his_api_controller.go 1.3MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. //"crypto/x509/pkix"
  10. "encoding/json"
  11. "fmt"
  12. "gdyb/controllers"
  13. "gdyb/enums"
  14. "gdyb/models"
  15. "gdyb/service"
  16. "gdyb/utils"
  17. "github.com/astaxie/beego"
  18. "github.com/axgle/mahonia"
  19. "github.com/gorilla/websocket"
  20. "github.com/jinzhu/gorm"
  21. "github.com/shopspring/decimal"
  22. "github.com/go-ole/go-ole"
  23. "github.com/go-ole/go-ole/oleutil"
  24. "io"
  25. "io/ioutil"
  26. //"math"
  27. "math/rand"
  28. "net/http"
  29. "net/url"
  30. "os"
  31. "path/filepath"
  32. "regexp"
  33. "strconv"
  34. "strings"
  35. "syscall"
  36. "time"
  37. "unsafe"
  38. )
  39. type HisApiController struct {
  40. controllers.BaseAuthAPIController
  41. }
  42. func HisManagerApiRegistRouters() {
  43. //挂号
  44. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  45. //上传就诊信息-上传明细-结算
  46. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  47. //查询
  48. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  49. //对总账
  50. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  51. //对明细
  52. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  53. //退费,退明细
  54. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  55. //退号
  56. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  57. //退明细
  58. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  59. //上传就诊信息-上传明细-预结算
  60. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  61. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  62. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  63. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  64. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  65. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  66. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  67. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  68. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  69. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  70. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  71. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  72. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  73. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  74. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  75. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  76. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  77. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  78. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  79. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  80. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  81. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  82. beego.Router("/api/check", &HisApiController{}, "get:Check")
  83. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  84. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  85. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  86. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  87. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  88. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  89. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  90. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  91. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  92. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  93. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  94. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  95. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  96. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  97. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  98. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  99. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  100. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  101. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  102. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  103. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  104. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  105. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  108. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  109. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  110. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  111. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  112. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  113. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  114. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  115. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  116. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  117. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  137. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  138. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  139. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  140. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  141. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  142. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  143. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  144. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  145. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  146. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  147. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  148. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  149. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  150. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  151. //库盘和变更
  152. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  153. //删除库盘和变更
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  155. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  156. //药品变更
  157. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  158. }
  159. func (c *HisApiController) FJ3501AND3502() {
  160. ids := c.GetString("ids")
  161. admin_user_id, _ := c.GetInt64("admin_user_id")
  162. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  163. id_arr := strings.Split(ids, ",")
  164. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  165. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  166. //库盘
  167. var errs []string
  168. for _, drug := range drugs {
  169. if drug.IsPc == 0 && drug.IsBg == 0 {
  170. var res2 ResultSix
  171. var res3 ResultSix
  172. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  173. var struct3501 models.Struct3501
  174. struct3501.OrgName = miConfig.OrgName
  175. struct3501.AccessKey = miConfig.AccessKey
  176. struct3501.Opter = roles.UserName
  177. struct3501.RequestUrl = miConfig.Url
  178. struct3501.Url = miConfig.Url
  179. struct3501.AppId = miConfig.Cainfo
  180. struct3501.AppSecret = miConfig.AppSecret
  181. struct3501.Enckey = miConfig.EncKey
  182. struct3501.SignKey = miConfig.SignKey
  183. struct3501.SecretKey = miConfig.SecretKey
  184. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  185. struct3501.FixmedinsHilistId = miConfig.Code
  186. struct3501.FixmedinsHilistName = miConfig.OrgName
  187. struct3501.RxFlag = "0"
  188. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  189. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  190. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  191. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  192. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  193. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  194. struct3501.FixmedinsBchno = number
  195. memo := make(map[string]interface{})
  196. memo["pric"] = drug.Price
  197. bytesData, _ := json.Marshal(memo)
  198. struct3501.Memo = string(bytesData)
  199. result1, result2, _ := service.FJyb3501(struct3501)
  200. saveLog(result1, result2, "3501", "3501")
  201. //saveLog(result, requestLog, "2201", "挂号")
  202. var respJSON2 map[string]interface{}
  203. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  206. return
  207. }
  208. userJSONBytes2, _ := json.Marshal(respJSON2)
  209. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res2.Infcode != -1 {
  215. drug.IsPc = 1
  216. drug.Bchno = number
  217. drug.PcDate = time.Now().Format("2006-01-02")
  218. err := service.SaveW(drug)
  219. if err == nil {
  220. var struct3502 models.Struct3502
  221. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  222. struct3502.FixmedinsHilistId = miConfig.Code
  223. struct3502.FixmedinsHilistName = miConfig.OrgName
  224. struct3502.FixmedinsCode = miConfig.Code
  225. struct3502.RxFlag = "0"
  226. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  227. struct3502.OrgName = miConfig.OrgName
  228. struct3502.Opter = roles.UserName
  229. struct3502.AccessKey = miConfig.AccessKey
  230. struct3502.RequestUrl = miConfig.Url
  231. struct3502.SecretKey = miConfig.SecretKey
  232. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  233. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  234. struct3502.Url = miConfig.Url
  235. struct3502.AppId = miConfig.Cainfo
  236. struct3502.AppSecret = miConfig.AppSecret
  237. struct3502.Enckey = miConfig.EncKey
  238. struct3502.SignKey = miConfig.SignKey
  239. struct3502.SecretKey = miConfig.SecretKey
  240. struct3502.Memo = ""
  241. struct3502.InvChgType = "108"
  242. struct3502.FixmedinsBchno = drug.Bchno
  243. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  244. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  245. result11, result22, _ := service.FJyb3502(struct3502)
  246. saveLog(result11, result22, "3502", "3502")
  247. var respJSON3 map[string]interface{}
  248. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  251. return
  252. }
  253. userJSONBytes3, _ := json.Marshal(respJSON3)
  254. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  255. utils.ErrorLog("解析失败:%v", err)
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  257. return
  258. }
  259. if res3.Infcode == -1 {
  260. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  261. c.ServeSuccessJSON(map[string]interface{}{
  262. "failed_code": -10,
  263. "msg": res3.ErrMsg,
  264. })
  265. } else {
  266. drug.IsBg = 1
  267. service.SaveW(drug)
  268. }
  269. }
  270. } else {
  271. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  272. }
  273. }
  274. //变更
  275. if drug.IsPc == 1 && drug.IsBg == 0 {
  276. var res3 ResultSix
  277. var struct3502 models.Struct3502
  278. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  279. struct3502.FixmedinsHilistId = miConfig.Code
  280. struct3502.FixmedinsHilistName = miConfig.OrgName
  281. struct3502.FixmedinsCode = miConfig.Code
  282. struct3502.Opter = roles.UserName
  283. struct3502.RxFlag = "0"
  284. struct3502.InvChgTime = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  285. struct3502.OrgName = miConfig.OrgName
  286. struct3502.AccessKey = miConfig.AccessKey
  287. struct3502.RequestUrl = miConfig.Url
  288. struct3502.SecretKey = miConfig.SecretKey
  289. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  290. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  291. struct3502.InvChgType = "108"
  292. struct3502.Url = miConfig.Url
  293. struct3502.AppId = miConfig.Cainfo
  294. struct3502.AppSecret = miConfig.AppSecret
  295. struct3502.Enckey = miConfig.EncKey
  296. struct3502.SignKey = miConfig.SignKey
  297. struct3502.SecretKey = miConfig.SecretKey
  298. struct3502.FixmedinsBchno = drug.Bchno
  299. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  300. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  301. result1, result2, _ := service.FJyb3502(struct3502)
  302. saveLog(result1, result2, "3502", "3502")
  303. var respJSON3 map[string]interface{}
  304. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  307. return
  308. }
  309. userJSONBytes3, _ := json.Marshal(respJSON3)
  310. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  311. utils.ErrorLog("解析失败:%v", err)
  312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  313. return
  314. }
  315. if res3.Infcode == -1 {
  316. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  317. } else {
  318. drug.IsBg = 1
  319. //drug.Bchno = number
  320. //drug.PcDate = time.Now().Format("2006-01-02")
  321. service.SaveW(drug)
  322. }
  323. }
  324. }
  325. if len(errs) == 0 {
  326. c.ServeSuccessJSON(map[string]interface{}{
  327. "msg": "盘存变更成功",
  328. })
  329. } else {
  330. c.ServeSuccessJSON(map[string]interface{}{
  331. "failed_code": -10,
  332. "msg": errs,
  333. })
  334. }
  335. }
  336. func (c *HisApiController) DeletePCandBG() {
  337. ids := c.GetString("ids")
  338. id_arr := strings.Split(ids, ",")
  339. admin_user_id, _ := c.GetInt64("admin_user_id")
  340. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  341. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  342. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  343. var err []string
  344. for _, item := range drugs {
  345. if item.IsPc == 1 && item.IsBg == 1 {
  346. var res FJ3507Result
  347. var res2 FJ3507Result
  348. var struct3507 models.Struct3507
  349. struct3507.FixmedinsBchno = item.Bchno
  350. struct3507.InvDataType = "1"
  351. struct3507.Opter = roles.UserName
  352. struct3507.OrgName = miConfig.OrgName
  353. struct3507.AccessKey = miConfig.AccessKey
  354. struct3507.RequestUrl = miConfig.Url
  355. struct3507.FixmedinsCode = miConfig.Code
  356. struct3507.SecretKey = miConfig.SecretKey
  357. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  358. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  359. struct3507.Url = miConfig.Url
  360. struct3507.AppId = miConfig.Cainfo
  361. struct3507.AppSecret = miConfig.AppSecret
  362. struct3507.Enckey = miConfig.EncKey
  363. struct3507.SignKey = miConfig.SignKey
  364. struct3507.SecretKey = miConfig.SecretKey
  365. result, result1, _ := service.FJyb3507(struct3507)
  366. saveLog(result, result1, "3507", "3507")
  367. var respJSON2 map[string]interface{}
  368. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  371. return
  372. }
  373. userJSONBytes2, _ := json.Marshal(respJSON2)
  374. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  375. utils.ErrorLog("解析失败:%v", err)
  376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  377. return
  378. }
  379. if res.Infcode != -1 {
  380. item.IsPc = 0
  381. err2 := service.SaveW(item)
  382. if err2 == nil {
  383. var struct3507_2 models.Struct3507
  384. struct3507_2.OrgName = miConfig.OrgName
  385. struct3507_2.AccessKey = miConfig.AccessKey
  386. struct3507_2.RequestUrl = miConfig.Url
  387. struct3507_2.Opter = roles.UserName
  388. struct3507_2.FixmedinsCode = miConfig.Code
  389. struct3507_2.SecretKey = miConfig.SecretKey
  390. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  391. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  392. struct3507_2.Url = miConfig.Url
  393. struct3507_2.AppId = miConfig.Cainfo
  394. struct3507_2.AppSecret = miConfig.AppSecret
  395. struct3507_2.Enckey = miConfig.EncKey
  396. struct3507_2.SignKey = miConfig.SignKey
  397. struct3507_2.SecretKey = miConfig.SecretKey
  398. struct3507_2.FixmedinsBchno = item.Bchno
  399. struct3507_2.InvDataType = "2"
  400. result11, result22, _ := service.FJyb3507(struct3507_2)
  401. saveLog(result11, result22, "3507", "3507")
  402. var respJSON3 map[string]interface{}
  403. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  406. return
  407. }
  408. userJSONBytes3, _ := json.Marshal(respJSON3)
  409. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  410. utils.ErrorLog("解析失败:%v", err)
  411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  412. return
  413. }
  414. if res2.Infcode != -1 {
  415. item.IsBg = 0
  416. item.Bchno = ""
  417. item.PcDate = ""
  418. service.SaveW(item)
  419. } else {
  420. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  421. }
  422. }
  423. } else {
  424. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  425. }
  426. }
  427. if item.IsPc == 1 && item.IsBg == 0 {
  428. var res FJ3507Result
  429. var struct3507 models.Struct3507
  430. struct3507.FixmedinsBchno = item.Bchno
  431. struct3507.InvDataType = "2"
  432. struct3507.Opter = roles.UserName
  433. struct3507.FixmedinsCode = miConfig.Code
  434. struct3507.OrgName = miConfig.OrgName
  435. struct3507.AccessKey = miConfig.AccessKey
  436. struct3507.RequestUrl = miConfig.Url
  437. struct3507.SecretKey = miConfig.SecretKey
  438. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  439. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  440. struct3507.Url = miConfig.Url
  441. struct3507.AppId = miConfig.Cainfo
  442. struct3507.AppSecret = miConfig.AppSecret
  443. struct3507.Enckey = miConfig.EncKey
  444. struct3507.SignKey = miConfig.SignKey
  445. struct3507.SecretKey = miConfig.SecretKey
  446. result, result1, _ := service.FJyb3507(struct3507)
  447. saveLog(result, result1, "3507", "3507")
  448. var respJSON3 map[string]interface{}
  449. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  452. return
  453. }
  454. userJSONBytes3, _ := json.Marshal(respJSON3)
  455. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  456. utils.ErrorLog("解析失败:%v", err)
  457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  458. return
  459. }
  460. if res.Infcode != -1 {
  461. item.IsBg = 0
  462. item.Bchno = ""
  463. item.PcDate = ""
  464. service.SaveW(item)
  465. } else {
  466. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  467. }
  468. }
  469. }
  470. if len(err) == 0 {
  471. c.ServeSuccessJSON(map[string]interface{}{
  472. "msg": "删除盘存变更成功",
  473. })
  474. } else {
  475. c.ServeSuccessJSON(map[string]interface{}{
  476. "failed_code": -10,
  477. "msg": err,
  478. })
  479. }
  480. }
  481. func (c *HisApiController) DeleteXSandBG() {
  482. ids := c.GetString("ids")
  483. id_arr := strings.Split(ids, ",")
  484. admin_user_id, _ := c.GetInt64("admin_user_id")
  485. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  486. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  487. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  488. for _, item := range drugs {
  489. if item.IsPc == 1 && item.IsBg == 1 {
  490. var struct3507 models.Struct3507
  491. struct3507.FixmedinsBchno = ""
  492. struct3507.InvDataType = "1"
  493. struct3507.Opter = roles.UserName
  494. struct3507.OrgName = miConfig.OrgName
  495. struct3507.AccessKey = miConfig.AccessKey
  496. struct3507.RequestUrl = miConfig.Url
  497. struct3507.SecretKey = miConfig.SecretKey
  498. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  499. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  500. struct3507.Url = miConfig.Url
  501. struct3507.AppId = miConfig.Cainfo
  502. struct3507.AppSecret = miConfig.AppSecret
  503. struct3507.Enckey = miConfig.EncKey
  504. struct3507.SignKey = miConfig.SignKey
  505. struct3507.SecretKey = miConfig.SecretKey
  506. struct3507.FixmedinsBchno = ""
  507. struct3507.InvDataType = "1"
  508. service.FJyb3507(struct3507)
  509. var struct3507_2 models.Struct3507
  510. struct3507_2.OrgName = miConfig.OrgName
  511. struct3507_2.AccessKey = miConfig.AccessKey
  512. struct3507_2.RequestUrl = miConfig.Url
  513. struct3507_2.SecretKey = miConfig.SecretKey
  514. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  515. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  516. struct3507_2.FixmedinsBchno = ""
  517. struct3507_2.InvDataType = "2"
  518. struct3507_2.Url = miConfig.Url
  519. struct3507_2.AppId = miConfig.Cainfo
  520. struct3507_2.AppSecret = miConfig.AppSecret
  521. struct3507_2.Enckey = miConfig.EncKey
  522. struct3507_2.SignKey = miConfig.SignKey
  523. struct3507_2.SecretKey = miConfig.SecretKey
  524. struct3507_2.FixmedinsBchno = ""
  525. struct3507_2.InvDataType = "1"
  526. service.FJyb3507(struct3507_2)
  527. }
  528. if item.IsPc == 1 && item.IsBg == 0 {
  529. var struct3507 models.Struct3507
  530. struct3507.OrgName = miConfig.OrgName
  531. struct3507.AccessKey = miConfig.AccessKey
  532. struct3507.RequestUrl = miConfig.Url
  533. struct3507.SecretKey = miConfig.SecretKey
  534. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  535. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  536. struct3507.FixmedinsBchno = ""
  537. struct3507.InvDataType = "1"
  538. service.FJyb3507(struct3507)
  539. }
  540. }
  541. }
  542. func (c *HisApiController) ChangeDrug() {
  543. ids := c.GetString("ids")
  544. id_arr := strings.Split(ids, ",")
  545. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  546. admin_user_id, _ := c.GetInt64("admin_user_id")
  547. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  548. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  549. for _, item := range flows {
  550. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  551. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  552. if prescription.OrderStatus == 2 { //已经结算
  553. //判断是否已经销售
  554. if item.IsSale == 1 { //是否已经销售,1是 0否
  555. //是否已经变更 1是 0否
  556. if item.IsChange == 0 { //没变更,进行变更操作
  557. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  558. }
  559. } else { //没销售,
  560. //进行商品销售接口
  561. SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "", roles)
  562. if item.IsChange == 0 { //没变更,进行变更操作
  563. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  564. }
  565. }
  566. } else { //还没结算
  567. if item.IsChange == 0 { //没变更,进行变更操作
  568. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  569. }
  570. }
  571. } else if item.ConsumableType == 7 {
  572. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  573. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  574. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  575. //判断是否已经销售
  576. if item.IsSale == 1 { //是否已经销售,1是 0否
  577. //是否已经变更 1是 0否
  578. if item.IsChange == 0 { //没变更,进行变更操作
  579. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  580. }
  581. } else { //没销售,
  582. //进行商品销售退货接口
  583. CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
  584. if item.IsChange == 0 { //没变更,进行变更操作
  585. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  586. }
  587. }
  588. } else { //还没结算
  589. if item.IsChange == 0 { //没变更,进行变更操作
  590. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  591. }
  592. }
  593. } else { //其他方式
  594. if item.IsChange == 0 { //没变更,进行变更操作
  595. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  596. }
  597. }
  598. }
  599. }
  600. func ChangeStock(count int64, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
  601. var struct3502 models.Struct3502
  602. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  603. struct3502.FixmedinsHilistId = miConfig.Code
  604. struct3502.FixmedinsHilistName = miConfig.OrgName
  605. struct3502.FixmedinsCode = miConfig.Code
  606. struct3502.Opter = role.UserName
  607. struct3502.RxFlag = "0"
  608. struct3502.InvChgTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  609. struct3502.OrgName = miConfig.OrgName
  610. struct3502.AccessKey = miConfig.AccessKey
  611. struct3502.RequestUrl = miConfig.Url
  612. struct3502.SecretKey = miConfig.SecretKey
  613. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  614. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  615. struct3502.Url = miConfig.Url
  616. struct3502.AppId = miConfig.Cainfo
  617. struct3502.AppSecret = miConfig.AppSecret
  618. struct3502.Enckey = miConfig.EncKey
  619. struct3502.SignKey = miConfig.SignKey
  620. struct3502.SecretKey = miConfig.SecretKey
  621. struct3502.InvChgType = chgType
  622. struct3502.FixmedinsBchno = ""
  623. struct3502.Cnt = strconv.FormatInt(count, 10)
  624. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  625. result1, result2, result3 := service.FJyb3502(struct3502)
  626. fmt.Println(result1)
  627. fmt.Println(result2)
  628. fmt.Println(result3)
  629. }
  630. func SaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
  631. var struct3505 models.Struct3505
  632. struct3505.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  633. struct3505.FixmedinsHilistId = miConfig.Code
  634. struct3505.FixmedinsHilistName = miConfig.OrgName
  635. struct3505.FixmedinsCode = miConfig.Code
  636. struct3505.FixmedinsBchno = ""
  637. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  638. struct3505.PrscDrName = roles.UserName
  639. struct3505.PharName = ""
  640. struct3505.PharPracCertNo = ""
  641. order := service.GetHisOrderByNumber(pre.BatchNumber)
  642. struct3505.SetlId = order.SetlId
  643. struct3505.MdtrtSn = order.MdtrtId
  644. struct3505.ManuLotnum = ""
  645. struct3505.ManuDate = ""
  646. struct3505.ExpyEnd = ""
  647. struct3505.RxFlag = "0"
  648. struct3505.TrdnFlag = "1"
  649. struct3505.Url = miConfig.Url
  650. struct3505.AppId = miConfig.Cainfo
  651. struct3505.AppSecret = miConfig.AppSecret
  652. struct3505.Enckey = miConfig.EncKey
  653. struct3505.SignKey = miConfig.SignKey
  654. struct3505.SecretKey = miConfig.SecretKey
  655. struct3505.RtalDocno = order.Number
  656. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  657. struct3505.SelRetnCnt = strValue
  658. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  659. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  660. struct3505.SelRetnOpterName = roles_two.UserName
  661. if order.IsMedicineInsurance == 1 {
  662. struct3505.MdtrtSetlType = "1"
  663. } else {
  664. struct3505.MdtrtSetlType = "2"
  665. }
  666. struct3505.OrgName = miConfig.OrgName
  667. struct3505.AccessKey = miConfig.AccessKey
  668. struct3505.RequestUrl = miConfig.Url
  669. struct3505.SecretKey = miConfig.SecretKey
  670. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  671. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  672. result1, result2, result3 := service.FJyb3505(struct3505)
  673. fmt.Println(result1)
  674. fmt.Println(result2)
  675. fmt.Println(result3)
  676. }
  677. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  678. var struct3506 models.Struct3506
  679. struct3506.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  680. struct3506.FixmedinsHilistId = miConfig.Code
  681. struct3506.FixmedinsHilistName = miConfig.OrgName
  682. struct3506.FixmedinsCode = miConfig.Code
  683. struct3506.FixmedinsBchno = ""
  684. order := service.GetHisOrderByNumber(pre.BatchNumber)
  685. //roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  686. struct3506.ManuLotnum = ""
  687. struct3506.ManuDate = ""
  688. struct3506.MdtrtSn = order.MdtrtId
  689. struct3506.ExpyEnd = ""
  690. struct3506.RxFlag = "0"
  691. struct3506.TrdnFlag = "1"
  692. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  693. struct3506.SelRetnCnt = strValue
  694. struct3506.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  695. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  696. struct3506.SelRetnOpterName = roles_two.UserName
  697. struct3506.OrgName = miConfig.OrgName
  698. struct3506.AccessKey = miConfig.AccessKey
  699. struct3506.RequestUrl = miConfig.Url
  700. struct3506.SecretKey = miConfig.SecretKey
  701. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  702. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  703. struct3506.Url = miConfig.Url
  704. struct3506.AppId = miConfig.Cainfo
  705. struct3506.AppSecret = miConfig.AppSecret
  706. struct3506.Enckey = miConfig.EncKey
  707. struct3506.SignKey = miConfig.SignKey
  708. struct3506.SecretKey = miConfig.SecretKey
  709. result1, result2, result3 := service.FJyb3506(struct3506)
  710. fmt.Println(result1)
  711. fmt.Println(result2)
  712. fmt.Println(result3)
  713. }
  714. func (c *HisApiController) Get1318() {
  715. adminUser := c.GetAdminUserInfo()
  716. admin_user_id, _ := c.GetInt64("admin_user_id")
  717. code := c.GetString("code")
  718. code = ""
  719. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  720. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  721. api := ""
  722. if miConfig.MdtrtareaAdmvs == "320921" {
  723. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  724. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  725. } else {
  726. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  727. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  728. }
  729. resp, requestErr := http.Get(api)
  730. if requestErr != nil {
  731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  732. return
  733. }
  734. body, ioErr := ioutil.ReadAll(resp.Body)
  735. if ioErr != nil {
  736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  738. return
  739. }
  740. var respJSON map[string]interface{}
  741. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  744. return
  745. }
  746. //var res Result2406
  747. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  748. result, _ := json.Marshal(respJSON)
  749. if err := json.Unmarshal([]byte(result), &res); err != nil {
  750. utils.ErrorLog("解析失败:%v", err)
  751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  752. return
  753. }
  754. if res.Infcode == "0" {
  755. c.ServeSuccessJSON(map[string]interface{}{
  756. "result": "",
  757. })
  758. } else {
  759. c.ServeSuccessJSON(map[string]interface{}{
  760. "failed_code": -10,
  761. "msg": res.ErrMsg,
  762. })
  763. */return
  764. //}
  765. }
  766. func (c *HisApiController) Get2503() {
  767. adminUser := c.GetAdminUserInfo()
  768. admin_user_id, _ := c.GetInt64("admin_user_id")
  769. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  770. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  771. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  772. }
  773. func (c *HisApiController) Get2406() {
  774. id, _ := c.GetInt64("id")
  775. record_time := c.GetString("record_time")
  776. his_patient_id, _ := c.GetInt64("his_patient_id")
  777. admin_user_id, _ := c.GetInt64("admin_user_id")
  778. diagnosis_id := c.GetString("diagnosis")
  779. timeLayout := "2006-01-02"
  780. loc, _ := time.LoadLocation("Local")
  781. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  782. if err != nil {
  783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  784. return
  785. }
  786. recordDateTime := theTime.Unix()
  787. adminUser := c.GetAdminUserInfo()
  788. diagnosis_ids := strings.Split(diagnosis_id, ",")
  789. var config []*models.HisXtDiagnoseConfig
  790. for _, item := range diagnosis_ids {
  791. id, _ := strconv.ParseInt(item, 10, 64)
  792. diagnosisConfig, _ := service.FindDiagnoseById(id)
  793. config = append(config, &diagnosisConfig)
  794. }
  795. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  796. fmt.Println(his_patient_id)
  797. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  798. //timestamp := time.Now().Unix()
  799. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  800. var patientPrescription models.HisPrescriptionInfo
  801. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  802. if patientPrescription.ID == 0 {
  803. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  804. }
  805. var res2 Result2406
  806. if miConfig.MdtrtareaAdmvs == "341203" {
  807. data := make(map[string]interface{})
  808. client := &http.Client{}
  809. data["psn_no"] = his.PsnNo
  810. data["mdtrt_id"] = his.Number
  811. data["operator"] = roles.UserName
  812. data["cert_no"] = his.IdCardNo
  813. data["org_name"] = miConfig.OrgName
  814. data["psn_name"] = his.Name
  815. data["ipt_otp_no"] = his.IptOtpNo
  816. data["ipt_psn_sp_flag_type"] = "0901"
  817. data["ipt_psn_sp_flag"] = "1"
  818. data["fixmedins_code"] = miConfig.Code
  819. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  820. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  821. data["url"] = miConfig.Url
  822. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  823. bytesData, _ := json.Marshal(data)
  824. var req *http.Request
  825. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  826. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  827. resp, _ := client.Do(req)
  828. defer resp.Body.Close()
  829. body, ioErr := ioutil.ReadAll(resp.Body)
  830. if ioErr != nil {
  831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  833. return
  834. }
  835. var respJSON map[string]interface{}
  836. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  839. return
  840. }
  841. status := respJSON["data"].(map[string]interface{})["status"].(string)
  842. if status == "0" {
  843. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  844. c.ServeSuccessJSON(map[string]interface{}{
  845. "failed_code": -10,
  846. "msg": err_msg,
  847. })
  848. return
  849. }
  850. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  851. userJSONBytes, _ := json.Marshal(respJSON)
  852. fmt.Println("log")
  853. fmt.Println(string(userJSONBytes))
  854. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  855. utils.ErrorLog("解析失败:%v", err)
  856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  857. return
  858. }
  859. }
  860. if res2.Infcode != 0 {
  861. adminUser := c.GetAdminUserInfo()
  862. errlog := &models.HisOrderError{
  863. UserOrgId: adminUser.CurrentOrgId,
  864. Ctime: time.Now().Unix(),
  865. Mtime: time.Now().Unix(),
  866. ErrMsg: res2.ErrMsg,
  867. Status: 1,
  868. PatientId: id,
  869. RecordTime: recordDateTime,
  870. Stage: 3,
  871. }
  872. service.CreateErrMsgLog(errlog)
  873. c.ServeSuccessJSON(map[string]interface{}{
  874. "failed_code": -10,
  875. "msg": res2.ErrMsg,
  876. })
  877. return
  878. } else {
  879. c.ServeSuccessJSON(map[string]interface{}{
  880. "msg": "上传成功",
  881. })
  882. return
  883. }
  884. }
  885. func (c *HisApiController) Get4105() {
  886. }
  887. func (c *HisApiController) Post5302() {
  888. patient_id, _ := c.GetInt64("id")
  889. admin_user_id, _ := c.GetInt64("admin_user_id")
  890. p, _ := service.GetHisPatientById(patient_id)
  891. adminUser := c.GetAdminUserInfo()
  892. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  893. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  894. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  895. }
  896. func (c *HisApiController) Get4104() {
  897. }
  898. type Output struct {
  899. CertNo string `json:"certno"`
  900. PsnName string `json:"psn_name"`
  901. CardNo string `json:"card_no"`
  902. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  903. CardSN string `json:"card_sn"`
  904. PsnCertType string `json:"psn_cert_type"`
  905. MdtrtCertNo string `json:"mdtrt_cert_no"`
  906. MdtrtCertType string `json:"mdtrt_cert_type"`
  907. QRCode string `json:"qrCode"`
  908. EcToken string `json:"ecToken"`
  909. }
  910. type AHResponse struct {
  911. Body AHBody `json:"body"`
  912. Code int `json:"code"`
  913. CSBCode int `json:"csbCode"`
  914. Message string `json:"message"`
  915. RequestID string `json:"requestId"`
  916. State struct{} `json:"state"`
  917. }
  918. type AHBody struct {
  919. ErrMsg string `json:"err_msg"`
  920. InfRefMsgID string `json:"inf_refmsgid"`
  921. InfCode int `json:"infcode"`
  922. Output struct {
  923. Result []struct {
  924. BasMednFlag string `json:"bas_medn_flag"`
  925. ChldMedcFlag string `json:"chld_medc_flag"`
  926. ChrgitmLv string `json:"chrgitm_lv"`
  927. Cnt float64 `json:"cnt"`
  928. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  929. DrtReimFlag string `json:"drt_reim_flag"`
  930. FeedetlSn string `json:"feedetl_sn"`
  931. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  932. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  933. InscpScpAmt float64 `json:"inscp_scp_amt"`
  934. ListSpItemFlag string `json:"list_sp_item_flag"`
  935. LmtUsedFlag string `json:"lmt_used_flag"`
  936. MedChrgitmType string `json:"med_chrgitm_type"`
  937. Memo string `json:"memo"`
  938. OverlmtAmt float64 `json:"overlmt_amt"`
  939. PreselfpayAmt float64 `json:"preselfpay_amt"`
  940. Pric float64 `json:"pric"`
  941. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  942. SelfpayProp float64 `json:"selfpay_prop"`
  943. } `json:"result"`
  944. } `json:"output"`
  945. }
  946. type Response struct {
  947. Output Output `json:"output"`
  948. Infcode int `json:"infcode"`
  949. InfRefMsgID string `json:"inf_refmsgid"`
  950. RefMsgTime string `json:"refmsg_time"`
  951. RespondTime string `json:"respond_time"`
  952. ErrMsg string `json:"err_msg"`
  953. WarnMsg string `json:"warn_msg"`
  954. SignType string `json:"signtype"`
  955. CAInfo string `json:"cainfo"`
  956. }
  957. func (c *HisApiController) Getquerydata() {
  958. query_type, _ := c.GetInt64("type")
  959. refd_setl_flag := c.GetString("refd_setl_flag")
  960. med_type := c.GetString("med_type")
  961. //admin_user_id,_ := c.GetInt64("admin_user_id")
  962. cert_no := c.GetString("cert_no")
  963. psn_no := c.GetString("psn_no")
  964. start_time := c.GetString("start_time")
  965. end_time := c.GetString("end_time")
  966. page, _ := c.GetInt64("page")
  967. limit, _ := c.GetInt64("limit")
  968. var bp models.BusinessParams5262
  969. bp.RefdSetlFlag = refd_setl_flag
  970. bp.MedType = med_type
  971. bp.Certno = cert_no
  972. bp.Psnno = psn_no
  973. bp.QBegntime = start_time
  974. bp.QEndtime = end_time
  975. if query_type == 1 { //本地
  976. Post5262(c, bp, page, limit)
  977. } else { //异地
  978. Post5267(c, bp, page, limit)
  979. }
  980. }
  981. func (c *HisApiController) Drugscheck() {
  982. admin_user_id, _ := c.GetInt64("admin_user_id")
  983. adminUser := c.GetAdminUserInfo()
  984. var queryResult []QueryResult
  985. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  986. for _, item := range drugs {
  987. result := QueryResult{
  988. ID: item.ID,
  989. Name: item.DrugName,
  990. Code: item.MedicalInsuranceNumber,
  991. List_type_code: "101",
  992. }
  993. queryResult = append(queryResult, result)
  994. }
  995. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  996. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  997. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  998. for _, item := range queryResult {
  999. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  1000. }
  1001. }
  1002. func (c *HisApiController) Goodcheck() {
  1003. admin_user_id, _ := c.GetInt64("admin_user_id")
  1004. adminUser := c.GetAdminUserInfo()
  1005. var queryResult []QueryResult
  1006. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  1007. for _, item := range goods {
  1008. result := QueryResult{
  1009. ID: item.ID,
  1010. Name: item.GoodName,
  1011. Code: item.SocialSecurityDirectoryCode,
  1012. List_type_code: "301",
  1013. }
  1014. queryResult = append(queryResult, result)
  1015. }
  1016. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1017. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1018. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1019. for _, item := range queryResult {
  1020. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  1021. //service.Hnyb3302(miConfig.OrgName,role.UserName,miConfig.Code,miConfig.InsuplcAdmdvs,miConfig.MdtrtareaAdmvs,miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url,miConfig.AccessKey,miConfig.SecretKey)
  1022. }
  1023. }
  1024. func (c *HisApiController) Projectcheck() {
  1025. admin_user_id, _ := c.GetInt64("admin_user_id")
  1026. adminUser := c.GetAdminUserInfo()
  1027. var queryResult []QueryResult
  1028. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  1029. for _, item := range projects {
  1030. result := QueryResult{
  1031. ID: item.ID,
  1032. Name: item.ProjectName,
  1033. Code: item.MedicalCode,
  1034. List_type_code: "201",
  1035. }
  1036. queryResult = append(queryResult, result)
  1037. }
  1038. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1039. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1040. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1041. for _, item := range queryResult {
  1042. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  1043. }
  1044. }
  1045. //func (c *HisApiController)CancleDia(){
  1046. //
  1047. // id, _ := c.GetInt64("id")
  1048. // record_time := c.GetString("record_time")
  1049. // his_patient_id, _ := c.GetInt64("his_patient_id")
  1050. //
  1051. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1052. //
  1053. // diagnosis_id := c.GetString("diagnosis")
  1054. // sick_type, _ := c.GetInt64("sick_type")
  1055. // reg_type, _ := c.GetInt64("p_type")
  1056. // begin_time := c.GetString("begin_time")
  1057. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  1058. //
  1059. //
  1060. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  1061. //
  1062. // fmt.Println(acct_used_flag)
  1063. //
  1064. //
  1065. // timeLayout := "2006-01-02"
  1066. // loc, _ := time.LoadLocation("Local")
  1067. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1068. // if err != nil {
  1069. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1070. // return
  1071. // }
  1072. // recordDateTime := theTime.Unix()
  1073. // adminUser := c.GetAdminUserInfo()
  1074. //
  1075. //
  1076. //
  1077. //
  1078. //
  1079. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1080. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1081. // var patientPrescription models.HisPrescriptionInfo
  1082. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1083. // if patientPrescription.ID == 0 {
  1084. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1085. // }
  1086. // //if patientPrescription.Do
  1087. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1088. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1089. //
  1090. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1091. //
  1092. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  1093. //
  1094. // var config []*models.HisXtDiagnoseConfig
  1095. // for _, item := range diagnosis_ids {
  1096. // id, _ := strconv.ParseInt(item, 10, 64)
  1097. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  1098. // config = append(config, &diagnosisConfig)
  1099. // }
  1100. //
  1101. // sickConfig, _ := service.FindSickById(sick_type)
  1102. //
  1103. //
  1104. // data := make(map[string]interface{})
  1105. // client := &http.Client{}
  1106. // data["psn_no"] = his.PsnNo
  1107. // data["mdtrt_id"] = his.Number
  1108. // data["doctor"] = roles.UserName
  1109. // data["department"] = department.Name
  1110. // data["org_name"] = miConfig.OrgName
  1111. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  1112. // data["doctor_id"] = doctor_info.DoctorNumber
  1113. // data["new_doctor_name"] = doctor_info.UserName
  1114. // data["fixmedins_code"] = miConfig.Code
  1115. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  1116. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1117. // data["secret_key"] = miConfig.SecretKey
  1118. // data["sick_code"] = sickConfig.CountryCode
  1119. // data["sick_name"] = sickConfig.ClassName
  1120. // data["url"] = miConfig.Url
  1121. // data["ak"] = miConfig.AccessKey
  1122. // data["begin_time"] = begin_time
  1123. // data["cainfo"] = miConfig.Cainfo
  1124. // data["is_vaild"] = "0"
  1125. //
  1126. // data["dept"] = strconv.FormatInt(department.ID, 10)
  1127. // data["config"] = config
  1128. // bytesData, _ := json.Marshal(data)
  1129. //
  1130. // var req *http.Request
  1131. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  1132. // resp, _ := client.Do(req)
  1133. // defer resp.Body.Close()
  1134. // body, ioErr := ioutil.ReadAll(resp.Body)
  1135. // if ioErr != nil {
  1136. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1138. // return
  1139. // }
  1140. // var respJSON map[string]interface{}
  1141. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1142. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1144. // return
  1145. // }
  1146. //
  1147. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1148. // userJSONBytes, _ := json.Marshal(respJSON)
  1149. // fmt.Println("log")
  1150. // fmt.Println(string(userJSONBytes))
  1151. //
  1152. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  1153. // utils.ErrorLog("解析失败:%v", err)
  1154. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1155. // return
  1156. // }
  1157. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  1158. // res2.Output = ressix10265.Output
  1159. // res2.ErrMsg = ressix10265.ErrMsg
  1160. // res2.Cainfo = ressix10265.Cainfo
  1161. // res2.WarnMsg = ressix10265.WarnMsg
  1162. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  1163. // res2.Infcode = infocode
  1164. //
  1165. //}
  1166. func (c *HisApiController) Get4102() {
  1167. order_id, _ := c.GetInt64("order_id")
  1168. admin_user_id, _ := c.GetInt64("admin_user_id")
  1169. stas_type := c.GetString("stas_type")
  1170. order, _ := service.GetHisOrderByIDTwo(order_id)
  1171. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1172. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1173. var pp models.PublicParams
  1174. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1175. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1176. pp.FixmedinsName = miConfig.OrgName
  1177. pp.FixmedinsCode = miConfig.Code
  1178. pp.RequestUrl = miConfig.Url
  1179. pp.Cainfo = miConfig.Cainfo
  1180. pp.SecretKey = miConfig.SecretKey
  1181. pp.AccessKey = miConfig.AccessKey
  1182. pp.OpterName = curRoles.UserName
  1183. if miConfig.MdtrtareaAdmvs == "350500" {
  1184. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1185. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  1186. saveLog(result, request, "4102", "清单确认")
  1187. var dat map[string]interface{}
  1188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1189. fmt.Println(dat)
  1190. } else {
  1191. fmt.Println(err)
  1192. }
  1193. var empty ResultFourteen
  1194. userJSONBytes, _ := json.Marshal(dat)
  1195. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1196. utils.ErrorLog("解析失败:%v", err)
  1197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1198. return
  1199. }
  1200. if empty.Infcode == 0 {
  1201. c.ServeSuccessJSON(map[string]interface{}{
  1202. "msg": "确认成功",
  1203. })
  1204. return
  1205. }
  1206. } else {
  1207. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1208. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  1209. result3, request3 := service.Jxyb4105(pp)
  1210. saveLog(result, request, "4102", "清单确认")
  1211. saveLog(result2, request2, "4103", "清单确认")
  1212. saveLog(result3, request3, "4105", "清单统计")
  1213. var dat map[string]interface{}
  1214. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1215. fmt.Println(dat)
  1216. } else {
  1217. fmt.Println(err)
  1218. }
  1219. var empty ResultFourteen
  1220. userJSONBytes, _ := json.Marshal(dat)
  1221. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1222. utils.ErrorLog("解析失败:%v", err)
  1223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1224. return
  1225. }
  1226. if empty.Infcode == 0 {
  1227. c.ServeSuccessJSON(map[string]interface{}{
  1228. "msg": "确认成功",
  1229. })
  1230. return
  1231. }
  1232. }
  1233. }
  1234. // 对账权限查询
  1235. func (c *HisApiController) Get3260() {
  1236. admin_user_id, _ := c.GetInt64("admin_user_id")
  1237. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1238. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1239. var api string
  1240. var res models.JSResult3260
  1241. if miConfig.MdtrtareaAdmvs == "320921" {
  1242. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1243. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1244. } else {
  1245. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1246. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1247. }
  1248. resp, requestErr := http.Get(api)
  1249. if requestErr != nil {
  1250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1251. return
  1252. }
  1253. body, ioErr := ioutil.ReadAll(resp.Body)
  1254. if ioErr != nil {
  1255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1257. return
  1258. }
  1259. var respJSON map[string]interface{}
  1260. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1263. return
  1264. }
  1265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1266. result, _ := json.Marshal(respJSON)
  1267. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1268. utils.ErrorLog("解析失败:%v", err)
  1269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1270. return
  1271. }
  1272. if res.Infcode == "0" {
  1273. c.ServeSuccessJSON(map[string]interface{}{
  1274. "result": res.Output.Data,
  1275. })
  1276. } else {
  1277. c.ServeSuccessJSON(map[string]interface{}{
  1278. "failed_code": -10,
  1279. "msg": res.ErrMsg,
  1280. })
  1281. return
  1282. }
  1283. }
  1284. func (c *HisApiController) Get3261() {
  1285. admin_user_id, _ := c.GetInt64("admin_user_id")
  1286. //month := c.GetString("month")
  1287. startTime := c.GetString("start_time")
  1288. //endTime, _ := c.GetString("end_time")
  1289. times := strings.Split(startTime, "-")
  1290. stmt_mon := times[0] + times[1]
  1291. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1292. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1293. var api string
  1294. var res models.JSResult3261
  1295. //var res10265 Result5301For10265
  1296. if miConfig.MdtrtareaAdmvs == "320921" {
  1297. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1298. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1299. } else {
  1300. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1301. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1302. }
  1303. resp, requestErr := http.Get(api)
  1304. if requestErr != nil {
  1305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1306. return
  1307. }
  1308. body, ioErr := ioutil.ReadAll(resp.Body)
  1309. if ioErr != nil {
  1310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1312. return
  1313. }
  1314. var respJSON map[string]interface{}
  1315. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1318. return
  1319. }
  1320. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1321. result, _ := json.Marshal(respJSON)
  1322. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1323. utils.ErrorLog("解析失败:%v", err)
  1324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1325. return
  1326. }
  1327. if res.Infcode == "0" {
  1328. c.ServeSuccessJSON(map[string]interface{}{
  1329. "result": res.Output,
  1330. })
  1331. } else {
  1332. c.ServeSuccessJSON(map[string]interface{}{
  1333. "failed_code": -10,
  1334. "msg": res.ErrMsg,
  1335. })
  1336. return
  1337. }
  1338. }
  1339. type TempFun struct {
  1340. FundKey string
  1341. FundCode string
  1342. }
  1343. func (c *HisApiController) Get3262() {
  1344. admin_user_id, _ := c.GetInt64("admin_user_id")
  1345. startTime := c.GetString("start_time")
  1346. endTime := c.GetString("end_time")
  1347. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1348. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1349. //timeLayout := "2006-01-02"
  1350. //loc, _ := time.LoadLocation("Local")
  1351. //var theStartTIme int64
  1352. //if len(startTime) > 0 {
  1353. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  1354. // if err != nil {
  1355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1356. // return
  1357. // }
  1358. // theStartTIme = theTime.Unix()
  1359. //}
  1360. //var theEndtTIme int64
  1361. //if len(endTime) > 0 {
  1362. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  1363. // if err != nil {
  1364. // utils.ErrorLog(err.Error())
  1365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1366. // return
  1367. // }
  1368. // theEndtTIme = theTime.Unix()
  1369. //}
  1370. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1371. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1372. for _, team := range datas {
  1373. fmt.Println(team.PsnTime)
  1374. for _, team_two := range datas_two {
  1375. fmt.Println(team_two.PsnTime)
  1376. if team.FundKey == team_two.FundKey {
  1377. fmt.Println(team_two.PsnTime)
  1378. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  1379. fmt.Println(team.PsnTime)
  1380. }
  1381. }
  1382. }
  1383. fmt.Println("1111")
  1384. fmt.Println(datas)
  1385. fmt.Println("1111")
  1386. var twos []models.FixMonRecDetailFileInTwo
  1387. for _, team := range datas {
  1388. var two models.FixMonRecDetailFileInTwo
  1389. two.MedType = team.MedType
  1390. two.Insutype = team.Insutype
  1391. two.PsnType = team.PsnType
  1392. two.MedType = team.MedType
  1393. two.FixBlngAdmdvs = "999999"
  1394. two.InsuAdmdvs = "555555"
  1395. two.PsnTime = team.PsnTime
  1396. two.PsnCnt = team.PsnCnt
  1397. two.FundKey = team.FundKey
  1398. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1399. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1400. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1401. two.MedfeeSumAmt = ms
  1402. two.InscpAmt = ia
  1403. two.FundPaySumAmt = fps
  1404. twos = append(twos, two)
  1405. }
  1406. //startTime := c.GetString("start_time")
  1407. //endTime, _ := c.GetString("end_time")
  1408. times := strings.Split(startTime, "-")
  1409. stmt_mon := times[0] + times[1]
  1410. var funs []models.FundDetail
  1411. for _, item := range datas {
  1412. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1413. funs = append(funs, fun...)
  1414. }
  1415. var funInfos []models.Fund
  1416. //for _, item := range funs {
  1417. // var rf []models.FundInfo
  1418. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1419. // for _, subitem := range rf {
  1420. // var fund models.Fund
  1421. // fund.FundCode = subitem.FundPayType
  1422. // fund.FundName = subitem.FundPayTypeName
  1423. // fund.FundAmt = subitem.FundPayAmt
  1424. // fund.FundKey = item.FundKey
  1425. // fund.InsuAdmdvs = "555555"
  1426. // fund.FixBlngAdmdvs = "999999"
  1427. // funInfos = append(funInfos, fund)
  1428. // }
  1429. //}
  1430. var tempFuns []TempFun
  1431. for _, funInfo := range funInfos {
  1432. var tempFun TempFun
  1433. tempFun.FundKey = funInfo.FundKey
  1434. tempFun.FundCode = funInfo.FundCode
  1435. tempFuns = append(tempFuns, tempFun)
  1436. }
  1437. tempFuns = RemoveRepeatedFunElement(tempFuns)
  1438. fmt.Println(tempFuns)
  1439. var funInfosTwo []models.Fund
  1440. decimal.DivisionPrecision = 2
  1441. for _, item := range tempFuns {
  1442. var fund models.Fund
  1443. for _, subItem := range funInfos {
  1444. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  1445. fund.FundKey = subItem.FundKey
  1446. fund.InsuAdmdvs = subItem.InsuAdmdvs
  1447. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  1448. fund.FundName = subItem.FundName
  1449. fund.FundCode = subItem.FundCode
  1450. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  1451. }
  1452. }
  1453. funInfosTwo = append(funInfosTwo, fund)
  1454. }
  1455. fmt.Println("funInfosTwo")
  1456. fmt.Println(funInfosTwo)
  1457. var upld_btch string
  1458. var empty models.JSResultEmpty
  1459. data := make(map[string]interface{})
  1460. data["org_name"] = miConfig.OrgName
  1461. data["doctor"] = curRoles.UserName
  1462. data["doctor_name"] = curRoles.UserName
  1463. data["fixmedins_code"] = miConfig.Code
  1464. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1465. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1466. data["secret_key"] = miConfig.SecretKey
  1467. data["url"] = miConfig.Url
  1468. data["ak"] = miConfig.AccessKey
  1469. data["cainfo"] = miConfig.Cainfo
  1470. data["datas"] = twos
  1471. data["fund"] = funInfosTwo
  1472. fmt.Println(twos)
  1473. month := time.Unix(1557042972, 0).Format("1")
  1474. year := time.Now().Format("2006")
  1475. month = time.Now().Format("01")
  1476. day := time.Now().Format("02")
  1477. hour := time.Now().Format("15")
  1478. min := time.Now().Format("04")
  1479. sec := time.Now().Format("05")
  1480. fix_fill_date := year + month + day + hour + min + sec
  1481. data["fix_fill_dept"] = miConfig.OrgName
  1482. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1483. data["fix_fill_psn"] = curRoles.UserName
  1484. data["fix_fill_date"] = fix_fill_date
  1485. data["stmt_loc"] = "2"
  1486. data["setl_mon"] = stmt_mon
  1487. upld_btch = "0"
  1488. data["upld_btch"] = upld_btch
  1489. //fmt.Println(data)
  1490. client := &http.Client{}
  1491. bytesData, _ := json.Marshal(data)
  1492. var req *http.Request
  1493. if miConfig.MdtrtareaAdmvs == "320921" {
  1494. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1495. } else {
  1496. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1497. }
  1498. resp, _ := client.Do(req)
  1499. defer resp.Body.Close()
  1500. body, ioErr := ioutil.ReadAll(resp.Body)
  1501. if ioErr != nil {
  1502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1504. }
  1505. var respJSON map[string]interface{}
  1506. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1509. }
  1510. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1511. //fmt.Println(respJSON)
  1512. result, _ := json.Marshal(respJSON)
  1513. //fmt.Println(result)
  1514. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1515. utils.ErrorLog("解析失败:%v", err)
  1516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1517. }
  1518. if empty.Infcode != "0" {
  1519. c.ServeSuccessJSON(map[string]interface{}{
  1520. "failed_code": -10,
  1521. "msg": empty.ErrMsg,
  1522. })
  1523. return
  1524. } else {
  1525. c.ServeSuccessJSON(map[string]interface{}{
  1526. "msg": "上传成功",
  1527. })
  1528. return
  1529. }
  1530. }
  1531. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  1532. newArr = make([]TempFun, 0)
  1533. for i := 0; i < len(arr); i++ {
  1534. repeat := false
  1535. for j := i + 1; j < len(arr); j++ {
  1536. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  1537. repeat = true
  1538. break
  1539. }
  1540. }
  1541. if !repeat {
  1542. newArr = append(newArr, arr[i])
  1543. }
  1544. }
  1545. return
  1546. }
  1547. func (c *HisApiController) Get3263() {
  1548. admin_user_id, _ := c.GetInt64("admin_user_id")
  1549. startTime := c.GetString("start_time")
  1550. //endTime, _ := c.GetString("end_time")
  1551. times := strings.Split(startTime, "-")
  1552. setl_mon := times[0] + times[1]
  1553. upld_btch := "0"
  1554. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1555. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1556. var result3263 models.JSResult3263
  1557. data := make(map[string]interface{})
  1558. data["org_name"] = miConfig.OrgName
  1559. data["doctor"] = curRoles.UserName
  1560. data["doctor_name"] = curRoles.UserName
  1561. data["fixmedins_code"] = miConfig.Code
  1562. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1563. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1564. data["secret_key"] = miConfig.SecretKey
  1565. data["url"] = miConfig.Url
  1566. data["ak"] = miConfig.AccessKey
  1567. data["cainfo"] = miConfig.Cainfo
  1568. data["setl_mon"] = setl_mon
  1569. data["stmt_loc"] = "2"
  1570. data["upld_btch"] = upld_btch
  1571. client := &http.Client{}
  1572. bytesData, _ := json.Marshal(data)
  1573. var req *http.Request
  1574. if miConfig.MdtrtareaAdmvs == "320921" {
  1575. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1576. } else {
  1577. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1578. }
  1579. resp, _ := client.Do(req)
  1580. defer resp.Body.Close()
  1581. body, ioErr := ioutil.ReadAll(resp.Body)
  1582. if ioErr != nil {
  1583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1585. }
  1586. var respJSON map[string]interface{}
  1587. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1590. }
  1591. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1592. fmt.Println(respJSON)
  1593. result, _ := json.Marshal(respJSON)
  1594. fmt.Println(result)
  1595. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1596. utils.ErrorLog("解析失败:%v", err)
  1597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1598. }
  1599. if result3263.Infcode != "0" {
  1600. c.ServeSuccessJSON(map[string]interface{}{
  1601. "failed_code": -10,
  1602. "msg": result3263.ErrMsg,
  1603. })
  1604. return
  1605. } else {
  1606. c.ServeSuccessJSON(map[string]interface{}{
  1607. "list": result3263.Output,
  1608. })
  1609. return
  1610. }
  1611. }
  1612. func (c *HisApiController) Get3264() {
  1613. admin_user_id, _ := c.GetInt64("admin_user_id")
  1614. startTime := c.GetString("start_time")
  1615. //endTime, _ := c.GetString("end_time")
  1616. times := strings.Split(startTime, "-")
  1617. setl_mon := times[0] + times[1]
  1618. upld_btch := "0"
  1619. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1620. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1621. //solidify_id := []
  1622. var result3263 models.JSResult3263
  1623. data := make(map[string]interface{})
  1624. data["org_name"] = miConfig.OrgName
  1625. data["doctor"] = curRoles.UserName
  1626. data["doctor_name"] = curRoles.UserName
  1627. data["fixmedins_code"] = miConfig.Code
  1628. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1629. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1630. data["secret_key"] = miConfig.SecretKey
  1631. data["url"] = miConfig.Url
  1632. data["ak"] = miConfig.AccessKey
  1633. data["cainfo"] = miConfig.Cainfo
  1634. data["setl_mon"] = setl_mon
  1635. data["stmt_loc"] = "2"
  1636. data["upld_btch"] = upld_btch
  1637. client := &http.Client{}
  1638. bytesData, _ := json.Marshal(data)
  1639. var req3263 *http.Request
  1640. if miConfig.MdtrtareaAdmvs == "320921" {
  1641. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1642. } else {
  1643. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1644. }
  1645. resp, _ := client.Do(req3263)
  1646. defer resp.Body.Close()
  1647. body, ioErr := ioutil.ReadAll(resp.Body)
  1648. if ioErr != nil {
  1649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1651. }
  1652. var respJSON3263 map[string]interface{}
  1653. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1656. }
  1657. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1658. fmt.Println(respJSON3263)
  1659. result, _ := json.Marshal(respJSON3263)
  1660. fmt.Println(result)
  1661. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1662. utils.ErrorLog("解析失败:%v", err)
  1663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1664. }
  1665. var ids []string
  1666. for _, item := range result3263.Output {
  1667. ids = append(ids, item.SolidifyID)
  1668. }
  1669. var empty models.JSResultEmpty
  1670. data2 := make(map[string]interface{})
  1671. data2["org_name"] = miConfig.OrgName
  1672. data2["doctor"] = curRoles.UserName
  1673. data2["doctor_name"] = curRoles.UserName
  1674. data2["fixmedins_code"] = miConfig.Code
  1675. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1676. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1677. data2["secret_key"] = miConfig.SecretKey
  1678. data2["url"] = miConfig.Url
  1679. data2["ak"] = miConfig.AccessKey
  1680. data2["cainfo"] = miConfig.Cainfo
  1681. data2["setl_mon"] = setl_mon
  1682. data2["stmt_loc"] = "2"
  1683. data2["upld_btch"] = upld_btch
  1684. data2["solidify_id"] = ids
  1685. client2 := &http.Client{}
  1686. bytesData2, _ := json.Marshal(data2)
  1687. var req *http.Request
  1688. if miConfig.MdtrtareaAdmvs == "320921" {
  1689. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1690. } else {
  1691. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1692. }
  1693. resp2, _ := client2.Do(req)
  1694. defer resp.Body.Close()
  1695. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1696. if ioErr2 != nil {
  1697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1699. }
  1700. var respJSON map[string]interface{}
  1701. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1704. }
  1705. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1706. fmt.Println(respJSON)
  1707. result2, _ := json.Marshal(respJSON)
  1708. fmt.Println(result2)
  1709. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1710. utils.ErrorLog("解析失败:%v", err)
  1711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1712. }
  1713. if empty.Infcode != "0" {
  1714. c.ServeSuccessJSON(map[string]interface{}{
  1715. "failed_code": -10,
  1716. "msg": empty.ErrMsg,
  1717. })
  1718. return
  1719. } else {
  1720. c.ServeSuccessJSON(map[string]interface{}{
  1721. "msg": "",
  1722. })
  1723. return
  1724. }
  1725. }
  1726. func (c *HisApiController) Get3265() {
  1727. admin_user_id, _ := c.GetInt64("admin_user_id")
  1728. startTime := c.GetString("start_time")
  1729. //endTime, _ := c.GetString("end_time")
  1730. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1731. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1732. times := strings.Split(startTime, "-")
  1733. setl_mon := times[0] + times[1]
  1734. var upld_btch string
  1735. upld_btch = "0"
  1736. //var empty models.JSResultEmpty
  1737. var result3265 models.JSResult3264
  1738. var result3263 models.JSResult3263
  1739. data2 := make(map[string]interface{})
  1740. data2["org_name"] = miConfig.OrgName
  1741. data2["doctor"] = curRoles.UserName
  1742. data2["doctor_name"] = curRoles.UserName
  1743. data2["fixmedins_code"] = miConfig.Code
  1744. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1745. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1746. data2["secret_key"] = miConfig.SecretKey
  1747. data2["url"] = miConfig.Url
  1748. data2["ak"] = miConfig.AccessKey
  1749. data2["cainfo"] = miConfig.Cainfo
  1750. data2["setl_mon"] = setl_mon
  1751. data2["stmt_loc"] = "2"
  1752. data2["upld_btch"] = upld_btch
  1753. client2 := &http.Client{}
  1754. bytesData2, _ := json.Marshal(data2)
  1755. var req3263 *http.Request
  1756. if miConfig.MdtrtareaAdmvs == "320921" {
  1757. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1758. } else {
  1759. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1760. }
  1761. resp2, _ := client2.Do(req3263)
  1762. defer resp2.Body.Close()
  1763. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1764. if ioErr2 != nil {
  1765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1767. }
  1768. var respJSON3263 map[string]interface{}
  1769. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1772. }
  1773. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1774. fmt.Println(respJSON3263)
  1775. result2, _ := json.Marshal(respJSON3263)
  1776. fmt.Println(result2)
  1777. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1778. utils.ErrorLog("解析失败:%v", err)
  1779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1780. }
  1781. var ids []string
  1782. for _, item := range result3263.Output {
  1783. ids = append(ids, item.SolidifyID)
  1784. }
  1785. data := make(map[string]interface{})
  1786. data["org_name"] = miConfig.OrgName
  1787. data["doctor"] = curRoles.UserName
  1788. data["doctor_name"] = curRoles.UserName
  1789. data["fixmedins_code"] = miConfig.Code
  1790. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1791. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1792. data["secret_key"] = miConfig.SecretKey
  1793. data["url"] = miConfig.Url
  1794. data["ak"] = miConfig.AccessKey
  1795. data["cainfo"] = miConfig.Cainfo
  1796. data["setl_mon"] = setl_mon
  1797. data["solidify_id"] = ids
  1798. month := time.Unix(1557042972, 0).Format("1")
  1799. year := time.Now().Format("2006")
  1800. month = time.Now().Format("01")
  1801. day := time.Now().Format("02")
  1802. hour := time.Now().Format("15")
  1803. min := time.Now().Format("04")
  1804. sec := time.Now().Format("05")
  1805. fix_fill_date := year + month + day + hour + min + sec
  1806. data["fix_fill_dept"] = miConfig.OrgName
  1807. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1808. data["fix_fill_psn"] = curRoles.UserName
  1809. data["fix_fill_date"] = fix_fill_date
  1810. data["stmt_loc"] = "2"
  1811. data["upld_btch"] = upld_btch
  1812. client := &http.Client{}
  1813. bytesData, _ := json.Marshal(data)
  1814. var req *http.Request
  1815. if miConfig.MdtrtareaAdmvs == "320921" {
  1816. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1817. } else {
  1818. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1819. }
  1820. resp, _ := client.Do(req)
  1821. defer resp.Body.Close()
  1822. body, ioErr := ioutil.ReadAll(resp.Body)
  1823. if ioErr != nil {
  1824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1826. }
  1827. var respJSON map[string]interface{}
  1828. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1831. }
  1832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1833. fmt.Println(respJSON)
  1834. result, _ := json.Marshal(respJSON)
  1835. fmt.Println(result)
  1836. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1837. utils.ErrorLog("解析失败:%v", err)
  1838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1839. }
  1840. if result3265.Infcode != "0" {
  1841. c.ServeSuccessJSON(map[string]interface{}{
  1842. "failed_code": -10,
  1843. "msg": result3265.ErrMsg,
  1844. })
  1845. return
  1846. } else {
  1847. c.ServeSuccessJSON(map[string]interface{}{
  1848. "info": result3265.Output,
  1849. })
  1850. return
  1851. }
  1852. }
  1853. func (c *HisApiController) Get3266() {
  1854. admin_user_id, _ := c.GetInt64("admin_user_id")
  1855. startTime := c.GetString("start_time")
  1856. //endTime, _ := c.GetString("end_time")
  1857. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1858. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1859. times := strings.Split(startTime, "-")
  1860. stmt_mon := times[0] + times[1]
  1861. var upld_btch string
  1862. //var empty models.JSResultEmpty
  1863. var result3265 models.JSResult3264
  1864. data := make(map[string]interface{})
  1865. data["org_name"] = miConfig.OrgName
  1866. data["doctor"] = curRoles.UserName
  1867. data["doctor_name"] = curRoles.UserName
  1868. data["fixmedins_code"] = miConfig.Code
  1869. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1870. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1871. data["secret_key"] = miConfig.SecretKey
  1872. data["url"] = miConfig.Url
  1873. data["ak"] = miConfig.AccessKey
  1874. data["cainfo"] = miConfig.Cainfo
  1875. data["setl_mon"] = stmt_mon
  1876. month := time.Unix(1557042972, 0).Format("1")
  1877. year := time.Now().Format("2006")
  1878. month = time.Now().Format("01")
  1879. day := time.Now().Format("02")
  1880. hour := time.Now().Format("15")
  1881. min := time.Now().Format("04")
  1882. sec := time.Now().Format("05")
  1883. fix_fill_date := year + month + day + hour + min + sec
  1884. data["fix_fill_dept"] = miConfig.OrgName
  1885. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1886. data["fix_fill_psn"] = curRoles.UserName
  1887. data["fix_fill_date"] = fix_fill_date
  1888. data["stmt_loc"] = "2"
  1889. upld_btch = "0"
  1890. data["upld_btch"] = upld_btch
  1891. client := &http.Client{}
  1892. bytesData, _ := json.Marshal(data)
  1893. var req *http.Request
  1894. if miConfig.MdtrtareaAdmvs == "320921" {
  1895. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1896. } else {
  1897. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1898. }
  1899. resp, _ := client.Do(req)
  1900. defer resp.Body.Close()
  1901. body, ioErr := ioutil.ReadAll(resp.Body)
  1902. if ioErr != nil {
  1903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1905. }
  1906. var respJSON map[string]interface{}
  1907. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1910. }
  1911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1912. fmt.Println(respJSON)
  1913. result, _ := json.Marshal(respJSON)
  1914. fmt.Println(result)
  1915. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1916. utils.ErrorLog("解析失败:%v", err)
  1917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1918. }
  1919. if result3265.Infcode != "0" {
  1920. c.ServeSuccessJSON(map[string]interface{}{
  1921. "failed_code": -10,
  1922. "msg": result3265.ErrMsg,
  1923. })
  1924. return
  1925. } else {
  1926. c.ServeSuccessJSON(map[string]interface{}{
  1927. "info": result3265.Output,
  1928. })
  1929. return
  1930. }
  1931. }
  1932. func (c *HisApiController) Get3267() {
  1933. admin_user_id, _ := c.GetInt64("admin_user_id")
  1934. startTime := c.GetString("start_time")
  1935. //endTime, _ := c.GetString("end_time")
  1936. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1937. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1938. times := strings.Split(startTime, "-")
  1939. setl_mon := times[0] + times[1]
  1940. var upld_btch string
  1941. //var empty models.JSResultEmpty
  1942. var result3265 models.JSResult3264
  1943. upld_btch = "0"
  1944. data := make(map[string]interface{})
  1945. data["org_name"] = miConfig.OrgName
  1946. data["doctor"] = curRoles.UserName
  1947. data["doctor_name"] = curRoles.UserName
  1948. data["fixmedins_code"] = miConfig.Code
  1949. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1950. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1951. data["secret_key"] = miConfig.SecretKey
  1952. data["url"] = miConfig.Url
  1953. data["ak"] = miConfig.AccessKey
  1954. data["cainfo"] = miConfig.Cainfo
  1955. data["setl_mon"] = setl_mon
  1956. data["stmt_loc"] = "2"
  1957. data["upld_btch"] = upld_btch
  1958. client := &http.Client{}
  1959. bytesData, _ := json.Marshal(data)
  1960. var req *http.Request
  1961. if miConfig.MdtrtareaAdmvs == "320921" {
  1962. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1963. } else {
  1964. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1965. }
  1966. resp, _ := client.Do(req)
  1967. defer resp.Body.Close()
  1968. body, ioErr := ioutil.ReadAll(resp.Body)
  1969. if ioErr != nil {
  1970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1972. }
  1973. var respJSON map[string]interface{}
  1974. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1977. }
  1978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1979. fmt.Println(respJSON)
  1980. result, _ := json.Marshal(respJSON)
  1981. fmt.Println(result)
  1982. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1983. utils.ErrorLog("解析失败:%v", err)
  1984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1985. }
  1986. if result3265.Infcode != "0" {
  1987. c.ServeSuccessJSON(map[string]interface{}{
  1988. "failed_code": -10,
  1989. "msg": result3265.ErrMsg,
  1990. })
  1991. return
  1992. } else {
  1993. c.ServeSuccessJSON(map[string]interface{}{
  1994. "info": result3265.Output.Data,
  1995. })
  1996. return
  1997. }
  1998. }
  1999. func (c *HisApiController) Get3268() {
  2000. admin_user_id, _ := c.GetInt64("admin_user_id")
  2001. startTime := c.GetString("start_time")
  2002. endTime := c.GetString("end_time")
  2003. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2004. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2005. times := strings.Split(startTime, "-")
  2006. setl_mon := times[0] + times[1]
  2007. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  2008. var twos []models.FixMonRecDetailFileInTwo
  2009. var funs []models.FundDetail
  2010. for _, item := range datas {
  2011. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  2012. funs = append(funs, fun...)
  2013. }
  2014. var funInfos []models.Fund
  2015. //for _, item := range funs {
  2016. // var rf []models.FundInfo
  2017. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  2018. // for _, subitem := range rf {
  2019. // var fund models.Fund
  2020. // fund.FundCode = subitem.FundPayType
  2021. // fund.FundName = subitem.FundPayTypeName
  2022. // fund.FundAmt = subitem.FundPayAmt
  2023. // fund.FundKey = item.FundKey
  2024. // fund.InsuAdmdvs = "555555"
  2025. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  2026. // funInfos = append(funInfos, fund)
  2027. // }
  2028. //}
  2029. for _, team := range datas {
  2030. var two models.FixMonRecDetailFileInTwo
  2031. two.SetlDate = time.Now().Format("2006-01-02")
  2032. two.MedType = team.MedType
  2033. two.Insutype = team.Insutype
  2034. two.PsnType = team.PsnType
  2035. two.MedType = team.MedType
  2036. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  2037. two.InsuAdmdvs = team.InsuAdmdvs
  2038. two.PsnTime = team.PsnTime
  2039. two.PsnCnt = team.PsnCnt
  2040. two.FundKey = team.FundKey
  2041. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  2042. fps, _ := strconv.ParseFloat(team.Fund, 64)
  2043. ia, _ := strconv.ParseFloat(team.Amt, 64)
  2044. two.MedfeeSumAmt = ms
  2045. two.InscpAmt = ia
  2046. two.FundPaySumAmt = fps
  2047. twos = append(twos, two)
  2048. }
  2049. var upld_btch string
  2050. upld_btch = "0"
  2051. var empty models.JSResultEmpty
  2052. data := make(map[string]interface{})
  2053. data["org_name"] = miConfig.OrgName
  2054. data["doctor"] = curRoles.UserName
  2055. data["doctor_name"] = curRoles.UserName
  2056. data["fixmedins_code"] = miConfig.Code
  2057. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2058. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2059. data["secret_key"] = miConfig.SecretKey
  2060. data["url"] = miConfig.Url
  2061. data["ak"] = miConfig.AccessKey
  2062. data["cainfo"] = miConfig.Cainfo
  2063. data["datas"] = twos
  2064. data["fund"] = funInfos
  2065. data["setl_mon"] = setl_mon
  2066. month := time.Unix(1557042972, 0).Format("1")
  2067. year := time.Now().Format("2006")
  2068. month = time.Now().Format("01")
  2069. day := time.Now().Format("02")
  2070. hour := time.Now().Format("15")
  2071. min := time.Now().Format("04")
  2072. sec := time.Now().Format("05")
  2073. fix_fill_date := year + month + day + hour + min + sec
  2074. data["fix_fill_dept"] = miConfig.OrgName
  2075. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2076. data["fix_fill_psn"] = curRoles.UserName
  2077. data["fix_fill_date"] = fix_fill_date
  2078. data["stmt_loc"] = "2"
  2079. data["upld_btch"] = upld_btch
  2080. client := &http.Client{}
  2081. bytesData, _ := json.Marshal(data)
  2082. var req *http.Request
  2083. if miConfig.MdtrtareaAdmvs == "320921" {
  2084. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2085. } else {
  2086. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2087. }
  2088. resp, _ := client.Do(req)
  2089. defer resp.Body.Close()
  2090. body, ioErr := ioutil.ReadAll(resp.Body)
  2091. if ioErr != nil {
  2092. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2094. }
  2095. var respJSON map[string]interface{}
  2096. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2099. }
  2100. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2101. fmt.Println(respJSON)
  2102. result, _ := json.Marshal(respJSON)
  2103. fmt.Println(result)
  2104. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  2105. utils.ErrorLog("解析失败:%v", err)
  2106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2107. }
  2108. if empty.Infcode != "0" {
  2109. c.ServeSuccessJSON(map[string]interface{}{
  2110. "failed_code": -10,
  2111. "msg": empty.ErrMsg,
  2112. })
  2113. return
  2114. } else {
  2115. c.ServeSuccessJSON(map[string]interface{}{
  2116. "msg": "上传成功",
  2117. })
  2118. return
  2119. }
  2120. }
  2121. func (c *HisApiController) Get3269() {
  2122. admin_user_id, _ := c.GetInt64("admin_user_id")
  2123. startTime := c.GetString("start_time")
  2124. //endTime, _ := c.GetString("end_time")
  2125. times := strings.Split(startTime, "-")
  2126. setl_mon := times[0] + times[1]
  2127. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2128. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2129. var result3263 models.JSResult3263
  2130. data := make(map[string]interface{})
  2131. data["org_name"] = miConfig.OrgName
  2132. data["doctor"] = curRoles.UserName
  2133. data["doctor_name"] = curRoles.UserName
  2134. data["fixmedins_code"] = miConfig.Code
  2135. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2136. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2137. data["secret_key"] = miConfig.SecretKey
  2138. data["url"] = miConfig.Url
  2139. data["ak"] = miConfig.AccessKey
  2140. data["cainfo"] = miConfig.Cainfo
  2141. data["setl_mon"] = setl_mon
  2142. data["stmt_loc"] = "2"
  2143. client := &http.Client{}
  2144. bytesData, _ := json.Marshal(data)
  2145. var req *http.Request
  2146. if miConfig.MdtrtareaAdmvs == "320921" {
  2147. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  2148. } else {
  2149. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  2150. }
  2151. resp, _ := client.Do(req)
  2152. defer resp.Body.Close()
  2153. body, ioErr := ioutil.ReadAll(resp.Body)
  2154. if ioErr != nil {
  2155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2157. }
  2158. var respJSON map[string]interface{}
  2159. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2162. }
  2163. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2164. fmt.Println(respJSON)
  2165. result, _ := json.Marshal(respJSON)
  2166. fmt.Println(result)
  2167. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2168. utils.ErrorLog("解析失败:%v", err)
  2169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2170. }
  2171. if result3263.Infcode != "0" {
  2172. c.ServeSuccessJSON(map[string]interface{}{
  2173. "failed_code": -10,
  2174. "msg": result3263.ErrMsg,
  2175. })
  2176. return
  2177. } else {
  2178. c.ServeSuccessJSON(map[string]interface{}{
  2179. "msg": "上传成功",
  2180. })
  2181. return
  2182. }
  2183. }
  2184. func (c *HisApiController) Get3270() {
  2185. admin_user_id, _ := c.GetInt64("admin_user_id")
  2186. startTime := c.GetString("start_time")
  2187. //endTime, _ := c.GetString("end_time")
  2188. times := strings.Split(startTime, "-")
  2189. setl_mon := times[0] + times[1]
  2190. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2191. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2192. var result3263 models.JSResult3263
  2193. data2 := make(map[string]interface{})
  2194. data2["org_name"] = miConfig.OrgName
  2195. data2["doctor"] = curRoles.UserName
  2196. data2["doctor_name"] = curRoles.UserName
  2197. data2["fixmedins_code"] = miConfig.Code
  2198. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2199. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2200. data2["secret_key"] = miConfig.SecretKey
  2201. data2["url"] = miConfig.Url
  2202. data2["ak"] = miConfig.AccessKey
  2203. data2["cainfo"] = miConfig.Cainfo
  2204. data2["setl_mon"] = setl_mon
  2205. data2["stmt_loc"] = "2"
  2206. client2 := &http.Client{}
  2207. bytesData2, _ := json.Marshal(data2)
  2208. var req3263 *http.Request
  2209. if miConfig.MdtrtareaAdmvs == "320921" {
  2210. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2211. } else {
  2212. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2213. }
  2214. resp2, _ := client2.Do(req3263)
  2215. defer resp2.Body.Close()
  2216. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2217. if ioErr2 != nil {
  2218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2220. }
  2221. var respJSON3263 map[string]interface{}
  2222. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2225. }
  2226. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2227. fmt.Println(respJSON3263)
  2228. result2, _ := json.Marshal(respJSON3263)
  2229. fmt.Println(result2)
  2230. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2231. utils.ErrorLog("解析失败:%v", err)
  2232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2233. }
  2234. var ids []string
  2235. for _, item := range result3263.Output {
  2236. ids = append(ids, item.SolidifyID)
  2237. }
  2238. var result3264 models.JSResult3264
  2239. data := make(map[string]interface{})
  2240. data["org_name"] = miConfig.OrgName
  2241. data["doctor"] = curRoles.UserName
  2242. data["doctor_name"] = curRoles.UserName
  2243. data["fixmedins_code"] = miConfig.Code
  2244. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2245. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2246. data["secret_key"] = miConfig.SecretKey
  2247. data["url"] = miConfig.Url
  2248. data["ak"] = miConfig.AccessKey
  2249. data["cainfo"] = miConfig.Cainfo
  2250. data["setl_mon"] = setl_mon
  2251. data["stmt_loc"] = "2"
  2252. data["solidify_id"] = ids
  2253. client := &http.Client{}
  2254. bytesData, _ := json.Marshal(data)
  2255. var req *http.Request
  2256. if miConfig.MdtrtareaAdmvs == "320921" {
  2257. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2258. } else {
  2259. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2260. }
  2261. resp, _ := client.Do(req)
  2262. defer resp.Body.Close()
  2263. body, ioErr := ioutil.ReadAll(resp.Body)
  2264. if ioErr != nil {
  2265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2267. }
  2268. var respJSON map[string]interface{}
  2269. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2272. }
  2273. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2274. fmt.Println(respJSON)
  2275. result, _ := json.Marshal(respJSON)
  2276. fmt.Println(result)
  2277. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  2278. utils.ErrorLog("解析失败:%v", err)
  2279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2280. }
  2281. if result3264.Infcode != "0" {
  2282. c.ServeSuccessJSON(map[string]interface{}{
  2283. "failed_code": -10,
  2284. "msg": result3264.ErrMsg,
  2285. })
  2286. return
  2287. } else {
  2288. c.ServeSuccessJSON(map[string]interface{}{
  2289. "info": result3264.Output,
  2290. })
  2291. return
  2292. }
  2293. }
  2294. func (c *HisApiController) Get3271() {
  2295. admin_user_id, _ := c.GetInt64("admin_user_id")
  2296. startTime := c.GetString("start_time")
  2297. //endTime, _ := c.GetString("end_time")
  2298. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2299. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2300. times := strings.Split(startTime, "-")
  2301. setl_mon := times[0] + times[1]
  2302. //var empty models.JSResultEmpty
  2303. var result3265 models.JSResult3264
  2304. var result3263 models.JSResult3263
  2305. data2 := make(map[string]interface{})
  2306. data2["org_name"] = miConfig.OrgName
  2307. data2["doctor"] = curRoles.UserName
  2308. data2["doctor_name"] = curRoles.UserName
  2309. data2["fixmedins_code"] = miConfig.Code
  2310. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2311. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2312. data2["secret_key"] = miConfig.SecretKey
  2313. data2["url"] = miConfig.Url
  2314. data2["ak"] = miConfig.AccessKey
  2315. data2["cainfo"] = miConfig.Cainfo
  2316. data2["setl_mon"] = setl_mon
  2317. data2["stmt_loc"] = "2"
  2318. client2 := &http.Client{}
  2319. bytesData2, _ := json.Marshal(data2)
  2320. var req3263 *http.Request
  2321. if miConfig.MdtrtareaAdmvs == "320921" {
  2322. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2323. } else {
  2324. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2325. }
  2326. resp2, _ := client2.Do(req3263)
  2327. defer resp2.Body.Close()
  2328. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2329. if ioErr2 != nil {
  2330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2332. }
  2333. var respJSON3263 map[string]interface{}
  2334. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2337. }
  2338. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2339. fmt.Println(respJSON3263)
  2340. result2, _ := json.Marshal(respJSON3263)
  2341. fmt.Println(result2)
  2342. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2343. utils.ErrorLog("解析失败:%v", err)
  2344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2345. }
  2346. var ids []string
  2347. for _, item := range result3263.Output {
  2348. ids = append(ids, item.SolidifyID)
  2349. }
  2350. data := make(map[string]interface{})
  2351. data["org_name"] = miConfig.OrgName
  2352. data["doctor"] = curRoles.UserName
  2353. data["doctor_name"] = curRoles.UserName
  2354. data["fixmedins_code"] = miConfig.Code
  2355. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2356. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2357. data["secret_key"] = miConfig.SecretKey
  2358. data["url"] = miConfig.Url
  2359. data["ak"] = miConfig.AccessKey
  2360. data["cainfo"] = miConfig.Cainfo
  2361. data["setl_mon"] = setl_mon
  2362. data["solidify_id"] = ids
  2363. month := time.Unix(1557042972, 0).Format("1")
  2364. year := time.Now().Format("2006")
  2365. month = time.Now().Format("01")
  2366. day := time.Now().Format("02")
  2367. hour := time.Now().Format("15")
  2368. min := time.Now().Format("04")
  2369. sec := time.Now().Format("05")
  2370. fix_fill_date := year + month + day + hour + min + sec
  2371. data["fix_fill_dept"] = miConfig.OrgName
  2372. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2373. data["fix_fill_psn"] = curRoles.UserName
  2374. data["fix_fill_date"] = fix_fill_date
  2375. data["stmt_loc"] = "2"
  2376. client := &http.Client{}
  2377. bytesData, _ := json.Marshal(data)
  2378. var req *http.Request
  2379. if miConfig.MdtrtareaAdmvs == "320921" {
  2380. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2381. } else {
  2382. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2383. }
  2384. resp, _ := client.Do(req)
  2385. defer resp.Body.Close()
  2386. body, ioErr := ioutil.ReadAll(resp.Body)
  2387. if ioErr != nil {
  2388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2390. }
  2391. var respJSON map[string]interface{}
  2392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2395. }
  2396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2397. fmt.Println(respJSON)
  2398. result, _ := json.Marshal(respJSON)
  2399. fmt.Println(result)
  2400. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2401. utils.ErrorLog("解析失败:%v", err)
  2402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2403. }
  2404. if result3265.Infcode != "0" {
  2405. c.ServeSuccessJSON(map[string]interface{}{
  2406. "failed_code": -10,
  2407. "msg": result3265.ErrMsg,
  2408. })
  2409. return
  2410. } else {
  2411. c.ServeSuccessJSON(map[string]interface{}{
  2412. "info": result3265.Output.Data,
  2413. })
  2414. return
  2415. }
  2416. }
  2417. func (c *HisApiController) Get3272() {
  2418. admin_user_id, _ := c.GetInt64("admin_user_id")
  2419. startTime := c.GetString("start_time")
  2420. //endTime, _ := c.GetString("end_time")
  2421. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2422. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2423. times := strings.Split(startTime, "-")
  2424. setl_mon := times[0] + times[1]
  2425. var upld_btch string
  2426. //var empty models.JSResultEmpty
  2427. var result3265 models.JSResult3264
  2428. data := make(map[string]interface{})
  2429. data["org_name"] = miConfig.OrgName
  2430. data["doctor"] = curRoles.UserName
  2431. data["doctor_name"] = curRoles.UserName
  2432. data["fixmedins_code"] = miConfig.Code
  2433. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2434. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2435. data["secret_key"] = miConfig.SecretKey
  2436. data["url"] = miConfig.Url
  2437. data["ak"] = miConfig.AccessKey
  2438. data["cainfo"] = miConfig.Cainfo
  2439. data["setl_mon"] = setl_mon
  2440. month := time.Unix(1557042972, 0).Format("1")
  2441. year := time.Now().Format("2006")
  2442. month = time.Now().Format("01")
  2443. day := time.Now().Format("02")
  2444. hour := time.Now().Format("15")
  2445. min := time.Now().Format("04")
  2446. sec := time.Now().Format("05")
  2447. fix_fill_date := year + month + day + hour + min + sec
  2448. data["fix_fill_dept"] = miConfig.OrgName
  2449. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2450. data["fix_fill_psn"] = curRoles.UserName
  2451. data["fix_fill_date"] = fix_fill_date
  2452. data["stmt_loc"] = "2"
  2453. data["upld_btch"] = upld_btch
  2454. client := &http.Client{}
  2455. bytesData, _ := json.Marshal(data)
  2456. var req *http.Request
  2457. if miConfig.MdtrtareaAdmvs == "320921" {
  2458. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2459. } else {
  2460. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2461. }
  2462. resp, _ := client.Do(req)
  2463. defer resp.Body.Close()
  2464. body, ioErr := ioutil.ReadAll(resp.Body)
  2465. if ioErr != nil {
  2466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2468. }
  2469. var respJSON map[string]interface{}
  2470. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2473. }
  2474. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2475. fmt.Println(respJSON)
  2476. result, _ := json.Marshal(respJSON)
  2477. fmt.Println(result)
  2478. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2479. utils.ErrorLog("解析失败:%v", err)
  2480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2481. }
  2482. if result3265.Infcode != "0" {
  2483. c.ServeSuccessJSON(map[string]interface{}{
  2484. "failed_code": -10,
  2485. "msg": result3265.ErrMsg,
  2486. })
  2487. return
  2488. } else {
  2489. c.ServeSuccessJSON(map[string]interface{}{
  2490. "info": result3265.Output,
  2491. })
  2492. return
  2493. }
  2494. }
  2495. func (c *HisApiController) Get3273() {
  2496. admin_user_id, _ := c.GetInt64("admin_user_id")
  2497. startTime := c.GetString("start_time")
  2498. //endTime, _ := c.GetString("end_time")
  2499. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2500. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2501. times := strings.Split(startTime, "-")
  2502. setl_mon := times[0] + times[1]
  2503. var result3265 models.JSResult3264
  2504. data := make(map[string]interface{})
  2505. data["org_name"] = miConfig.OrgName
  2506. data["doctor"] = curRoles.UserName
  2507. data["doctor_name"] = curRoles.UserName
  2508. data["fixmedins_code"] = miConfig.Code
  2509. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2510. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2511. data["secret_key"] = miConfig.SecretKey
  2512. data["url"] = miConfig.Url
  2513. data["ak"] = miConfig.AccessKey
  2514. data["cainfo"] = miConfig.Cainfo
  2515. data["setl_mon"] = setl_mon
  2516. data["stmt_loc"] = "2"
  2517. client := &http.Client{}
  2518. bytesData, _ := json.Marshal(data)
  2519. var req *http.Request
  2520. if miConfig.MdtrtareaAdmvs == "320921" {
  2521. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2522. } else {
  2523. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2524. }
  2525. resp, _ := client.Do(req)
  2526. defer resp.Body.Close()
  2527. body, ioErr := ioutil.ReadAll(resp.Body)
  2528. if ioErr != nil {
  2529. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2531. }
  2532. var respJSON map[string]interface{}
  2533. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2536. }
  2537. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2538. fmt.Println(respJSON)
  2539. result, _ := json.Marshal(respJSON)
  2540. fmt.Println(result)
  2541. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2542. utils.ErrorLog("解析失败:%v", err)
  2543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2544. }
  2545. if result3265.Infcode != "0" {
  2546. c.ServeSuccessJSON(map[string]interface{}{
  2547. "failed_code": -10,
  2548. "msg": result3265.ErrMsg,
  2549. })
  2550. return
  2551. } else {
  2552. c.ServeSuccessJSON(map[string]interface{}{
  2553. "info": result3265.Output.Data,
  2554. })
  2555. return
  2556. }
  2557. }
  2558. func (c *HisApiController) Get3274() {
  2559. //if miConfig.MdtrtareaAdmvs == "320921" {
  2560. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2561. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2562. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  2563. //
  2564. //} else {
  2565. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2566. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2567. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  2568. //
  2569. //}
  2570. }
  2571. func (c *HisApiController) Get3275() {
  2572. //if miConfig.MdtrtareaAdmvs == "320921" {
  2573. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2574. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2575. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  2576. //
  2577. //} else {
  2578. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2579. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2580. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  2581. //
  2582. //}
  2583. }
  2584. func (c *HisApiController) Get3276() {
  2585. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2586. //month := c.GetString("month")
  2587. //
  2588. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2589. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2590. //var api string
  2591. //var res Result5301
  2592. //
  2593. //if miConfig.MdtrtareaAdmvs == "320921" {
  2594. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2595. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2596. //} else {
  2597. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2598. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2599. //}
  2600. //
  2601. //resp, requestErr := http.Get(api)
  2602. //if requestErr != nil {
  2603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2604. // return
  2605. //}
  2606. //
  2607. //body, ioErr := ioutil.ReadAll(resp.Body)
  2608. //if ioErr != nil {
  2609. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2611. // return
  2612. //}
  2613. //var respJSON map[string]interface{}
  2614. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2615. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2617. // return
  2618. //}
  2619. //
  2620. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2621. //result, _ := json.Marshal(respJSON)
  2622. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2623. // utils.ErrorLog("解析失败:%v", err)
  2624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2625. // return
  2626. //}
  2627. }
  2628. func (c *HisApiController) Get3277() {
  2629. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2630. //month := c.GetString("month")
  2631. //
  2632. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2633. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2634. //var api string
  2635. //var res Result5301
  2636. //
  2637. //if miConfig.MdtrtareaAdmvs == "320921" {
  2638. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2639. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2640. //} else {
  2641. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2642. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2643. //}
  2644. //
  2645. //resp, requestErr := http.Get(api)
  2646. //if requestErr != nil {
  2647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2648. // return
  2649. //}
  2650. //
  2651. //body, ioErr := ioutil.ReadAll(resp.Body)
  2652. //if ioErr != nil {
  2653. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2655. // return
  2656. //}
  2657. //var respJSON map[string]interface{}
  2658. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2659. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2661. // return
  2662. //}
  2663. //
  2664. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2665. //result, _ := json.Marshal(respJSON)
  2666. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2667. // utils.ErrorLog("解析失败:%v", err)
  2668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2669. // return
  2670. //}
  2671. }
  2672. func (c *HisApiController) GetCFYLJG001() {
  2673. admin_user_id, _ := c.GetInt64("admin_user_id")
  2674. patient_id, _ := c.GetInt64("patient_id")
  2675. his_patient_id, _ := c.GetInt64("his_patient_id")
  2676. record_time := c.GetString("record_time")
  2677. admin_user_id = 3626
  2678. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2679. psn, _ := service.GetPsnByPatientId(patient_id)
  2680. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2681. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2682. var cFYLJG001 models.CFYLJG001
  2683. timeLayout := "2006-01-02"
  2684. loc, _ := time.LoadLocation("Local")
  2685. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2686. if err != nil {
  2687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2688. return
  2689. }
  2690. recordDateTime := theTime.Unix()
  2691. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2692. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2693. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2694. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2695. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2696. for _, item := range prescriptions {
  2697. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2698. if his.IdCardType == 1 {
  2699. bas := strings.Split(psn.CardInfo, "|")
  2700. basNumber := bas[1]
  2701. fmt.Println(basNumber)
  2702. card_sn := bas[3]
  2703. card_no := bas[2]
  2704. cFYLJG001.MdtrtCertType = "03"
  2705. cFYLJG001.CardSn = card_sn
  2706. cFYLJG001.MdtrtCertNo = card_no
  2707. cFYLJG001.EcToken = ""
  2708. cFYLJG001.AuthNo = ""
  2709. } else if his.IdCardType == 2 {
  2710. cFYLJG001.MdtrtCertType = "02"
  2711. cFYLJG001.CardSn = ""
  2712. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2713. cFYLJG001.EcToken = ""
  2714. cFYLJG001.AuthNo = ""
  2715. } else if his.IdCardType == 4 {
  2716. cFYLJG001.MdtrtCertType = "01"
  2717. cFYLJG001.CardSn = ""
  2718. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2719. cFYLJG001.EcToken = psn.VerifyNumber
  2720. cFYLJG001.AuthNo = ""
  2721. }
  2722. cFYLJG001.BizTypeCode = "01"
  2723. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2724. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2725. cFYLJG001.RxTypeCode = "1"
  2726. tempTime := time.Unix(item.PreTime, 0)
  2727. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2728. cFYLJG001.PrscTime = timeFormatOne
  2729. var count float64
  2730. if item.Type == 1 {
  2731. for _, sumItem := range item.HisDoctorAdviceInfo {
  2732. count = count + sumItem.PrescribingNumber
  2733. }
  2734. }
  2735. cFYLJG001.RxDrugCnt = count
  2736. cFYLJG001.ValiDays = "5"
  2737. ts := time.Unix(item.PreTime, 0)
  2738. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2739. tempTime3 := time.Unix(record_time2, 0)
  2740. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2741. cFYLJG001.ValiEndTime = timeFormat3
  2742. cFYLJG001.RxCotnFlag = "0"
  2743. for _, subItem := range item.HisDoctorAdviceInfo {
  2744. var drug models.RxDrug
  2745. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2746. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2747. drug.RxItemTypeCode = "11"
  2748. drug.DrugDosform = "乳膏剂" //TODO
  2749. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2750. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2751. }
  2752. drug.MedcWayDscr = subItem.DeliveryWay
  2753. tempTime2 := time.Unix(subItem.StartTime, 0)
  2754. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2755. drug.MedcBegntime = timeFormatTwo
  2756. if subItem.Day > 0 {
  2757. ts := time.Unix(subItem.StartTime, 0)
  2758. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2759. tempTime4 := time.Unix(record_time, 0)
  2760. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2761. drug.MedcEndtime = timeFormat5
  2762. } else {
  2763. tempTime2 := time.Unix(subItem.StartTime, 0)
  2764. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2765. drug.MedcEndtime = timeFormatTwo
  2766. }
  2767. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2768. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2769. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2770. drug.DrugCnt = subItem.PrescribingNumber
  2771. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2772. drug.DrugGenname = subItem.AdviceName
  2773. drug.MedcWayCodg = subItem.DeliveryWay
  2774. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2775. drug.SinDoscnt = subItem.SingleDose
  2776. drug.SinDosunt = subItem.SingleDoseUnit
  2777. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2778. drug.UsedFrquName = subItem.ExecutionFrequency
  2779. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2780. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2781. drug.HospApprFlag = "1"
  2782. cFYLJG001.List = append(cFYLJG001.List, drug)
  2783. }
  2784. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2785. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2786. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2787. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2788. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2789. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2790. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2791. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2792. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2793. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2794. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2795. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2796. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2797. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2798. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2799. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2800. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2801. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2802. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2803. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2804. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2805. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2806. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2807. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2808. tempTime2 := time.Now().Unix()
  2809. tempTime6 := time.Unix(tempTime2, 0)
  2810. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2811. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2812. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2813. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2814. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2815. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2816. //memo := make(map[string]interface{})
  2817. //inputData := make(map[string]interface{}, 0)
  2818. //type MyData struct {
  2819. // Insutype string `json:"insutype"`
  2820. //}
  2821. //
  2822. // data := MyData{
  2823. // Insutype: his.Insutype,
  2824. //}
  2825. //
  2826. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2827. var config []*models.HisXtDiagnoseConfig
  2828. for _, item := range diagnosis_ids {
  2829. id, _ := strconv.ParseInt(item, 10, 64)
  2830. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2831. config = append(config, &diagnosisConfig)
  2832. }
  2833. for index, subitem := range config {
  2834. if index == 0 {
  2835. var dia models.DiseInfo
  2836. dia.DiagType = "1"
  2837. dia.MaindiagFlag = "1"
  2838. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2839. dia.DiagCode = subitem.CountryCode
  2840. dia.DiagName = subitem.ClassName
  2841. dia.DiagDept = "肾内科"
  2842. dia.DiagDrNo = doctor.DoctorNumber
  2843. dia.DiagDrName = doctor.UserName
  2844. tempTime3 := time.Unix(item.PreTime, 0)
  2845. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2846. dia.DiagTime = timeFormatTwo
  2847. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2848. } else {
  2849. var dia models.DiseInfo
  2850. dia.DiagType = "1"
  2851. dia.MaindiagFlag = "0"
  2852. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2853. dia.DiagCode = subitem.CountryCode
  2854. dia.DiagName = subitem.ClassName
  2855. dia.DiagDept = "肾内科"
  2856. dia.DiagDrNo = doctor.DoctorNumber
  2857. dia.DiagDrName = doctor.UserName
  2858. tempTime3 := time.Unix(item.PreTime, 0)
  2859. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2860. dia.DiagTime = timeFormatTwo
  2861. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2862. }
  2863. }
  2864. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2865. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2866. var res ResultCFYLJG001
  2867. var respJSON2 map[string]interface{}
  2868. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2871. return
  2872. }
  2873. userJSONBytes2, _ := json.Marshal(respJSON2)
  2874. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2875. utils.ErrorLog("解析失败:%v", err)
  2876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2877. return
  2878. }
  2879. if res.Infcode == -1 {
  2880. c.ServeSuccessJSON(map[string]interface{}{
  2881. "failed_code": -10,
  2882. "msg": res.ErrMsg,
  2883. })
  2884. return
  2885. } else {
  2886. var flow models.HisPrescriptionFlow
  2887. flow.Ctime = time.Now().Unix()
  2888. flow.SignDigest = ""
  2889. flow.RxTraceCode = res.Output.RxTraceCode
  2890. flow.HiRxno = res.Output.HiRxno
  2891. flow.MID = his.Number
  2892. flow.Status = 1
  2893. flow.DCode = doctor_info.DoctorNumber
  2894. flow.OriginalRxFile = ""
  2895. flow.OriginalValue = ""
  2896. flow.SignCertDn = ""
  2897. flow.UserOrgId = 10454
  2898. flow.SignCertSn = ""
  2899. flow.Mtime = time.Now().Unix()
  2900. service.Createflow(&flow)
  2901. c.ServeSuccessJSON(map[string]interface{}{
  2902. "msg": "上传成功",
  2903. })
  2904. }
  2905. }
  2906. }
  2907. func (c *HisApiController) GetCFYLJG002() {
  2908. admin_user_id, _ := c.GetInt64("admin_user_id")
  2909. his_patient_id, _ := c.GetInt64("his_patient_id")
  2910. record_time := c.GetString("record_time")
  2911. admin_user_id = 3626
  2912. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2913. //id, _ := c.GetInt64("id")
  2914. admin_user_id = 3626
  2915. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2916. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2917. flow, _ := service.Getflowtwo(his.Number)
  2918. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2919. //record_time := c.GetString("record_time")
  2920. patient_id, _ := c.GetInt64("patient_id")
  2921. //patient_id = 23834
  2922. //record_time = "2023-09-18"
  2923. timeLayout := "2006-01-02"
  2924. loc, _ := time.LoadLocation("Local")
  2925. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2926. if err != nil {
  2927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2928. return
  2929. }
  2930. recordDateTime := theTime.Unix()
  2931. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2932. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2933. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2934. dept, _ := service.GetDepartMentDetail(info.Departments)
  2935. inputData := make(map[string]interface{})
  2936. inputData["rxTraceCode"] = flow.RxTraceCode
  2937. inputData["hiRxno"] = flow.HiRxno
  2938. inputData["mdtrtId"] = flow.MID
  2939. inputData["patnName"] = his.PsnName
  2940. inputData["psnCertType"] = his.PsnCertType
  2941. inputData["certno"] = his.Certno
  2942. inputData["fixmedinsName"] = miConfig.OrgName
  2943. inputData["fixmedinsCode"] = miConfig.Code
  2944. inputData["drCode"] = doctor_info.DoctorNumber
  2945. inputData["prscDrName"] = doctor_info.UserName
  2946. inputData["pharDeptName"] = dept.Name
  2947. inputData["pharDeptCode"] = dept.Number
  2948. inputData["pharProfttlCodg"] = dept.Name
  2949. inputData["pharProfttlName"] = ""
  2950. inputData["pharCode"] = "HY440309002107"
  2951. inputData["pharCertType"] = "01"
  2952. inputData["pharCertno"] = "430482199408260023"
  2953. inputData["pharName"] = "彭斯遥"
  2954. inputData["pharPracCertNo"] = ""
  2955. tempTime2 := time.Unix(info.Ctime, 0)
  2956. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2957. inputData["pharChkTime"] = timeFormatTwo
  2958. bytesData, _ := json.Marshal(inputData)
  2959. fmt.Println(string(bytesData))
  2960. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2961. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2962. if err != nil {
  2963. fmt.Println("Error reading PDF file:", err)
  2964. return
  2965. }
  2966. // 将 PDF 文件内容进行 Base64 编码
  2967. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2968. fmt.Println(err)
  2969. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2970. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2971. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2972. var res2 Result002
  2973. var respJSON2 map[string]interface{}
  2974. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2977. return
  2978. }
  2979. userJSONBytes2, _ := json.Marshal(respJSON2)
  2980. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2981. utils.ErrorLog("解析失败:%v", err)
  2982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2983. return
  2984. }
  2985. if res2.Infcode == 0 {
  2986. flow.Ctime = time.Now().Unix()
  2987. flow.SignDigest = res2.Output.SignDigest
  2988. flow.RxFile = res2.Output.RxFile
  2989. flow.MID = his.Number
  2990. flow.Status = 1
  2991. flow.DCode = doctor_info.DoctorNumber
  2992. flow.OriginalRxFile = rx_encoded
  2993. flow.OriginalValue = encoded
  2994. flow.SignCertDn = res2.Output.SignCertDn
  2995. flow.SignCertSn = res2.Output.SignCertSn
  2996. flow.Mtime = time.Now().Unix()
  2997. service.Saveflow(flow)
  2998. c.ServeSuccessJSON(map[string]interface{}{
  2999. "msg": "预签名成功",
  3000. })
  3001. } else {
  3002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3003. return
  3004. }
  3005. }
  3006. func (c *HisApiController) GetCFYLJG003() {
  3007. admin_user_id, _ := c.GetInt64("admin_user_id")
  3008. his_patient_id, _ := c.GetInt64("his_patient_id")
  3009. record_time := c.GetString("record_time")
  3010. admin_user_id = 3626
  3011. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3012. //id, _ := c.GetInt64("id")
  3013. admin_user_id = 3626
  3014. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3015. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3016. flow, _ := service.Getflowtwo(his.Number)
  3017. //id = 3
  3018. patient_id, _ := c.GetInt64("patient_id")
  3019. //patient_id = 23834
  3020. //record_time = "2023-09-18"
  3021. timeLayout := "2006-01-02"
  3022. loc, _ := time.LoadLocation("Local")
  3023. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3024. if err != nil {
  3025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3026. return
  3027. }
  3028. recordDateTime := theTime.Unix()
  3029. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3030. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3031. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3032. dept, _ := service.GetDepartMentDetail(info.Departments)
  3033. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  3034. var cFYLJG003 models.CFYLJG003
  3035. cFYLJG003.RxTraceCode = flow.RxTraceCode
  3036. cFYLJG003.HiRxno = flow.HiRxno
  3037. cFYLJG003.MdtrtID = flow.MID
  3038. cFYLJG003.PatnName = his.Name
  3039. cFYLJG003.Certno = his.Certno
  3040. cFYLJG003.FixmedinsName = miConfig.OrgName
  3041. cFYLJG003.FixmedinsCode = miConfig.Code
  3042. cFYLJG003.DrCode = doctor_info.DoctorNumber
  3043. cFYLJG003.PrscDrName = doctor_info.UserName
  3044. cFYLJG003.PharDeptName = dept.Name
  3045. cFYLJG003.PharDeptCode = dept.Number
  3046. cFYLJG003.PharCode = "HY440309002107"
  3047. cFYLJG003.PharCertType = "01"
  3048. cFYLJG003.PharCertno = "430482199408260023"
  3049. cFYLJG003.PharName = "彭斯遥"
  3050. cFYLJG003.PsnCertType = "01"
  3051. cFYLJG003.RxFile = flow.RxFile
  3052. cFYLJG003.SignDigest = flow.SignDigest
  3053. cFYLJG003.FixmedinsCode = miConfig.Code
  3054. cFYLJG003.PsnCertType = "01"
  3055. cFYLJG003.PharProfttlCodg = dept.Name
  3056. //inputData["pharProfttlCodg"] =dept.Name
  3057. tempTime2 := time.Unix(info.Ctime, 0)
  3058. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3059. cFYLJG003.PharChkTime = timeFormatTwo
  3060. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  3061. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  3062. var res ResultCFYLJG003
  3063. var respJSON2 map[string]interface{}
  3064. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3067. return
  3068. }
  3069. userJSONBytes2, _ := json.Marshal(respJSON2)
  3070. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3071. utils.ErrorLog("解析失败:%v", err)
  3072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3073. return
  3074. }
  3075. if res.Infcode == -1 {
  3076. c.ServeSuccessJSON(map[string]interface{}{
  3077. "failed_code": -10,
  3078. "msg": res.ErrMsg,
  3079. })
  3080. return
  3081. } else {
  3082. c.ServeSuccessJSON(map[string]interface{}{
  3083. "info": res.Output,
  3084. })
  3085. }
  3086. }
  3087. func (c *HisApiController) GetCFYLJG004() {
  3088. admin_user_id, _ := c.GetInt64("admin_user_id")
  3089. his_patient_id, _ := c.GetInt64("his_patient_id")
  3090. record_time := c.GetString("record_time")
  3091. admin_user_id = 3626
  3092. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3093. //id, _ := c.GetInt64("id")
  3094. admin_user_id = 3626
  3095. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3096. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3097. flow, _ := service.Getflowtwo(his.Number)
  3098. //id = 3
  3099. patient_id, _ := c.GetInt64("patient_id")
  3100. //patient_id = 23834
  3101. //record_time = "2023-09-18"
  3102. timeLayout := "2006-01-02"
  3103. loc, _ := time.LoadLocation("Local")
  3104. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3105. if err != nil {
  3106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3107. return
  3108. }
  3109. recordDateTime := theTime.Unix()
  3110. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3111. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3112. var cFYLJG004 models.CFYLJG004
  3113. cFYLJG004.HiRxno = flow.HiRxno
  3114. cFYLJG004.FixmedinsCode = miConfig.Code
  3115. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  3116. cFYLJG004.UndoDrCertType = "01"
  3117. cFYLJG004.UndoRea = "撤销处方"
  3118. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  3119. cFYLJG004.UndoDrName = doctor_info.UserName
  3120. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  3121. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  3122. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  3123. var res ResultCFYLJG004
  3124. var respJSON2 map[string]interface{}
  3125. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3128. return
  3129. }
  3130. userJSONBytes2, _ := json.Marshal(respJSON2)
  3131. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3132. utils.ErrorLog("解析失败:%v", err)
  3133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3134. return
  3135. }
  3136. if res.Infcode == -1 {
  3137. c.ServeSuccessJSON(map[string]interface{}{
  3138. "failed_code": -10,
  3139. "msg": res.ErrMsg,
  3140. })
  3141. return
  3142. } else {
  3143. flow.Status = 0
  3144. service.Saveflow(flow)
  3145. c.ServeSuccessJSON(map[string]interface{}{
  3146. "msg": "撤销成功",
  3147. })
  3148. return
  3149. }
  3150. }
  3151. func (c *HisApiController) GetCFYLJG005() {
  3152. admin_user_id, _ := c.GetInt64("admin_user_id")
  3153. his_patient_id, _ := c.GetInt64("his_patient_id")
  3154. //record_time := c.GetString("record_time")
  3155. admin_user_id = 3626
  3156. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3157. //id, _ := c.GetInt64("id")
  3158. admin_user_id = 3626
  3159. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3160. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3161. flow, _ := service.Getflowtwo(his.Number)
  3162. //id = 3
  3163. var cFYLJG005 models.CFYLJG005
  3164. //patient_id, _ := c.GetInt64("patient_id")
  3165. cFYLJG005.HiRxno = flow.HiRxno
  3166. cFYLJG005.MdtrtID = flow.MID
  3167. cFYLJG005.EcToken = ""
  3168. cFYLJG005.PsnName = his.Name
  3169. cFYLJG005.PsnCertType = "01"
  3170. cFYLJG005.Certno = his.IdCardNo
  3171. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  3172. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  3173. var res ResultCFYLJG005
  3174. var respJSON2 map[string]interface{}
  3175. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3178. return
  3179. }
  3180. userJSONBytes2, _ := json.Marshal(respJSON2)
  3181. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3182. utils.ErrorLog("解析失败:%v", err)
  3183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3184. return
  3185. }
  3186. if res.Infcode == -1 {
  3187. c.ServeSuccessJSON(map[string]interface{}{
  3188. "failed_code": -10,
  3189. "msg": res.ErrMsg,
  3190. })
  3191. return
  3192. } else {
  3193. c.ServeSuccessJSON(map[string]interface{}{
  3194. "info": res.Output,
  3195. })
  3196. return
  3197. }
  3198. }
  3199. func (c *HisApiController) GetCFYLJG006() {
  3200. admin_user_id, _ := c.GetInt64("admin_user_id")
  3201. his_patient_id, _ := c.GetInt64("his_patient_id")
  3202. admin_user_id = 3626
  3203. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3204. //id, _ := c.GetInt64("id")
  3205. admin_user_id = 3626
  3206. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3207. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3208. flow, _ := service.Getflowtwo(his.Number)
  3209. //id = 3
  3210. patient_id, _ := c.GetInt64("patient_id")
  3211. var cFYLJG006 models.CFYLJG006
  3212. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3213. cFYLJG006.HiRxno = flow.HiRxno
  3214. cFYLJG006.MdtrtID = flow.MID
  3215. cFYLJG006.PsnName = patient.Name
  3216. cFYLJG006.PsnCertType = "01"
  3217. cFYLJG006.Certno = patient.IdCardNo
  3218. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  3219. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  3220. var res ResultCFYLJG006
  3221. var respJSON2 map[string]interface{}
  3222. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3225. return
  3226. }
  3227. userJSONBytes2, _ := json.Marshal(respJSON2)
  3228. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3229. utils.ErrorLog("解析失败:%v", err)
  3230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3231. return
  3232. }
  3233. if res.Infcode == -1 {
  3234. c.ServeSuccessJSON(map[string]interface{}{
  3235. "failed_code": -10,
  3236. "msg": res.ErrMsg,
  3237. })
  3238. return
  3239. } else {
  3240. c.ServeSuccessJSON(map[string]interface{}{
  3241. "info": res.Output,
  3242. })
  3243. return
  3244. }
  3245. }
  3246. func (c *HisApiController) GetCFYLJG007() {
  3247. admin_user_id, _ := c.GetInt64("admin_user_id")
  3248. his_patient_id, _ := c.GetInt64("his_patient_id")
  3249. admin_user_id = 3626
  3250. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3251. //id, _ := c.GetInt64("id")
  3252. admin_user_id = 3626
  3253. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3254. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3255. flow, _ := service.Getflowtwo(his.Number)
  3256. //id = 3
  3257. patient_id, _ := c.GetInt64("patient_id")
  3258. var cFYLJG007 models.CFYLJG007
  3259. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3260. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3261. cFYLJG007.HiRxno = flow.HiRxno
  3262. cFYLJG007.MdtrtID = flow.MID
  3263. cFYLJG007.PsnNo = his.PsnNo
  3264. cFYLJG007.PsnCertType = "01"
  3265. cFYLJG007.Certno = patient.IdCardNo
  3266. cFYLJG007.PsnName = patient.Name
  3267. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  3268. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  3269. var res ResultCFYLJG007
  3270. var respJSON2 map[string]interface{}
  3271. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3274. return
  3275. }
  3276. userJSONBytes2, _ := json.Marshal(respJSON2)
  3277. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3278. utils.ErrorLog("解析失败:%v", err)
  3279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3280. return
  3281. }
  3282. if res.Infcode == -1 {
  3283. c.ServeSuccessJSON(map[string]interface{}{
  3284. "failed_code": -10,
  3285. "msg": res.ErrMsg,
  3286. })
  3287. return
  3288. } else {
  3289. c.ServeSuccessJSON(map[string]interface{}{
  3290. "info": res,
  3291. })
  3292. return
  3293. }
  3294. }
  3295. func (c *HisApiController) GetCFYLJG008() {
  3296. admin_user_id, _ := c.GetInt64("admin_user_id")
  3297. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3298. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3299. var cFYLJG008 models.CFYLJG008
  3300. //id, _ := c.GetInt64("id")
  3301. patient_id, _ := c.GetInt64("patient_id")
  3302. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3303. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3304. //id = 3
  3305. //flow, _ := service.Getflow(id)
  3306. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3307. //
  3308. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3309. //patient_id, _ := c.GetInt64("patient_id")
  3310. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3311. record_time := c.GetString("record_time")
  3312. admin_user_id = 3626
  3313. patient_id = 19424
  3314. //his_patient_id = 263947
  3315. record_time = "2023-08-29"
  3316. timeLayout := "2006-01-02"
  3317. loc, _ := time.LoadLocation("Local")
  3318. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3319. if err != nil {
  3320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3321. return
  3322. }
  3323. recordDateTime := theTime.Unix()
  3324. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3325. cFYLJG008.FixmedinsName = ""
  3326. cFYLJG008.Lat = ""
  3327. cFYLJG008.Lng = ""
  3328. cFYLJG008.OrderType = "1"
  3329. cFYLJG008.PoolareaNo = ""
  3330. cFYLJG008.Lng = ""
  3331. cFYLJG008.PageNum = 1
  3332. cFYLJG008.PageSize = 10
  3333. var MPI models.MedinsProdInvChgDDTO
  3334. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  3335. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  3336. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  3337. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  3338. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  3339. var res ResultCFYLJG008
  3340. var respJSON2 map[string]interface{}
  3341. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3344. return
  3345. }
  3346. userJSONBytes2, _ := json.Marshal(respJSON2)
  3347. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3348. utils.ErrorLog("解析失败:%v", err)
  3349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3350. return
  3351. }
  3352. if res.Infcode == -1 {
  3353. c.ServeSuccessJSON(map[string]interface{}{
  3354. "failed_code": -10,
  3355. "msg": res.ErrMsg,
  3356. })
  3357. return
  3358. } else {
  3359. c.ServeSuccessJSON(map[string]interface{}{
  3360. "info": res.Output,
  3361. })
  3362. return
  3363. }
  3364. }
  3365. func (c *HisApiController) GetBL4201A() {
  3366. order_id, _ := c.GetInt64("order_id")
  3367. admin_user_id, _ := c.GetInt64("admin_user_id")
  3368. order, _ := service.GetHisOrderByIDTwo(order_id)
  3369. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3370. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3371. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3372. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3373. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3374. department, _ := service.GetDepartMentDetail(his.Departments)
  3375. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3376. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3377. if order.ID == 0 {
  3378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3379. return
  3380. }
  3381. var struct4201A models.Struct4201A
  3382. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3383. for _, items := range order_info {
  3384. memo := make(map[string]interface{})
  3385. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3386. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3387. fsiOPFLD.MedType = "14"
  3388. fsiOPFLD.BkkpSn = items.FeedetlSn
  3389. fsiOPFLD.FixmedinsCode = miConfig.Code
  3390. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3391. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3392. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3393. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3394. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3395. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3396. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3397. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3398. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3399. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3400. fsiOPFLD.BilgDeptName = department.Name
  3401. fsiOPFLD.BilgDeptCodg = department.Number
  3402. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3403. fsiOPFLD.BilgDrName = doctor.UserName
  3404. fsiOPFLD.MedChrgitmType = "09"
  3405. memo["hosp_appr_flag"] = "1"
  3406. memo["invoice_no"] = order.MdtrtId
  3407. memo["memo"] = "自费"
  3408. bytesData, _ := json.Marshal(memo)
  3409. fsiOPFLD.Memo = string(bytesData)
  3410. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3411. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3412. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3413. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3414. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3415. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3416. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3417. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3418. fsiOPFLD.BilgDeptName = department.Name
  3419. fsiOPFLD.BilgDeptCodg = department.Number
  3420. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3421. fsiOPFLD.BilgDrName = doctor.UserName
  3422. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3423. case 0:
  3424. break
  3425. case 1:
  3426. fsiOPFLD.MedChrgitmType = "14"
  3427. break
  3428. case 2:
  3429. fsiOPFLD.MedChrgitmType = "05"
  3430. break
  3431. case 3:
  3432. fsiOPFLD.MedChrgitmType = "03"
  3433. break
  3434. case 4:
  3435. fsiOPFLD.MedChrgitmType = "03"
  3436. break
  3437. case 5:
  3438. fsiOPFLD.MedChrgitmType = "08"
  3439. break
  3440. case 6:
  3441. fsiOPFLD.MedChrgitmType = "14"
  3442. break
  3443. case 7:
  3444. fsiOPFLD.MedChrgitmType = "14"
  3445. break
  3446. case 8:
  3447. fsiOPFLD.MedChrgitmType = "03"
  3448. break
  3449. case 9:
  3450. fsiOPFLD.MedChrgitmType = "14"
  3451. break
  3452. case 10:
  3453. fsiOPFLD.MedChrgitmType = "14"
  3454. break
  3455. case 11:
  3456. fsiOPFLD.MedChrgitmType = "06"
  3457. break
  3458. case 12:
  3459. fsiOPFLD.MedChrgitmType = "12"
  3460. break
  3461. case 13:
  3462. fsiOPFLD.MedChrgitmType = "01"
  3463. break
  3464. case 14:
  3465. fsiOPFLD.MedChrgitmType = "04"
  3466. break
  3467. case 15:
  3468. fsiOPFLD.MedChrgitmType = "14"
  3469. break
  3470. }
  3471. memo["hosp_appr_flag"] = "1"
  3472. memo["invoice_no"] = order.MdtrtId
  3473. memo["memo"] = "自费"
  3474. bytesData, _ := json.Marshal(memo)
  3475. fsiOPFLD.Memo = string(bytesData)
  3476. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3477. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3478. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3479. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3480. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3481. fsiOPFLD.BilgDeptName = department.Name
  3482. fsiOPFLD.BilgDeptCodg = department.Number
  3483. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3484. fsiOPFLD.BilgDrName = doctor.UserName
  3485. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3486. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3487. fsiOPFLD.MedChrgitmType = "08"
  3488. memo["hosp_appr_flag"] = "1"
  3489. memo["invoice_no"] = order.MdtrtId
  3490. memo["memo"] = "自费"
  3491. bytesData, _ := json.Marshal(memo)
  3492. fsiOPFLD.Memo = string(bytesData)
  3493. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3494. }
  3495. }
  3496. }
  3497. for _, items := range order_info_two {
  3498. memo := make(map[string]interface{})
  3499. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3500. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3501. fsiOPFLD.MedType = "14"
  3502. fsiOPFLD.BkkpSn = items.FeedetlSn
  3503. fsiOPFLD.FixmedinsCode = miConfig.Code
  3504. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3505. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3506. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3507. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3508. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3509. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3510. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3511. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3512. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3513. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3514. fsiOPFLD.BilgDeptName = department.Name
  3515. fsiOPFLD.BilgDeptCodg = department.Number
  3516. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3517. fsiOPFLD.BilgDrName = doctor.UserName
  3518. fsiOPFLD.MedChrgitmType = "09"
  3519. memo["hosp_appr_flag"] = "1"
  3520. memo["invoice_no"] = order.MdtrtId
  3521. memo["memo"] = "自费"
  3522. bytesData, _ := json.Marshal(memo)
  3523. fsiOPFLD.Memo = string(bytesData)
  3524. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3525. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3526. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3527. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3528. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3529. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3530. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3531. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3532. fsiOPFLD.BilgDeptName = department.Name
  3533. fsiOPFLD.BilgDeptCodg = department.Number
  3534. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3535. fsiOPFLD.BilgDrName = doctor.UserName
  3536. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3537. case 0:
  3538. break
  3539. case 1:
  3540. fsiOPFLD.MedChrgitmType = "14"
  3541. break
  3542. case 2:
  3543. fsiOPFLD.MedChrgitmType = "05"
  3544. break
  3545. case 3:
  3546. fsiOPFLD.MedChrgitmType = "03"
  3547. break
  3548. case 4:
  3549. fsiOPFLD.MedChrgitmType = "03"
  3550. break
  3551. case 5:
  3552. fsiOPFLD.MedChrgitmType = "08"
  3553. break
  3554. case 6:
  3555. fsiOPFLD.MedChrgitmType = "14"
  3556. break
  3557. case 7:
  3558. fsiOPFLD.MedChrgitmType = "14"
  3559. break
  3560. case 8:
  3561. fsiOPFLD.MedChrgitmType = "03"
  3562. break
  3563. case 9:
  3564. fsiOPFLD.MedChrgitmType = "14"
  3565. break
  3566. case 10:
  3567. fsiOPFLD.MedChrgitmType = "14"
  3568. break
  3569. case 11:
  3570. fsiOPFLD.MedChrgitmType = "06"
  3571. break
  3572. case 12:
  3573. fsiOPFLD.MedChrgitmType = "12"
  3574. break
  3575. case 13:
  3576. fsiOPFLD.MedChrgitmType = "01"
  3577. break
  3578. case 14:
  3579. fsiOPFLD.MedChrgitmType = "04"
  3580. break
  3581. case 15:
  3582. fsiOPFLD.MedChrgitmType = "14"
  3583. break
  3584. }
  3585. memo["hosp_appr_flag"] = "1"
  3586. memo["invoice_no"] = order.MdtrtId
  3587. memo["memo"] = "自费"
  3588. bytesData, _ := json.Marshal(memo)
  3589. fsiOPFLD.Memo = string(bytesData)
  3590. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3591. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3592. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3593. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3594. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3595. fsiOPFLD.BilgDeptName = department.Name
  3596. fsiOPFLD.BilgDeptCodg = department.Number
  3597. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3598. fsiOPFLD.BilgDrName = doctor.UserName
  3599. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3600. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3601. fsiOPFLD.MedChrgitmType = "08"
  3602. memo["hosp_appr_flag"] = "1"
  3603. memo["invoice_no"] = order.MdtrtId
  3604. memo["memo"] = "自费"
  3605. bytesData, _ := json.Marshal(memo)
  3606. fsiOPFLD.Memo = string(bytesData)
  3607. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3608. }
  3609. }
  3610. }
  3611. fmt.Println(fsiOPFLDs)
  3612. struct4201A.Fopfd = fsiOPFLDs
  3613. fmt.Println(struct4201A.Fopfd)
  3614. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3615. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3616. var res2 ResultSix
  3617. var respJSON2 map[string]interface{}
  3618. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3621. return
  3622. }
  3623. userJSONBytes2, _ := json.Marshal(respJSON2)
  3624. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3625. utils.ErrorLog("解析失败:%v", err)
  3626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3627. return
  3628. }
  3629. if res2.Infcode != 0 {
  3630. c.ServeSuccessJSON(map[string]interface{}{
  3631. "failed_code": -10,
  3632. "msg": res2.ErrMsg,
  3633. })
  3634. return
  3635. } else {
  3636. order.IsUploadOrderInfo = 1
  3637. service.UpdateOrder(order)
  3638. c.ServeSuccessJSON(map[string]interface{}{
  3639. "msg": "上传成功",
  3640. })
  3641. }
  3642. }
  3643. func (c *HisApiController) Get2505() {
  3644. admin_user_id, _ := c.GetInt64("admin_user_id")
  3645. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3646. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3647. service.Gdyb2505("45000000000008100145868008", curRoles.UserName, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2024-01-12 09:00:00", "2026-12-31 23:00:00", admin_user_id)
  3648. }
  3649. func (c *HisApiController) Get4201A() {
  3650. order_id, _ := c.GetInt64("order_id")
  3651. admin_user_id, _ := c.GetInt64("admin_user_id")
  3652. order, _ := service.GetHisOrderByIDTwo(order_id)
  3653. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3654. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3655. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3656. //order_info = append(order_info, order_info_two...)
  3657. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3658. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3659. department, _ := service.GetDepartMentDetail(his.Departments)
  3660. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3661. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3662. if order.ID == 0 {
  3663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3664. return
  3665. }
  3666. var struct4201A models.Struct4201A
  3667. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3668. for _, items := range order_info {
  3669. memo := make(map[string]interface{})
  3670. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3671. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3672. fsiOPFLD.MedType = "14"
  3673. fsiOPFLD.BkkpSn = items.FeedetlSn
  3674. fsiOPFLD.FixmedinsCode = miConfig.Code
  3675. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3676. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3677. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3678. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3679. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3680. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3681. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3682. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3683. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3684. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3685. fsiOPFLD.BilgDeptName = department.Name
  3686. fsiOPFLD.BilgDeptCodg = department.Number
  3687. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3688. fsiOPFLD.BilgDrName = doctor.UserName
  3689. fsiOPFLD.MedChrgitmType = "09"
  3690. memo["hosp_appr_flag"] = "1"
  3691. memo["invoice_no"] = order.MdtrtId
  3692. memo["memo"] = "自费"
  3693. bytesData, _ := json.Marshal(memo)
  3694. fsiOPFLD.Memo = string(bytesData)
  3695. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3696. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3697. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3698. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3699. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3700. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3701. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3702. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3703. fsiOPFLD.BilgDeptName = department.Name
  3704. fsiOPFLD.BilgDeptCodg = department.Number
  3705. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3706. fsiOPFLD.BilgDrName = doctor.UserName
  3707. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3708. case 0:
  3709. break
  3710. case 1:
  3711. fsiOPFLD.MedChrgitmType = "14"
  3712. break
  3713. case 2:
  3714. fsiOPFLD.MedChrgitmType = "05"
  3715. break
  3716. case 3:
  3717. fsiOPFLD.MedChrgitmType = "03"
  3718. break
  3719. case 4:
  3720. fsiOPFLD.MedChrgitmType = "03"
  3721. break
  3722. case 5:
  3723. fsiOPFLD.MedChrgitmType = "08"
  3724. break
  3725. case 6:
  3726. fsiOPFLD.MedChrgitmType = "14"
  3727. break
  3728. case 7:
  3729. fsiOPFLD.MedChrgitmType = "14"
  3730. break
  3731. case 8:
  3732. fsiOPFLD.MedChrgitmType = "03"
  3733. break
  3734. case 9:
  3735. fsiOPFLD.MedChrgitmType = "14"
  3736. break
  3737. case 10:
  3738. fsiOPFLD.MedChrgitmType = "14"
  3739. break
  3740. case 11:
  3741. fsiOPFLD.MedChrgitmType = "06"
  3742. break
  3743. case 12:
  3744. fsiOPFLD.MedChrgitmType = "12"
  3745. break
  3746. case 13:
  3747. fsiOPFLD.MedChrgitmType = "01"
  3748. break
  3749. case 14:
  3750. fsiOPFLD.MedChrgitmType = "04"
  3751. break
  3752. case 15:
  3753. fsiOPFLD.MedChrgitmType = "14"
  3754. break
  3755. }
  3756. memo["hosp_appr_flag"] = "1"
  3757. memo["invoice_no"] = order.MdtrtId
  3758. memo["memo"] = "自费"
  3759. bytesData, _ := json.Marshal(memo)
  3760. fsiOPFLD.Memo = string(bytesData)
  3761. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3762. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3763. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3764. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3765. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3766. fsiOPFLD.BilgDeptName = department.Name
  3767. fsiOPFLD.BilgDeptCodg = department.Number
  3768. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3769. fsiOPFLD.BilgDrName = doctor.UserName
  3770. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3771. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3772. fsiOPFLD.MedChrgitmType = "08"
  3773. memo["hosp_appr_flag"] = "1"
  3774. memo["invoice_no"] = order.MdtrtId
  3775. memo["memo"] = "自费"
  3776. bytesData, _ := json.Marshal(memo)
  3777. fsiOPFLD.Memo = string(bytesData)
  3778. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3779. }
  3780. }
  3781. }
  3782. for _, items := range order_info_two {
  3783. memo := make(map[string]interface{})
  3784. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3785. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3786. fsiOPFLD.MedType = "14"
  3787. fsiOPFLD.BkkpSn = items.FeedetlSn
  3788. fsiOPFLD.FixmedinsCode = miConfig.Code
  3789. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3790. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3791. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3792. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3793. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3794. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3795. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3796. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3797. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3798. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3799. fsiOPFLD.BilgDeptName = department.Name
  3800. fsiOPFLD.BilgDeptCodg = department.Number
  3801. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3802. fsiOPFLD.BilgDrName = doctor.UserName
  3803. fsiOPFLD.MedChrgitmType = "09"
  3804. memo["hosp_appr_flag"] = "1"
  3805. memo["invoice_no"] = order.MdtrtId
  3806. memo["memo"] = "自费"
  3807. bytesData, _ := json.Marshal(memo)
  3808. fsiOPFLD.Memo = string(bytesData)
  3809. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3810. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3811. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3812. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3813. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3814. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3815. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3816. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3817. fsiOPFLD.BilgDeptName = department.Name
  3818. fsiOPFLD.BilgDeptCodg = department.Number
  3819. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3820. fsiOPFLD.BilgDrName = doctor.UserName
  3821. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3822. case 0:
  3823. break
  3824. case 1:
  3825. fsiOPFLD.MedChrgitmType = "14"
  3826. break
  3827. case 2:
  3828. fsiOPFLD.MedChrgitmType = "05"
  3829. break
  3830. case 3:
  3831. fsiOPFLD.MedChrgitmType = "03"
  3832. break
  3833. case 4:
  3834. fsiOPFLD.MedChrgitmType = "03"
  3835. break
  3836. case 5:
  3837. fsiOPFLD.MedChrgitmType = "08"
  3838. break
  3839. case 6:
  3840. fsiOPFLD.MedChrgitmType = "14"
  3841. break
  3842. case 7:
  3843. fsiOPFLD.MedChrgitmType = "14"
  3844. break
  3845. case 8:
  3846. fsiOPFLD.MedChrgitmType = "03"
  3847. break
  3848. case 9:
  3849. fsiOPFLD.MedChrgitmType = "14"
  3850. break
  3851. case 10:
  3852. fsiOPFLD.MedChrgitmType = "14"
  3853. break
  3854. case 11:
  3855. fsiOPFLD.MedChrgitmType = "06"
  3856. break
  3857. case 12:
  3858. fsiOPFLD.MedChrgitmType = "12"
  3859. break
  3860. case 13:
  3861. fsiOPFLD.MedChrgitmType = "01"
  3862. break
  3863. case 14:
  3864. fsiOPFLD.MedChrgitmType = "04"
  3865. break
  3866. case 15:
  3867. fsiOPFLD.MedChrgitmType = "14"
  3868. break
  3869. }
  3870. memo["hosp_appr_flag"] = "1"
  3871. memo["invoice_no"] = order.MdtrtId
  3872. memo["memo"] = "自费"
  3873. bytesData, _ := json.Marshal(memo)
  3874. fsiOPFLD.Memo = string(bytesData)
  3875. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3876. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3877. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3878. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3879. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3880. fsiOPFLD.BilgDeptName = department.Name
  3881. fsiOPFLD.BilgDeptCodg = department.Number
  3882. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3883. fsiOPFLD.BilgDrName = doctor.UserName
  3884. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3885. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3886. fsiOPFLD.MedChrgitmType = "08"
  3887. memo["hosp_appr_flag"] = "1"
  3888. memo["invoice_no"] = order.MdtrtId
  3889. memo["memo"] = "自费"
  3890. bytesData, _ := json.Marshal(memo)
  3891. fsiOPFLD.Memo = string(bytesData)
  3892. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3893. }
  3894. }
  3895. }
  3896. fmt.Println(fsiOPFLDs)
  3897. struct4201A.Fopfd = fsiOPFLDs
  3898. fmt.Println(struct4201A.Fopfd)
  3899. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3900. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3901. var res2 ResultSix
  3902. var respJSON2 map[string]interface{}
  3903. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3906. return
  3907. }
  3908. userJSONBytes2, _ := json.Marshal(respJSON2)
  3909. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3910. utils.ErrorLog("解析失败:%v", err)
  3911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3912. return
  3913. }
  3914. if res2.Infcode != 0 {
  3915. c.ServeSuccessJSON(map[string]interface{}{
  3916. "failed_code": -10,
  3917. "msg": res2.ErrMsg,
  3918. })
  3919. return
  3920. } else {
  3921. order.IsUploadOrderInfo = 1
  3922. service.UpdateOrder(order)
  3923. c.ServeSuccessJSON(map[string]interface{}{
  3924. "msg": "上传成功",
  3925. })
  3926. }
  3927. }
  3928. func (c *HisApiController) Get4202() {
  3929. order_id, _ := c.GetInt64("order_id")
  3930. admin_user_id, _ := c.GetInt64("admin_user_id")
  3931. order, _ := service.GetHisOrderByIDTwo(order_id)
  3932. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3933. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3934. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3935. if order.ID == 0 {
  3936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3937. return
  3938. }
  3939. var struct4202 models.Struct4202
  3940. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3941. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3942. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3943. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3944. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3945. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3946. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  3947. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  3948. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3949. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3950. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3951. var config []*models.HisXtDiagnoseConfig
  3952. for _, item := range diagnosis_ids {
  3953. id, _ := strconv.ParseInt(item, 10, 64)
  3954. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3955. config = append(config, &diagnosisConfig)
  3956. }
  3957. var tempDiaginfos []models.OwnPayPatnDiagListD
  3958. for index, item := range config {
  3959. if index == 0 {
  3960. var tempDiaginfo models.OwnPayPatnDiagListD
  3961. tempDiaginfo.InoutDiagType = "1"
  3962. tempDiaginfo.DiagCode = item.CountryCode
  3963. tempDiaginfo.DiagName = item.CountryContentName
  3964. tempDiaginfo.DiagType = "1"
  3965. tempDiaginfo.DiagSrtNo = "1"
  3966. tempDiaginfo.MaindiagFlag = "1"
  3967. tempDiaginfo.ValiFlag = "1"
  3968. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3969. } else {
  3970. var tempDiaginfo models.OwnPayPatnDiagListD
  3971. tempDiaginfo.DiagCode = item.CountryCode
  3972. tempDiaginfo.DiagName = item.CountryContentName
  3973. tempDiaginfo.DiagType = "2"
  3974. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3975. tempDiaginfo.MaindiagFlag = "0"
  3976. tempDiaginfo.ValiFlag = "1"
  3977. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3978. }
  3979. }
  3980. struct4202.ODiagListD = tempDiaginfos
  3981. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  3982. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  3983. var res2 ResultSix
  3984. var respJSON2 map[string]interface{}
  3985. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. return
  3989. }
  3990. userJSONBytes2, _ := json.Marshal(respJSON2)
  3991. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3992. utils.ErrorLog("解析失败:%v", err)
  3993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3994. return
  3995. }
  3996. if res2.Infcode != 0 {
  3997. c.ServeSuccessJSON(map[string]interface{}{
  3998. "failed_code": -10,
  3999. "msg": res2.ErrMsg,
  4000. })
  4001. return
  4002. } else {
  4003. order.IsUploadDiagnose = 1
  4004. service.UpdateOrder(order)
  4005. c.ServeSuccessJSON(map[string]interface{}{
  4006. "msg": "上传成功",
  4007. })
  4008. }
  4009. }
  4010. func (c *HisApiController) Get4203() {
  4011. admin_user_id, _ := c.GetInt64("admin_user_id")
  4012. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4013. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4014. order_id, _ := c.GetInt64("order_id")
  4015. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4016. number := ""
  4017. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4018. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4019. if his.ID == 0 {
  4020. number = hospital.Number
  4021. } else {
  4022. number = his.Number
  4023. }
  4024. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  4025. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  4026. var res2 ResultSix
  4027. var respJSON2 map[string]interface{}
  4028. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4031. return
  4032. }
  4033. userJSONBytes2, _ := json.Marshal(respJSON2)
  4034. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4035. utils.ErrorLog("解析失败:%v", err)
  4036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4037. return
  4038. }
  4039. if res2.Infcode != 0 {
  4040. c.ServeSuccessJSON(map[string]interface{}{
  4041. "failed_code": -10,
  4042. "msg": res2.ErrMsg,
  4043. })
  4044. return
  4045. } else {
  4046. order.IsUploadSuccess = 1
  4047. service.UpdateOrderTwo(order)
  4048. c.ServeSuccessJSON(map[string]interface{}{
  4049. "msg": "上传成功",
  4050. })
  4051. }
  4052. }
  4053. func (c *HisApiController) Get4205() {
  4054. order_id, _ := c.GetInt64("order_id")
  4055. admin_user_id, _ := c.GetInt64("admin_user_id")
  4056. fapiao_code := c.GetString("fapiao_code")
  4057. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4058. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4059. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4060. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4061. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  4062. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  4063. //order_info = append(order_info, order_info_two...)
  4064. department, _ := service.GetDepartMentDetail(his.Departments)
  4065. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4066. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4067. if order.ID == 0 {
  4068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4069. return
  4070. }
  4071. var struct4201A models.Struct4201A
  4072. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  4073. for _, items := range order_info {
  4074. memo := make(map[string]interface{})
  4075. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4076. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4077. fsiOPFLD.MedType = pre.MedType
  4078. fsiOPFLD.FixmedinsCode = miConfig.Code
  4079. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4080. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4081. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4082. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4083. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4084. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4085. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4086. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  4087. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4088. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4089. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4090. fsiOPFLD.BilgDeptName = department.Name
  4091. fsiOPFLD.BilgDeptCodg = department.Number
  4092. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4093. fsiOPFLD.BilgDrName = doctor.UserName
  4094. fsiOPFLD.MedChrgitmType = "09"
  4095. memo["hosp_appr_flag"] = "1"
  4096. memo["invoice_no"] = fapiao_code
  4097. memo["memo"] = "自费"
  4098. bytesData, _ := json.Marshal(memo)
  4099. fsiOPFLD.Memo = string(bytesData)
  4100. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4101. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4102. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4103. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4104. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4105. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4106. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4107. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4108. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4109. fsiOPFLD.BilgDeptName = department.Name
  4110. fsiOPFLD.BilgDeptCodg = department.Number
  4111. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4112. fsiOPFLD.BilgDrName = doctor.UserName
  4113. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4114. case 0:
  4115. break
  4116. case 1:
  4117. fsiOPFLD.MedChrgitmType = "14"
  4118. break
  4119. case 2:
  4120. fsiOPFLD.MedChrgitmType = "05"
  4121. break
  4122. case 3:
  4123. fsiOPFLD.MedChrgitmType = "03"
  4124. break
  4125. case 4:
  4126. fsiOPFLD.MedChrgitmType = "03"
  4127. break
  4128. case 5:
  4129. fsiOPFLD.MedChrgitmType = "08"
  4130. break
  4131. case 6:
  4132. fsiOPFLD.MedChrgitmType = "14"
  4133. break
  4134. case 7:
  4135. fsiOPFLD.MedChrgitmType = "14"
  4136. break
  4137. case 8:
  4138. fsiOPFLD.MedChrgitmType = "03"
  4139. break
  4140. case 9:
  4141. fsiOPFLD.MedChrgitmType = "14"
  4142. break
  4143. case 10:
  4144. fsiOPFLD.MedChrgitmType = "14"
  4145. break
  4146. case 11:
  4147. fsiOPFLD.MedChrgitmType = "06"
  4148. break
  4149. case 12:
  4150. fsiOPFLD.MedChrgitmType = "12"
  4151. break
  4152. case 13:
  4153. fsiOPFLD.MedChrgitmType = "01"
  4154. break
  4155. case 14:
  4156. fsiOPFLD.MedChrgitmType = "04"
  4157. break
  4158. case 15:
  4159. fsiOPFLD.MedChrgitmType = "14"
  4160. break
  4161. }
  4162. memo["hosp_appr_flag"] = "1"
  4163. memo["invoice_no"] = fapiao_code
  4164. memo["memo"] = "自费"
  4165. bytesData, _ := json.Marshal(memo)
  4166. fsiOPFLD.Memo = string(bytesData)
  4167. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4168. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4169. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4170. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4171. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4172. fsiOPFLD.BilgDeptName = department.Name
  4173. fsiOPFLD.BilgDeptCodg = department.Number
  4174. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4175. fsiOPFLD.BilgDrName = doctor.UserName
  4176. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4177. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4178. fsiOPFLD.MedChrgitmType = "08"
  4179. memo["hosp_appr_flag"] = "1"
  4180. memo["invoice_no"] = fapiao_code
  4181. memo["memo"] = "自费"
  4182. bytesData, _ := json.Marshal(memo)
  4183. fsiOPFLD.Memo = string(bytesData)
  4184. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4185. }
  4186. }
  4187. }
  4188. for _, items := range order_info_two {
  4189. memo := make(map[string]interface{})
  4190. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4191. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4192. fsiOPFLD.MedType = pre.MedType
  4193. fsiOPFLD.BkkpSn = items.FeedetlSn
  4194. fsiOPFLD.FixmedinsCode = miConfig.Code
  4195. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4196. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4197. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4198. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4199. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4200. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4201. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4202. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4203. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4204. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4205. fsiOPFLD.BilgDeptName = department.Name
  4206. fsiOPFLD.BilgDeptCodg = department.Number
  4207. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4208. fsiOPFLD.BilgDrName = doctor.UserName
  4209. fsiOPFLD.MedChrgitmType = "09"
  4210. memo["hosp_appr_flag"] = "1"
  4211. memo["invoice_no"] = fapiao_code
  4212. memo["memo"] = "自费"
  4213. bytesData, _ := json.Marshal(memo)
  4214. fsiOPFLD.Memo = string(bytesData)
  4215. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4216. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4217. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4218. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4219. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4220. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4221. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4222. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4223. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4224. fsiOPFLD.BilgDeptName = department.Name
  4225. fsiOPFLD.BilgDeptCodg = department.Number
  4226. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4227. fsiOPFLD.BilgDrName = doctor.UserName
  4228. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4229. case 0:
  4230. break
  4231. case 1:
  4232. fsiOPFLD.MedChrgitmType = "14"
  4233. break
  4234. case 2:
  4235. fsiOPFLD.MedChrgitmType = "05"
  4236. break
  4237. case 3:
  4238. fsiOPFLD.MedChrgitmType = "03"
  4239. break
  4240. case 4:
  4241. fsiOPFLD.MedChrgitmType = "03"
  4242. break
  4243. case 5:
  4244. fsiOPFLD.MedChrgitmType = "08"
  4245. break
  4246. case 6:
  4247. fsiOPFLD.MedChrgitmType = "14"
  4248. break
  4249. case 7:
  4250. fsiOPFLD.MedChrgitmType = "14"
  4251. break
  4252. case 8:
  4253. fsiOPFLD.MedChrgitmType = "03"
  4254. break
  4255. case 9:
  4256. fsiOPFLD.MedChrgitmType = "14"
  4257. break
  4258. case 10:
  4259. fsiOPFLD.MedChrgitmType = "14"
  4260. break
  4261. case 11:
  4262. fsiOPFLD.MedChrgitmType = "06"
  4263. break
  4264. case 12:
  4265. fsiOPFLD.MedChrgitmType = "12"
  4266. break
  4267. case 13:
  4268. fsiOPFLD.MedChrgitmType = "01"
  4269. break
  4270. case 14:
  4271. fsiOPFLD.MedChrgitmType = "04"
  4272. break
  4273. case 15:
  4274. fsiOPFLD.MedChrgitmType = "14"
  4275. break
  4276. }
  4277. memo["hosp_appr_flag"] = "1"
  4278. memo["invoice_no"] = fapiao_code
  4279. memo["memo"] = "自费"
  4280. bytesData, _ := json.Marshal(memo)
  4281. fsiOPFLD.Memo = string(bytesData)
  4282. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4283. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4284. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4285. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4286. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4287. fsiOPFLD.BilgDeptName = department.Name
  4288. fsiOPFLD.BilgDeptCodg = department.Number
  4289. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4290. fsiOPFLD.BilgDrName = doctor.UserName
  4291. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4292. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4293. fsiOPFLD.MedChrgitmType = "08"
  4294. memo["hosp_appr_flag"] = "1"
  4295. memo["invoice_no"] = fapiao_code
  4296. memo["memo"] = "自费"
  4297. bytesData, _ := json.Marshal(memo)
  4298. fsiOPFLD.Memo = string(bytesData)
  4299. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4300. }
  4301. }
  4302. }
  4303. fmt.Println(fsiOPFLDs)
  4304. struct4201A.Fopfd = fsiOPFLDs
  4305. fmt.Println(struct4201A.Fopfd)
  4306. var struct4202 models.Struct4202
  4307. timeLayout := "2006-01-02 15:04:05"
  4308. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  4309. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4310. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4311. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4312. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4313. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4314. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4315. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  4316. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  4317. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4318. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4319. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4320. var config []*models.HisXtDiagnoseConfig
  4321. for _, item := range diagnosis_ids {
  4322. id, _ := strconv.ParseInt(item, 10, 64)
  4323. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4324. config = append(config, &diagnosisConfig)
  4325. }
  4326. var tempDiaginfos []models.OwnPayPatnDiagListD
  4327. for index, item := range config {
  4328. if index == 0 {
  4329. var tempDiaginfo models.OwnPayPatnDiagListD
  4330. tempDiaginfo.InoutDiagType = "1"
  4331. tempDiaginfo.DiagCode = item.CountryCode
  4332. tempDiaginfo.DiagName = item.CountryContentName
  4333. tempDiaginfo.DiagType = "1"
  4334. tempDiaginfo.DiagSrtNo = "1"
  4335. tempDiaginfo.MaindiagFlag = "1"
  4336. tempDiaginfo.ValiFlag = "1"
  4337. tempDiaginfo.DiagDrName = doctor.UserName
  4338. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4339. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4340. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4341. } else {
  4342. var tempDiaginfo models.OwnPayPatnDiagListD
  4343. tempDiaginfo.DiagCode = item.CountryCode
  4344. tempDiaginfo.DiagName = item.CountryContentName
  4345. tempDiaginfo.DiagType = "2"
  4346. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4347. tempDiaginfo.MaindiagFlag = "0"
  4348. tempDiaginfo.ValiFlag = "1"
  4349. tempDiaginfo.DiagDrName = doctor.UserName
  4350. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4351. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4352. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4353. }
  4354. }
  4355. struct4202.ODiagListD = tempDiaginfos
  4356. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  4357. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  4358. var res2 ResultSix
  4359. var respJSON2 map[string]interface{}
  4360. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4363. return
  4364. }
  4365. userJSONBytes2, _ := json.Marshal(respJSON2)
  4366. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4367. utils.ErrorLog("解析失败:%v", err)
  4368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4369. return
  4370. }
  4371. if res2.Infcode != 0 {
  4372. c.ServeSuccessJSON(map[string]interface{}{
  4373. "failed_code": -10,
  4374. "msg": res2.ErrMsg,
  4375. })
  4376. return
  4377. } else {
  4378. order.IsUploadDiagnose = 1
  4379. order.IsUploadOrderInfo = 1
  4380. service.UpdateOrderTwo(order)
  4381. c.ServeSuccessJSON(map[string]interface{}{
  4382. "msg": "上传成功",
  4383. })
  4384. }
  4385. }
  4386. func (c *HisApiController) Get4207() {
  4387. admin_user_id, _ := c.GetInt64("admin_user_id")
  4388. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4389. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4390. order_id, _ := c.GetInt64("order_id")
  4391. order, _ := service.GetHisOrderByIDTwo(order_id)
  4392. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4393. var struct4207 models.Struct4207
  4394. struct4207.PageNum = "1"
  4395. struct4207.PageSize = "1000"
  4396. struct4207.FixmedinsCode = miConfig.Code
  4397. struct4207.FixmedinsMdtrtID = order.Number
  4398. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  4399. saveLog(result, requestLog, "4207", "查询")
  4400. var res2 ResultSix
  4401. var respJSON2 map[string]interface{}
  4402. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4405. return
  4406. }
  4407. userJSONBytes2, _ := json.Marshal(respJSON2)
  4408. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4409. utils.ErrorLog("解析失败:%v", err)
  4410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4411. return
  4412. }
  4413. if res2.Infcode != 0 {
  4414. c.ServeSuccessJSON(map[string]interface{}{
  4415. "failed_code": -10,
  4416. "msg": res2.ErrMsg,
  4417. })
  4418. return
  4419. } else {
  4420. c.ServeSuccessJSON(map[string]interface{}{
  4421. "msg": "查询成功",
  4422. })
  4423. }
  4424. }
  4425. func (c *HisApiController) Get4208() {
  4426. admin_user_id, _ := c.GetInt64("admin_user_id")
  4427. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4428. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4429. order_id, _ := c.GetInt64("order_id")
  4430. order, _ := service.GetHisOrderByIDTwo(order_id)
  4431. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4432. var struct4208 models.Struct4208
  4433. struct4208.PageNum = "1"
  4434. struct4208.PageSize = "1000"
  4435. struct4208.PsnCertType = "01"
  4436. struct4208.Certno = his.Certno
  4437. struct4208.MedType = order.MedType
  4438. struct4208.PsnName = his.Name
  4439. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  4440. saveLog(result, requestLog, "4208", "查询")
  4441. var res2 ResultSix
  4442. var respJSON2 map[string]interface{}
  4443. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4446. return
  4447. }
  4448. userJSONBytes2, _ := json.Marshal(respJSON2)
  4449. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4450. utils.ErrorLog("解析失败:%v", err)
  4451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4452. return
  4453. }
  4454. if res2.Infcode != 0 {
  4455. c.ServeSuccessJSON(map[string]interface{}{
  4456. "failed_code": -10,
  4457. "msg": res2.ErrMsg,
  4458. })
  4459. return
  4460. } else {
  4461. c.ServeSuccessJSON(map[string]interface{}{
  4462. "msg": "查询成功",
  4463. })
  4464. }
  4465. }
  4466. func (c *HisApiController) Get4209() {
  4467. admin_user_id, _ := c.GetInt64("admin_user_id")
  4468. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4469. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4470. order_id, _ := c.GetInt64("order_id")
  4471. order, _ := service.GetHisOrderByIDTwo(order_id)
  4472. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4473. var struct4209 models.Struct4209
  4474. struct4209.FixmedinsMdtrtID = order.Number
  4475. struct4209.FixmedinsCode = miConfig.Code
  4476. struct4209.PageSize = "1000"
  4477. struct4209.PageNum = "1"
  4478. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  4479. saveLog(result, requestLog, "4209", "查询")
  4480. var res2 ResultSix
  4481. var respJSON2 map[string]interface{}
  4482. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4485. return
  4486. }
  4487. userJSONBytes2, _ := json.Marshal(respJSON2)
  4488. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4489. utils.ErrorLog("解析失败:%v", err)
  4490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4491. return
  4492. }
  4493. if res2.Infcode != 0 {
  4494. c.ServeSuccessJSON(map[string]interface{}{
  4495. "failed_code": -10,
  4496. "msg": res2.ErrMsg,
  4497. })
  4498. return
  4499. } else {
  4500. c.ServeSuccessJSON(map[string]interface{}{
  4501. "msg": "查询成功",
  4502. })
  4503. }
  4504. }
  4505. type Result3101 struct {
  4506. Infcode string `json:"infcode"`
  4507. InfRefmsgid string `json:"inf_refmsgid"`
  4508. RefmsgTime string `json:"refmsg_time"`
  4509. RespondTime string `json:"respond_time"`
  4510. Enctype string `json:"enctype"`
  4511. Signtype string `json:"signtype"`
  4512. ErrMsg string `json:"err_msg"`
  4513. Output struct {
  4514. Result []struct {
  4515. JudgeResultDetailDtos []struct {
  4516. VolaItemType string `json:"vola_item_type"`
  4517. MdtrtID string `json:"mdtrt_id"`
  4518. JrdID string `json:"jrd_id"`
  4519. PatnID string `json:"patn_id"`
  4520. RxID string `json:"rx_id"`
  4521. VolaAmt interface{} `json:"vola_amt"`
  4522. } `json:"judge_result_detail_dtos"`
  4523. RuleID string `json:"rule_id"`
  4524. VolaEvid string `json:"vola_evid"`
  4525. MdtrtID string `json:"mdtrt_id"`
  4526. RuleName string `json:"rule_name"`
  4527. VolaAmtStas string `json:"vola_amt_stas"`
  4528. JrID string `json:"jr_id"`
  4529. PatnID string `json:"patn_id"`
  4530. SevDeg string `json:"sev_deg"`
  4531. VolaAmt float64 `json:"vola_amt"`
  4532. VolaBhvrType string `json:"vola_bhvr_type"`
  4533. VolaCont string `json:"vola_cont"`
  4534. } `json:"result"`
  4535. } `json:"output"`
  4536. }
  4537. type Resultgd3101 struct {
  4538. Infcode int64 `json:"infcode"`
  4539. InfRefmsgid string `json:"inf_refmsgid"`
  4540. RefmsgTime string `json:"refmsg_time"`
  4541. RespondTime string `json:"respond_time"`
  4542. Enctype string `json:"enctype"`
  4543. Signtype string `json:"signtype"`
  4544. ErrMsg string `json:"err_msg"`
  4545. Output struct {
  4546. Result []struct {
  4547. JudgeResultDetailDtos []struct {
  4548. VolaItemType string `json:"vola_item_type"`
  4549. MdtrtID string `json:"mdtrt_id"`
  4550. JrdID string `json:"jrd_id"`
  4551. PatnID string `json:"patn_id"`
  4552. RxID string `json:"rx_id"`
  4553. VolaAmt interface{} `json:"vola_amt"`
  4554. } `json:"judge_result_detail_dtos"`
  4555. RuleID string `json:"rule_id"`
  4556. VolaEvid string `json:"vola_evid"`
  4557. MdtrtID string `json:"mdtrt_id"`
  4558. RuleName string `json:"rule_name"`
  4559. VolaAmtStas string `json:"vola_amt_stas"`
  4560. JrID string `json:"jr_id"`
  4561. PatnID string `json:"patn_id"`
  4562. SevDeg string `json:"sev_deg"`
  4563. VolaAmt float64 `json:"vola_amt"`
  4564. VolaBhvrType string `json:"vola_bhvr_type"`
  4565. VolaCont string `json:"vola_cont"`
  4566. } `json:"result"`
  4567. } `json:"output"`
  4568. }
  4569. func (c *HisApiController) ReadEleToken() {
  4570. admin_user_id, _ := c.GetInt64("admin_user_id")
  4571. his_patient_id, _ := c.GetInt64("his_patient_id")
  4572. adminUser := c.GetAdminUserInfo()
  4573. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4574. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4575. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4576. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4577. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4578. if len(tokens) > 0 {
  4579. c.ServeSuccessJSON(map[string]interface{}{
  4580. "msg": "读取成功",
  4581. })
  4582. } else {
  4583. c.ServeSuccessJSON(map[string]interface{}{
  4584. "failed_code": -10,
  4585. "msg": "读取失败",
  4586. })
  4587. }
  4588. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4589. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4590. if len(tokens) > 0 {
  4591. c.ServeSuccessJSON(map[string]interface{}{
  4592. "msg": "读取成功",
  4593. })
  4594. } else {
  4595. c.ServeSuccessJSON(map[string]interface{}{
  4596. "failed_code": -10,
  4597. "msg": "读取失败",
  4598. })
  4599. }
  4600. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4601. var api string
  4602. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4603. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName + "&is_settle=1"
  4604. resp, requestErr := http.Get(api)
  4605. if requestErr != nil {
  4606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4607. }
  4608. body, ioErr := ioutil.ReadAll(resp.Body)
  4609. if ioErr != nil {
  4610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4612. }
  4613. var respJSON map[string]interface{}
  4614. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4617. return
  4618. }
  4619. var status string
  4620. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4621. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4622. var token string
  4623. var res ResultTwo //1101结果
  4624. var res10265 ResultTwo10265 //1101结果
  4625. if status == "0" { //读卡成功
  4626. var card_info string //卡信息
  4627. var busi_card_info string
  4628. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4629. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4630. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4631. fmt.Println(card_info)
  4632. fmt.Println(busi_card_info)
  4633. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4634. result, _ := json.Marshal(respJSON)
  4635. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4636. utils.ErrorLog("解析失败:%v", err)
  4637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4638. return
  4639. }
  4640. res.ErrMsg = res10265.ErrMsg
  4641. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4642. res.Infcode = infocode
  4643. res.Output = res10265.Output
  4644. res.InfRefmsgid = res10265.InfRefmsgid
  4645. if res.Infcode == 0 {
  4646. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4647. if err == gorm.ErrRecordNotFound {
  4648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4649. return
  4650. } else if err != nil {
  4651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4652. return
  4653. } else {
  4654. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4655. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4656. infoStr := string(Iinfos)
  4657. idetinfoStr := string(Idetinfos)
  4658. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  4659. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  4660. psn := &models.HisPsn{
  4661. PsnNo: res.Output.Baseinfo.PsnNo,
  4662. PatientId: patient.ID,
  4663. Certno: res.Output.Baseinfo.Certno,
  4664. Gend: res.Output.Baseinfo.Gend,
  4665. Naty: res.Output.Baseinfo.Naty,
  4666. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4667. PsnName: res.Output.Baseinfo.PsnName,
  4668. Age: float64(age),
  4669. Brdy: b,
  4670. Idetinfo: idetinfoStr,
  4671. Insuinfo: infoStr,
  4672. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4673. CardInfo: card_info,
  4674. VerifyNumber: token,
  4675. IdCardType: 4,
  4676. }
  4677. var rf []*ResultFive
  4678. json.Unmarshal([]byte(infoStr), &rf)
  4679. var insutypes []*ResultFive
  4680. var insutype string
  4681. var is390 int = 0
  4682. var is310 int = 0
  4683. for _, item := range rf {
  4684. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4685. insutypes = append(insutypes, item)
  4686. }
  4687. }
  4688. if len(insutypes) == 1 {
  4689. insutype = insutypes[0].Insutype
  4690. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4691. } else {
  4692. for _, i := range insutypes {
  4693. if i.Insutype == "390" {
  4694. is390 = 1
  4695. }
  4696. if i.Insutype == "310" {
  4697. is310 = 1
  4698. }
  4699. }
  4700. }
  4701. if is390 == 1 {
  4702. insutype = "390"
  4703. }
  4704. if is310 == 1 {
  4705. insutype = "310"
  4706. }
  4707. if len(insutypes) == 0 {
  4708. insutype = "310"
  4709. }
  4710. service.CreateHisPsn(psn)
  4711. c.ServeSuccessJSON(map[string]interface{}{
  4712. "patient": patient,
  4713. "number": token,
  4714. "insutype": insutype,
  4715. })
  4716. }
  4717. } else {
  4718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4719. return
  4720. }
  4721. } else { //读卡失败
  4722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4723. return
  4724. }
  4725. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4726. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4727. if len(errMsg) == 0 {
  4728. type ELeData struct {
  4729. Data struct {
  4730. IdNo string `json:"idNo"`
  4731. IdType string `json:"idType"`
  4732. UserName string `json:"userName"`
  4733. EcToken string `json:"ecToken"`
  4734. InsuOrg string `json:"insuOrg"`
  4735. Gender string `json:"gender"`
  4736. Birthday string `json:"birthday"`
  4737. Nationality string `json:"nationality"`
  4738. Email string `json:"email"`
  4739. Extra string `json:"extra"`
  4740. } `json:"data"`
  4741. Code int `json:"code"`
  4742. Message string `json:"message"`
  4743. }
  4744. var ele ELeData
  4745. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4746. if err != nil {
  4747. utils.ErrorLog("解析失败:%v", err)
  4748. }
  4749. token := ele.Data.EcToken
  4750. if len(token) > 0 {
  4751. psn := &models.HisPsn{
  4752. PsnNo: his.PsnNo,
  4753. Age: 0,
  4754. PatientId: his.PatientId,
  4755. Certno: his.Certno,
  4756. Brdy: his.Brdy,
  4757. Gend: his.Gend,
  4758. Naty: his.Naty,
  4759. PsnCertType: his.PsnCertType,
  4760. PsnName: his.PsnName,
  4761. Idetinfo: his.Idetinfo,
  4762. Insuinfo: his.Iinfo,
  4763. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4764. CardInfo: outPutInfo,
  4765. VerifyNumber: token,
  4766. }
  4767. service.CreateHisPsn(psn)
  4768. }
  4769. if len(token) > 0 {
  4770. c.ServeSuccessJSON(map[string]interface{}{
  4771. "msg": "读取成功",
  4772. })
  4773. } else {
  4774. c.ServeSuccessJSON(map[string]interface{}{
  4775. "failed_code": -10,
  4776. "msg": "读取失败",
  4777. })
  4778. }
  4779. }
  4780. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4781. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4782. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4783. type ELeData struct {
  4784. Data struct {
  4785. IdNo string `json:"idNo"`
  4786. IdType string `json:"idType"`
  4787. UserName string `json:"userName"`
  4788. EcToken string `json:"ecToken"`
  4789. InsuOrg string `json:"insuOrg"`
  4790. Gender string `json:"gender"`
  4791. Birthday string `json:"birthday"`
  4792. Nationality string `json:"nationality"`
  4793. Email string `json:"email"`
  4794. Extra string `json:"extra"`
  4795. } `json:"data"`
  4796. Code int `json:"code"`
  4797. Message string `json:"message"`
  4798. }
  4799. var ele ELeData
  4800. err := json.Unmarshal([]byte(result), &ele)
  4801. if err != nil {
  4802. utils.ErrorLog("解析失败:%v", err)
  4803. }
  4804. token := ele.Data.EcToken
  4805. token = Remove0000(token)
  4806. fmt.Println(ele.Data.UserName)
  4807. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  4808. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4809. var res ResultTwo
  4810. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4811. utils.ErrorLog("解析失败:%v", err)
  4812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4813. return
  4814. }
  4815. if res.Infcode == 0 {
  4816. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4817. if err == gorm.ErrRecordNotFound {
  4818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4819. return
  4820. } else if err != nil {
  4821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4822. return
  4823. } else {
  4824. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4825. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4826. infoStr := string(Iinfos)
  4827. idetinfoStr := string(Idetinfos)
  4828. psn := &models.HisPsn{
  4829. PsnNo: res.Output.Baseinfo.PsnNo,
  4830. PatientId: patient.ID,
  4831. Certno: res.Output.Baseinfo.Certno,
  4832. Gend: res.Output.Baseinfo.Gend,
  4833. Naty: res.Output.Baseinfo.Naty,
  4834. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4835. PsnName: res.Output.Baseinfo.PsnName,
  4836. Idetinfo: idetinfoStr,
  4837. Insuinfo: infoStr,
  4838. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4839. CardInfo: "",
  4840. VerifyNumber: token,
  4841. }
  4842. service.CreateHisPsn(psn)
  4843. c.ServeSuccessJSON(map[string]interface{}{
  4844. "patient": patient,
  4845. "number": token,
  4846. })
  4847. }
  4848. } else {
  4849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4850. return
  4851. }
  4852. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4853. idNo := c.GetString("idNo")
  4854. userName := c.GetString("userName")
  4855. ecToken := c.GetString("ecToken")
  4856. insuOrg := c.GetString("insuOrg")
  4857. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4858. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4859. var res ResultTwo
  4860. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4861. utils.ErrorLog("解析失败:%v", err)
  4862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4863. return
  4864. }
  4865. if res.Infcode == 0 {
  4866. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4867. if err == gorm.ErrRecordNotFound {
  4868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4869. return
  4870. } else if err != nil {
  4871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4872. return
  4873. } else {
  4874. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4875. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4876. infoStr := string(Iinfos)
  4877. idetinfoStr := string(Idetinfos)
  4878. psn := &models.HisPsn{
  4879. PsnNo: res.Output.Baseinfo.PsnNo,
  4880. PatientId: patient.ID,
  4881. Certno: res.Output.Baseinfo.Certno,
  4882. Gend: res.Output.Baseinfo.Gend,
  4883. Naty: res.Output.Baseinfo.Naty,
  4884. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4885. PsnName: res.Output.Baseinfo.PsnName,
  4886. Idetinfo: idetinfoStr,
  4887. Insuinfo: infoStr,
  4888. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4889. CardInfo: "",
  4890. VerifyNumber: ecToken,
  4891. InsuplcAdmdvs: insuOrg,
  4892. }
  4893. service.CreateHisPsn(psn)
  4894. c.ServeSuccessJSON(map[string]interface{}{
  4895. "patient": patient,
  4896. "number": ecToken,
  4897. })
  4898. }
  4899. } else {
  4900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4901. return
  4902. }
  4903. } else if miConfig.MdtrtareaAdmvs == "450721" {
  4904. res := c.GetoleInfo()
  4905. if res.Infcode == 0 {
  4906. var result string
  4907. if res.Output.MdtrtCertType == "01" {
  4908. result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, 1, res.Output.PsnName, res.Output.EcToken, admin_user_id)
  4909. } else if res.Output.MdtrtCertType == "02" {
  4910. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  4911. } else if res.Output.MdtrtCertType == "03" {
  4912. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  4913. }
  4914. var dat map[string]interface{}
  4915. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4916. fmt.Println(dat)
  4917. } else {
  4918. fmt.Println(err)
  4919. }
  4920. userJSONBytes, _ := json.Marshal(dat)
  4921. var res2 ResultTwo
  4922. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4923. utils.ErrorLog("解析失败:%v", err)
  4924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4925. return
  4926. }
  4927. if res2.Infcode == 0 {
  4928. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  4929. if err == gorm.ErrRecordNotFound {
  4930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4931. return
  4932. } else if err != nil {
  4933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4934. return
  4935. } else {
  4936. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  4937. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  4938. infoStr := string(Iinfos)
  4939. idetinfoStr := string(Idetinfos)
  4940. var rf []*ResultFive
  4941. json.Unmarshal([]byte(infoStr), &rf)
  4942. var insutypes []*ResultFive
  4943. var insutype string
  4944. var is390 int = 0
  4945. var is310 int = 0
  4946. //var insuplc_admdvs string
  4947. for _, item := range rf {
  4948. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4949. insutypes = append(insutypes, item)
  4950. }
  4951. }
  4952. if len(insutypes) == 1 {
  4953. insutype = insutypes[0].Insutype
  4954. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4955. } else {
  4956. for _, i := range insutypes {
  4957. if i.Insutype == "390" {
  4958. is390 = 1
  4959. }
  4960. if i.Insutype == "310" {
  4961. is310 = 1
  4962. }
  4963. }
  4964. }
  4965. if is390 == 1 {
  4966. insutype = "390"
  4967. }
  4968. if is310 == 1 {
  4969. insutype = "310"
  4970. }
  4971. if len(insutypes) == 0 {
  4972. insutype = "310"
  4973. }
  4974. psn := &models.HisPsn{
  4975. PsnNo: res2.Output.Baseinfo.PsnNo,
  4976. PatientId: patient.ID,
  4977. Certno: res2.Output.Baseinfo.Certno,
  4978. Gend: res2.Output.Baseinfo.Gend,
  4979. Naty: res2.Output.Baseinfo.Naty,
  4980. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  4981. PsnName: res2.Output.Baseinfo.PsnName,
  4982. Idetinfo: idetinfoStr,
  4983. Insuinfo: infoStr,
  4984. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4985. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  4986. VerifyNumber: res.Output.EcToken,
  4987. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  4988. }
  4989. service.CreateHisPsn(psn)
  4990. c.ServeSuccessJSON(map[string]interface{}{
  4991. "patient": patient,
  4992. "number": res.Output.CardNo,
  4993. "insutype": insutype,
  4994. })
  4995. }
  4996. } else {
  4997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4998. return
  4999. }
  5000. } else {
  5001. c.ServeSuccessJSON(map[string]interface{}{
  5002. "failed_code": -10,
  5003. "msg": res.ErrMsg,
  5004. })
  5005. }
  5006. } else {
  5007. //if initFlag == 0 {
  5008. // c.TestGetBasBaseInit()
  5009. //}
  5010. //token := c.GetEleBaseInfo()
  5011. //token = Remove0000(token)
  5012. type ELeData struct {
  5013. Code string `json:"code"`
  5014. Data struct {
  5015. Aac002 string `json:"aac002"`
  5016. Aaz500 string `json:"aaz500"`
  5017. ActCardNo string `json:"actCardNo"`
  5018. Bab520 string `json:"bab520"`
  5019. Bkz543 string `json:"bkz543"`
  5020. BusinessType string `json:"businessType"`
  5021. CertfCodg string `json:"certfCodg"`
  5022. EcIndexNo string `json:"ecIndexNo"`
  5023. EcToken string `json:"ecToken"`
  5024. ID0000 string `json:"id0000"`
  5025. IDNo string `json:"idNo"`
  5026. IDType string `json:"idType"`
  5027. Idcode string `json:"idcode"`
  5028. IdentityToken string `json:"identity_token"`
  5029. InsuOrg string `json:"insuOrg"`
  5030. OfficeID string `json:"officeId"`
  5031. OfficeName string `json:"officeName"`
  5032. OperatorID string `json:"operatorId"`
  5033. OperatorName string `json:"operatorName"`
  5034. OrgID string `json:"orgId"`
  5035. UserName string `json:"userName"`
  5036. } `json:"data"`
  5037. Infno interface{} `json:"infno"`
  5038. Message string `json:"message"`
  5039. OrgID string `json:"orgId"`
  5040. TransType string `json:"transType"`
  5041. }
  5042. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  5043. fmt.Println(result)
  5044. outPutInfo := Remove0000(result)
  5045. fmt.Println(outPutInfo)
  5046. var ele ELeData
  5047. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5048. if err != nil {
  5049. utils.ErrorLog("解析失败:%v", err)
  5050. }
  5051. token := ele.Data.EcToken
  5052. var result2 string
  5053. var requestLog2 string
  5054. if len(token) > 0 {
  5055. if strings.Contains(ele.Data.IDNo, "HKG") {
  5056. result2, requestLog2 = service.Gdyb1101ForEleCert1111(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo, 6)
  5057. } else {
  5058. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  5059. }
  5060. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5061. var res ResultTwo
  5062. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5063. utils.ErrorLog("解析失败:%v", err)
  5064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5065. return
  5066. }
  5067. if res.Infcode == 0 {
  5068. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5069. if err == gorm.ErrRecordNotFound {
  5070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5071. return
  5072. } else if err != nil {
  5073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5074. return
  5075. } else {
  5076. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5077. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5078. infoStr := string(Iinfos)
  5079. idetinfoStr := string(Idetinfos)
  5080. psn := &models.HisPsn{
  5081. PsnNo: res.Output.Baseinfo.PsnNo,
  5082. PatientId: patient.ID,
  5083. Certno: res.Output.Baseinfo.Certno,
  5084. Gend: res.Output.Baseinfo.Gend,
  5085. Naty: res.Output.Baseinfo.Naty,
  5086. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5087. PsnName: res.Output.Baseinfo.PsnName,
  5088. Idetinfo: idetinfoStr,
  5089. Insuinfo: infoStr,
  5090. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5091. CardInfo: "",
  5092. VerifyNumber: token,
  5093. }
  5094. service.CreateHisPsn(psn)
  5095. c.ServeSuccessJSON(map[string]interface{}{
  5096. "msg": "读取成功",
  5097. })
  5098. }
  5099. } else {
  5100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5101. return
  5102. }
  5103. } else {
  5104. c.ServeSuccessJSON(map[string]interface{}{
  5105. "failed_code": -10,
  5106. "msg": "读取失败",
  5107. })
  5108. }
  5109. }
  5110. }
  5111. func (c *HisApiController) ReadEleFace() {
  5112. admin_user_id, _ := c.GetInt64("admin_user_id")
  5113. //his_patient_id, _ := c.GetInt64("his_patient_id")
  5114. adminUser := c.GetAdminUserInfo()
  5115. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5116. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5117. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5118. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5119. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  5120. if len(tokens) > 0 {
  5121. c.ServeSuccessJSON(map[string]interface{}{
  5122. "msg": "读取成功",
  5123. })
  5124. } else {
  5125. c.ServeSuccessJSON(map[string]interface{}{
  5126. "failed_code": -10,
  5127. "msg": "读取失败",
  5128. })
  5129. }
  5130. }
  5131. }
  5132. func (c *HisApiController) Get9001() {
  5133. adminUser := c.GetAdminUserInfo()
  5134. admin_user_id, _ := c.GetInt64("admin_user_id")
  5135. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5136. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5137. if miConfig.MdtrtareaAdmvs == "350500" {
  5138. service.GetFjAuthorizationInfo(miConfig.Code)
  5139. } else if miConfig.MdtrtareaAdmvs == "131023" {
  5140. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  5141. var dat map[string]interface{}
  5142. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5143. fmt.Println(dat)
  5144. } else {
  5145. fmt.Println(err)
  5146. }
  5147. userJSONBytes, _ := json.Marshal(dat)
  5148. var res models.Result9001
  5149. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5150. utils.ErrorLog("解析失败:%v", err)
  5151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5152. return
  5153. }
  5154. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5155. fmt.Println(miConfig.SecretKey)
  5156. var res models.Result9001Two
  5157. api := miConfig.SecretKey + "ahyb/9001?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  5158. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  5159. resp, requestErr := http.Get(api)
  5160. if requestErr != nil {
  5161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5162. return
  5163. }
  5164. body, ioErr := ioutil.ReadAll(resp.Body)
  5165. if ioErr != nil {
  5166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5168. return
  5169. }
  5170. var respJSON map[string]interface{}
  5171. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5174. return
  5175. }
  5176. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5177. if status == "0" {
  5178. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5179. c.ServeSuccessJSON(map[string]interface{}{
  5180. "failed_code": -10,
  5181. "msg": err_msg,
  5182. })
  5183. return
  5184. }
  5185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5186. result, _ := json.Marshal(respJSON)
  5187. fmt.Println("log")
  5188. fmt.Println(string(result))
  5189. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5190. utils.ErrorLog("解析失败:%v", err)
  5191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5192. return
  5193. }
  5194. if res.Infcode == 0 {
  5195. sign := models.HisSignIn{
  5196. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5197. SignNo: res.Output.Signinoutb.SignNo,
  5198. SignTime: "",
  5199. Ctime: time.Now().Unix(),
  5200. Mtime: time.Now().Unix(),
  5201. Status: 1,
  5202. InputLog: "",
  5203. OutputLog: "",
  5204. FixmedinsCode: miConfig.Code,
  5205. }
  5206. err := service.CreateSignIn(&sign)
  5207. if err == nil {
  5208. c.ServeSuccessJSON(map[string]interface{}{
  5209. "msg": "签到成功",
  5210. })
  5211. }
  5212. } else {
  5213. c.ServeSuccessJSON(map[string]interface{}{
  5214. "failed_code": -10,
  5215. "msg": res.ErrMsg,
  5216. })
  5217. return
  5218. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5219. //return
  5220. }
  5221. } else {
  5222. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5223. var dat map[string]interface{}
  5224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5225. fmt.Println(dat)
  5226. } else {
  5227. fmt.Println(err)
  5228. }
  5229. userJSONBytes, _ := json.Marshal(dat)
  5230. var res models.Result9001
  5231. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5232. utils.ErrorLog("解析失败:%v", err)
  5233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5234. return
  5235. }
  5236. if res.Infcode == 0 {
  5237. sign := models.HisSignIn{
  5238. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5239. SignNo: res.Output.Signinoutb.SignNo,
  5240. SignTime: res.Output.Signinoutb.SignTime,
  5241. Ctime: time.Now().Unix(),
  5242. Mtime: time.Now().Unix(),
  5243. Status: 1,
  5244. InputLog: "",
  5245. OutputLog: "",
  5246. FixmedinsCode: miConfig.Code,
  5247. }
  5248. err := service.CreateSignIn(&sign)
  5249. if err == nil {
  5250. c.ServeSuccessJSON(map[string]interface{}{
  5251. "msg": "签到成功",
  5252. })
  5253. }
  5254. }
  5255. }
  5256. }
  5257. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  5258. var res Result3101
  5259. adminUser := c.GetAdminUserInfo()
  5260. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5261. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5262. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5263. //record_time := c.GetString("record_time")
  5264. //trig_scen := c.GetString("trig_scen")
  5265. timeLayout := "2006-01-02"
  5266. loc, _ := time.LoadLocation("Local")
  5267. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5268. if err != nil {
  5269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5270. return res
  5271. }
  5272. recordDateTime := theTime.Unix()
  5273. var patientPrescription models.HisPrescriptionInfo
  5274. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5275. //if patientPrescription.ID == 0 {
  5276. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5277. //}
  5278. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5279. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5280. //
  5281. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5282. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5283. var pp models.PublicParams
  5284. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5285. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5286. pp.FixmedinsName = miConfig.OrgName
  5287. pp.FixmedinsCode = miConfig.Code
  5288. pp.RequestUrl = miConfig.Url
  5289. pp.Cainfo = miConfig.Cainfo
  5290. pp.SecretKey = miConfig.SecretKey
  5291. pp.AccessKey = miConfig.AccessKey
  5292. pp.OpterName = roles.UserName
  5293. var config []*models.HisXtDiagnoseConfig
  5294. for _, item := range diagnosis_ids {
  5295. id, _ := strconv.ParseInt(item, 10, 64)
  5296. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5297. config = append(config, &diagnosisConfig)
  5298. }
  5299. var pd models.PatientDtos
  5300. pd.PatnID = his.PsnNo
  5301. pd.PatnName = his.Name
  5302. pd.Gend = his.Gend
  5303. pd.Brdy = his.Brdy
  5304. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5305. pd.CurrMdtrtID = his.Number
  5306. var fed models.FsiEncounterDtos
  5307. fed.MdtrtID = his.Number
  5308. fed.MedinsID = miConfig.Code
  5309. fed.MedinsName = miConfig.OrgName
  5310. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5311. fed.MedMdtrtType = "1"
  5312. fed.MedinsType = "1"
  5313. fed.MedinsLv = "11"
  5314. tm := time.Unix(his.RecordDate, 0)
  5315. s_tm := tm.Format("2006-01-02 15:04:05")
  5316. fed.AdmDate = s_tm
  5317. fed.DscgDate = s_tm
  5318. fed.DscgMainDiseCodg = config[0].CountryCode
  5319. fed.DscgMainDiseName = config[0].CountryContentName
  5320. //诊断信息
  5321. var fdds []*models.FsiDiagnoseDtos
  5322. for index, item := range config {
  5323. if index == 0 {
  5324. var fdd models.FsiDiagnoseDtos
  5325. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5326. fdd.InoutDiseType = "1"
  5327. fdd.MaindiseFlag = "1"
  5328. fdd.DiseDate = s_tm
  5329. fdd.DiasSrtNo = "1"
  5330. fdd.DiseName = item.CountryContentName
  5331. fdd.DiseCodg = item.CountryCode
  5332. fdds = append(fdds, &fdd)
  5333. } else {
  5334. var fdd models.FsiDiagnoseDtos
  5335. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5336. fdd.InoutDiseType = "1"
  5337. fdd.MaindiseFlag = "1"
  5338. fdd.DiseDate = s_tm
  5339. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5340. fdd.DiseName = item.CountryContentName
  5341. fdd.DiseCodg = item.CountryCode
  5342. fdds = append(fdds, &fdd)
  5343. }
  5344. }
  5345. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5346. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5347. fed.AdmDeptName = department.Name
  5348. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5349. fed.DscgDeptName = department.Name
  5350. fed.MedMdtrtType = "1"
  5351. fed.MedType = "11"
  5352. //if his.Insutype == "390" {
  5353. // fed.MedType = "1402"
  5354. //} else {
  5355. // fed.MedType = "9933"
  5356. //}
  5357. var orders []*models.FsiOrderDtos
  5358. if trig_scen == "2" {
  5359. //处方医嘱信息
  5360. for _, item := range prescriptions {
  5361. for _, subItem := range item.HisDoctorAdviceInfo {
  5362. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5363. var order models.FsiOrderDtos
  5364. order.RxID = strconv.FormatInt(item.ID, 10)
  5365. order.Rxno = strconv.FormatInt(item.ID, 10)
  5366. order.LongDrordFlag = "0"
  5367. order.HilistType = "1"
  5368. order.ChrgType = "1"
  5369. order.DrordBhvr = "-"
  5370. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5371. order.HosplistName = subItem.BaseDrugLib.DrugName
  5372. order.HilistLv = "1"
  5373. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5374. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5375. order.HosplistName = subItem.BaseDrugLib.DrugName
  5376. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5377. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5378. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5379. order.OwnpayAmt = ""
  5380. order.SelfpayAmt = ""
  5381. order.Spec = ""
  5382. order.SpecUnt = ""
  5383. order.DrordBegnDate = s_tm
  5384. order.DrordStopDate = ""
  5385. order.DrordDrCodg = doctor_info.DoctorNumber
  5386. order.DrordDeptName = department.Name
  5387. order.DrordDeptCodg = department.Number
  5388. order.DrordDrName = doctor_info.UserName
  5389. order.DrordDrProfttl = "234"
  5390. order.CurrDrordFlag = "1"
  5391. orders = append(orders, &order)
  5392. }
  5393. }
  5394. for _, subItem := range item.HisPrescriptionProject {
  5395. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5396. var order models.FsiOrderDtos
  5397. order.RxID = strconv.FormatInt(item.ID, 10)
  5398. order.Rxno = strconv.FormatInt(item.ID, 10)
  5399. order.LongDrordFlag = "0"
  5400. order.HilistType = "1"
  5401. order.ChrgType = "1"
  5402. order.DrordBhvr = "-"
  5403. order.HilistCode = subItem.HisProject.MedicalCode
  5404. order.HosplistName = subItem.HisProject.ProjectName
  5405. order.HilistLv = "1"
  5406. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5407. order.HosplistCode = subItem.HisProject.MedicalCode
  5408. order.HosplistName = subItem.HisProject.ProjectName
  5409. order.Cnt = subItem.Count
  5410. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5411. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5412. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5413. order.OwnpayAmt = ""
  5414. order.SelfpayAmt = ""
  5415. order.Spec = ""
  5416. order.SpecUnt = ""
  5417. order.DrordBegnDate = s_tm
  5418. order.DrordStopDate = ""
  5419. order.DrordDrCodg = doctor_info.DoctorNumber
  5420. order.DrordDeptName = department.Name
  5421. order.DrordDeptCodg = department.Number
  5422. order.DrordDrName = doctor_info.UserName
  5423. order.DrordDrProfttl = "234"
  5424. order.CurrDrordFlag = "1"
  5425. orders = append(orders, &order)
  5426. }
  5427. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5428. var order models.FsiOrderDtos
  5429. order.RxID = strconv.FormatInt(item.ID, 10)
  5430. order.Rxno = strconv.FormatInt(item.ID, 10)
  5431. order.LongDrordFlag = "0"
  5432. order.HilistType = "1"
  5433. order.ChrgType = "1"
  5434. order.DrordBhvr = "-"
  5435. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5436. order.HosplistName = subItem.GoodInfo.GoodName
  5437. order.HilistLv = "1"
  5438. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5439. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5440. order.HosplistName = subItem.GoodInfo.GoodName
  5441. order.Cnt = subItem.Count
  5442. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5443. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5444. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5445. order.OwnpayAmt = ""
  5446. order.SelfpayAmt = ""
  5447. order.Spec = ""
  5448. order.SpecUnt = ""
  5449. order.DrordBegnDate = s_tm
  5450. order.DrordStopDate = ""
  5451. order.DrordDrCodg = doctor_info.DoctorNumber
  5452. order.DrordDeptName = department.Name
  5453. order.DrordDeptCodg = department.Number
  5454. order.DrordDrName = doctor_info.UserName
  5455. order.DrordDrProfttl = "234"
  5456. order.CurrDrordFlag = "1"
  5457. orders = append(orders, &order)
  5458. }
  5459. }
  5460. }
  5461. //处方医嘱信息
  5462. }
  5463. fed.MatnStas = "0"
  5464. fed.MedfeeSumamt = "0"
  5465. fed.OwnpayAmt = "0"
  5466. fed.SelfpayAmt = "0"
  5467. fed.AcctPayamt = "0"
  5468. fed.MaAmt = "0"
  5469. fed.HifpPayamt = "0"
  5470. fed.SetlTotlnum = "1"
  5471. fed.Insutype = his.Insutype
  5472. fed.ReimFlag = "0"
  5473. fed.OutSetlFlag = "0"
  5474. var fopd []*models.FsiOperationDtosData
  5475. data := make(map[string]interface{})
  5476. data["fed"] = fed
  5477. data["fdd"] = fdds
  5478. data["fod"] = orders
  5479. data["pd"] = pd
  5480. data["pp"] = pp
  5481. data["fopd"] = fopd
  5482. data["trig_scen"] = trig_scen
  5483. fmt.Println(data)
  5484. fmt.Println(fed)
  5485. fmt.Println(fdds)
  5486. fmt.Println(orders)
  5487. fmt.Println(pd)
  5488. fmt.Println(pp)
  5489. fmt.Println(fopd)
  5490. client := &http.Client{}
  5491. bytesData, _ := json.Marshal(data)
  5492. var req *http.Request
  5493. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5494. if miConfig.MdtrtareaAdmvs == "320921" {
  5495. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5496. } else {
  5497. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5498. }
  5499. resp, _ := client.Do(req)
  5500. defer resp.Body.Close()
  5501. body, ioErr := ioutil.ReadAll(resp.Body)
  5502. if ioErr != nil {
  5503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5505. return res
  5506. }
  5507. var respJSON map[string]interface{}
  5508. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5511. return res
  5512. }
  5513. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5514. fmt.Println(respJSON)
  5515. result, _ := json.Marshal(respJSON)
  5516. fmt.Println(result)
  5517. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5518. utils.ErrorLog("解析失败:%v", err)
  5519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5520. return res
  5521. }
  5522. return res
  5523. } else {
  5524. //if miConfig.MdtrtareaAdmvs == "441202" {
  5525. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5526. saveLog(output, input, "3101", "事前")
  5527. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5528. utils.ErrorLog("解析失败:%v", err)
  5529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5530. return
  5531. }
  5532. return res
  5533. //}
  5534. }
  5535. }
  5536. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  5537. adminUser := c.GetAdminUserInfo()
  5538. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5539. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5540. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5541. //record_time := c.GetString("record_time")
  5542. //trig_scen := c.GetString("trig_scen")
  5543. timeLayout := "2006-01-02"
  5544. loc, _ := time.LoadLocation("Local")
  5545. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5546. if err != nil {
  5547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5548. return res
  5549. }
  5550. recordDateTime := theTime.Unix()
  5551. var patientPrescription models.HisPrescriptionInfo
  5552. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5553. if patientPrescription.ID == 0 {
  5554. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5555. }
  5556. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5557. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5558. //
  5559. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5560. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5561. var pp models.PublicParams
  5562. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5563. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5564. pp.FixmedinsName = miConfig.OrgName
  5565. pp.FixmedinsCode = miConfig.Code
  5566. pp.RequestUrl = miConfig.Url
  5567. pp.Cainfo = miConfig.Cainfo
  5568. pp.SecretKey = miConfig.SecretKey
  5569. pp.AccessKey = miConfig.AccessKey
  5570. pp.OpterName = roles.UserName
  5571. var config []*models.HisXtDiagnoseConfig
  5572. for _, item := range diagnosis_ids {
  5573. id, _ := strconv.ParseInt(item, 10, 64)
  5574. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5575. config = append(config, &diagnosisConfig)
  5576. }
  5577. var pd models.PatientDtos
  5578. pd.PatnID = his.PsnNo
  5579. pd.PatnName = his.Name
  5580. pd.Gend = his.Gend
  5581. pd.Brdy = his.Brdy
  5582. pd.Poolarea = his.InsuplcAdmdvs
  5583. pd.CurrMdtrtID = his.Number
  5584. var fed models.FsiEncounterDtos
  5585. fed.MdtrtID = his.Number
  5586. fed.MedinsID = miConfig.Code
  5587. fed.MedinsName = miConfig.OrgName
  5588. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5589. fed.MedMdtrtType = "1"
  5590. fed.MedinsType = "1"
  5591. fed.MedinsLv = "11"
  5592. tm := time.Unix(his.RecordDate, 0)
  5593. s_tm := tm.Format("2006-01-02 15:04:05")
  5594. fed.AdmDate = s_tm
  5595. fed.DscgDate = s_tm
  5596. fed.DscgMainDiseCodg = config[0].CountryCode
  5597. fed.DscgMainDiseName = config[0].CountryContentName
  5598. //诊断信息
  5599. var fdds []*models.FsiDiagnoseDtos
  5600. for index, item := range config {
  5601. if index == 0 {
  5602. var fdd models.FsiDiagnoseDtos
  5603. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5604. fdd.InoutDiseType = "1"
  5605. fdd.MaindiseFlag = "1"
  5606. fdd.DiseDate = s_tm
  5607. fdd.DiasSrtNo = "1"
  5608. fdd.DiseName = item.CountryContentName
  5609. fdd.DiseCodg = item.CountryCode
  5610. fdds = append(fdds, &fdd)
  5611. } else {
  5612. var fdd models.FsiDiagnoseDtos
  5613. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5614. fdd.InoutDiseType = "1"
  5615. fdd.MaindiseFlag = "1"
  5616. fdd.DiseDate = s_tm
  5617. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5618. fdd.DiseName = item.CountryContentName
  5619. fdd.DiseCodg = item.CountryCode
  5620. fdds = append(fdds, &fdd)
  5621. }
  5622. }
  5623. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5624. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5625. fed.AdmDeptName = department.Name
  5626. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5627. fed.DscgDeptName = department.Name
  5628. fed.MedMdtrtType = "1"
  5629. fed.MedType = "11"
  5630. //if his.Insutype == "390" {
  5631. // fed.MedType = "1402"
  5632. //} else {
  5633. // fed.MedType = "9933"
  5634. //}
  5635. var orders []*models.FsiOrderDtos
  5636. if trig_scen == "2" {
  5637. //处方医嘱信息
  5638. for _, item := range prescriptions {
  5639. for _, subItem := range item.HisDoctorAdviceInfo {
  5640. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5641. var order models.FsiOrderDtos
  5642. order.RxID = strconv.FormatInt(item.ID, 10)
  5643. order.Rxno = strconv.FormatInt(item.ID, 10)
  5644. order.LongDrordFlag = "0"
  5645. order.HilistType = "1"
  5646. order.ChrgType = "1"
  5647. order.DrordBhvr = "-"
  5648. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5649. order.HosplistName = subItem.BaseDrugLib.DrugName
  5650. order.HilistLv = "1"
  5651. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5652. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5653. order.HosplistName = subItem.BaseDrugLib.DrugName
  5654. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5655. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5656. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5657. order.OwnpayAmt = ""
  5658. order.SelfpayAmt = ""
  5659. order.Spec = ""
  5660. order.SpecUnt = ""
  5661. order.DrordBegnDate = s_tm
  5662. order.DrordStopDate = ""
  5663. order.DrordDrCodg = doctor_info.DoctorNumber
  5664. order.DrordDeptName = department.Name
  5665. order.DrordDeptCodg = department.Number
  5666. order.DrordDrName = doctor_info.UserName
  5667. order.DrordDrProfttl = "234"
  5668. order.CurrDrordFlag = "1"
  5669. orders = append(orders, &order)
  5670. }
  5671. }
  5672. for _, subItem := range item.HisPrescriptionProject {
  5673. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5674. var order models.FsiOrderDtos
  5675. order.RxID = strconv.FormatInt(item.ID, 10)
  5676. order.Rxno = strconv.FormatInt(item.ID, 10)
  5677. order.LongDrordFlag = "0"
  5678. order.HilistType = "1"
  5679. order.ChrgType = "1"
  5680. order.DrordBhvr = "-"
  5681. order.HilistCode = subItem.HisProject.MedicalCode
  5682. order.HosplistName = subItem.HisProject.ProjectName
  5683. order.HilistLv = "1"
  5684. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5685. order.HosplistCode = subItem.HisProject.MedicalCode
  5686. order.HosplistName = subItem.HisProject.ProjectName
  5687. order.Cnt = subItem.Count
  5688. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5689. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5690. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5691. order.OwnpayAmt = ""
  5692. order.SelfpayAmt = ""
  5693. order.Spec = ""
  5694. order.SpecUnt = ""
  5695. order.DrordBegnDate = s_tm
  5696. order.DrordStopDate = ""
  5697. order.DrordDrCodg = doctor_info.DoctorNumber
  5698. order.DrordDeptName = department.Name
  5699. order.DrordDeptCodg = department.Number
  5700. order.DrordDrName = doctor_info.UserName
  5701. order.DrordDrProfttl = "234"
  5702. order.CurrDrordFlag = "1"
  5703. orders = append(orders, &order)
  5704. }
  5705. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5706. var order models.FsiOrderDtos
  5707. order.RxID = strconv.FormatInt(item.ID, 10)
  5708. order.Rxno = strconv.FormatInt(item.ID, 10)
  5709. order.LongDrordFlag = "0"
  5710. order.HilistType = "1"
  5711. order.ChrgType = "1"
  5712. order.DrordBhvr = "-"
  5713. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5714. order.HosplistName = subItem.GoodInfo.GoodName
  5715. order.HilistLv = "1"
  5716. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5717. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5718. order.HosplistName = subItem.GoodInfo.GoodName
  5719. order.Cnt = subItem.Count
  5720. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5721. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5722. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5723. order.OwnpayAmt = ""
  5724. order.SelfpayAmt = ""
  5725. order.Spec = ""
  5726. order.SpecUnt = ""
  5727. order.DrordBegnDate = s_tm
  5728. order.DrordStopDate = ""
  5729. order.DrordDrCodg = doctor_info.DoctorNumber
  5730. order.DrordDeptName = department.Name
  5731. order.DrordDeptCodg = department.Number
  5732. order.DrordDrName = doctor_info.UserName
  5733. order.DrordDrProfttl = "234"
  5734. order.CurrDrordFlag = "1"
  5735. orders = append(orders, &order)
  5736. }
  5737. }
  5738. }
  5739. //处方医嘱信息
  5740. }
  5741. fed.MatnStas = "0"
  5742. fed.MedfeeSumamt = "0"
  5743. fed.OwnpayAmt = "0"
  5744. fed.SelfpayAmt = "0"
  5745. fed.AcctPayamt = "0"
  5746. fed.MaAmt = "0"
  5747. fed.HifpPayamt = "0"
  5748. fed.SetlTotlnum = "1"
  5749. fed.Insutype = his.Insutype
  5750. fed.ReimFlag = "0"
  5751. fed.OutSetlFlag = "0"
  5752. var fopd []*models.FsiOperationDtosData
  5753. data := make(map[string]interface{})
  5754. data["fed"] = fed
  5755. data["fdd"] = fdds
  5756. data["fod"] = orders
  5757. data["pd"] = pd
  5758. data["pp"] = pp
  5759. data["fopd"] = fopd
  5760. data["trig_scen"] = trig_scen
  5761. fmt.Println(data)
  5762. fmt.Println(fed)
  5763. fmt.Println(fdds)
  5764. fmt.Println(orders)
  5765. fmt.Println(pd)
  5766. fmt.Println(pp)
  5767. fmt.Println(fopd)
  5768. client := &http.Client{}
  5769. bytesData, _ := json.Marshal(data)
  5770. var req *http.Request
  5771. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5772. if miConfig.MdtrtareaAdmvs == "320921" {
  5773. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5774. } else {
  5775. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5776. }
  5777. resp, _ := client.Do(req)
  5778. defer resp.Body.Close()
  5779. body, ioErr := ioutil.ReadAll(resp.Body)
  5780. if ioErr != nil {
  5781. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5783. return res
  5784. }
  5785. var respJSON map[string]interface{}
  5786. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5789. return res
  5790. }
  5791. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5792. fmt.Println(respJSON)
  5793. result, _ := json.Marshal(respJSON)
  5794. fmt.Println(result)
  5795. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5796. utils.ErrorLog("解析失败:%v", err)
  5797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5798. return res
  5799. }
  5800. return res
  5801. } else {
  5802. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5803. saveLog(output, input, "3101", "事前")
  5804. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5805. utils.ErrorLog("解析失败:%v", err)
  5806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5807. return
  5808. }
  5809. return res
  5810. }
  5811. return res
  5812. }
  5813. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5814. ////patient_id, _ := c.GetInt64("patient_id")
  5815. //order_id, _ := c.GetInt64("order_id")
  5816. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5817. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5818. //trig_scen := c.GetString("trig_scen")
  5819. adminUser := c.GetAdminUserInfo()
  5820. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5821. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5822. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5823. record_time := c.GetString("record_time")
  5824. order, _ := service.GetHisOrderByID(order_id)
  5825. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5826. timeLayout := "2006-01-02"
  5827. loc, _ := time.LoadLocation("Local")
  5828. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5829. if err != nil {
  5830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5831. return
  5832. }
  5833. recordDateTime := theTime.Unix()
  5834. var patientPrescription models.HisPrescriptionInfo
  5835. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5836. if patientPrescription.ID == 0 {
  5837. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5838. }
  5839. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5840. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5841. //
  5842. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5843. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5844. var pp models.PublicParams
  5845. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5846. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5847. pp.FixmedinsName = miConfig.OrgName
  5848. pp.FixmedinsCode = miConfig.Code
  5849. pp.RequestUrl = miConfig.Url
  5850. pp.Cainfo = miConfig.Cainfo
  5851. pp.SecretKey = miConfig.SecretKey
  5852. pp.AccessKey = miConfig.AccessKey
  5853. pp.OpterName = roles.UserName
  5854. var config []*models.HisXtDiagnoseConfig
  5855. for _, item := range diagnosis_ids {
  5856. id, _ := strconv.ParseInt(item, 10, 64)
  5857. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5858. config = append(config, &diagnosisConfig)
  5859. }
  5860. var pd models.PatientDtos
  5861. pd.PatnID = his.PsnNo
  5862. pd.PatnName = his.Name
  5863. pd.Gend = his.Gend
  5864. pd.Brdy = psn_info.Brdy
  5865. pd.Poolarea = his.InsuplcAdmdvs
  5866. pd.CurrMdtrtID = his.Number
  5867. var fed models.FsiEncounterDtos
  5868. fed.MdtrtID = his.Number
  5869. fed.MedinsID = miConfig.Code
  5870. fed.MedinsName = miConfig.OrgName
  5871. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5872. fed.MedMdtrtType = "1"
  5873. fed.MedinsType = "1"
  5874. fed.MedinsLv = "11"
  5875. tm := time.Unix(his.RecordDate, 0)
  5876. s_tm := tm.Format("2006-01-02 15:04:05")
  5877. fed.AdmDate = s_tm
  5878. fed.DscgDate = s_tm
  5879. fed.DscgMainDiseCodg = config[0].CountryCode
  5880. fed.DscgMainDiseName = config[0].CountryContentName
  5881. //诊断信息
  5882. var fdds []*models.FsiDiagnoseDtos
  5883. for index, item := range config {
  5884. if index == 0 {
  5885. var fdd models.FsiDiagnoseDtos
  5886. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5887. fdd.InoutDiseType = "1"
  5888. fdd.MaindiseFlag = "1"
  5889. fdd.DiseDate = s_tm
  5890. fdd.DiasSrtNo = "1"
  5891. fdd.DiseName = item.CountryContentName
  5892. fdd.DiseCodg = item.CountryCode
  5893. fdds = append(fdds, &fdd)
  5894. } else {
  5895. var fdd models.FsiDiagnoseDtos
  5896. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5897. fdd.InoutDiseType = "1"
  5898. fdd.MaindiseFlag = "1"
  5899. fdd.DiseDate = s_tm
  5900. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5901. fdd.DiseName = item.CountryContentName
  5902. fdd.DiseCodg = item.CountryCode
  5903. fdds = append(fdds, &fdd)
  5904. }
  5905. }
  5906. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5907. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5908. fed.AdmDeptName = department.Name
  5909. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5910. fed.DscgDeptName = department.Name
  5911. fed.MedType = order.MedType
  5912. //处方医嘱信息
  5913. var orders []*models.FsiOrderDtos
  5914. //for _, item := range prescriptions {
  5915. // for _, subItem := range item.HisDoctorAdviceInfo {
  5916. // var order models.FsiOrderDtos
  5917. // order.RxID = strconv.FormatInt(item.ID, 10)
  5918. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5919. // order.LongDrordFlag = "0"
  5920. // order.HilistType = "1"
  5921. // order.ChrgType = "1"
  5922. // order.DrordBhvr = "-"
  5923. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5924. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5925. // order.HilistLv = "1"
  5926. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5927. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5928. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5929. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5930. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5931. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5932. // order.OwnpayAmt = ""
  5933. // order.SelfpayAmt = ""
  5934. // order.Spec = ""
  5935. // order.SpecUnt = ""
  5936. // order.DrordBegnDate = s_tm
  5937. // order.DrordStopDate = ""
  5938. // order.DrordDrCodg = "1"
  5939. // order.DrordDeptName = department.Name
  5940. // order.DrordDrCodg = "1"
  5941. // order.DrordDrName = doctor_info.UserName
  5942. // order.DrordDrProfttl = ""
  5943. // order.CurrDrordFlag = "1"
  5944. // orders = append(orders, &order)
  5945. // }
  5946. // for _, subItem := range item.HisPrescriptionProject {
  5947. // if subItem.Type == 2 {
  5948. // var order models.FsiOrderDtos
  5949. // order.RxID = strconv.FormatInt(item.ID, 10)
  5950. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5951. // order.LongDrordFlag = "0"
  5952. // order.HilistType = "1"
  5953. // order.ChrgType = "1"
  5954. // order.DrordBhvr = "-"
  5955. // order.HilistCode = subItem.HisProject.MedicalCode
  5956. // order.HosplistName = subItem.HisProject.ProjectName
  5957. // order.HilistLv = "1"
  5958. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5959. // order.HosplistCode = subItem.HisProject.MedicalCode
  5960. // order.HosplistName = subItem.HisProject.ProjectName
  5961. // order.Cnt = subItem.Count
  5962. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5963. //
  5964. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5965. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5966. // order.OwnpayAmt = ""
  5967. // order.SelfpayAmt = ""
  5968. // order.Spec = ""
  5969. // order.SpecUnt = ""
  5970. // order.DrordBegnDate = s_tm
  5971. // order.DrordStopDate = ""
  5972. // order.DrordDrCodg = "1"
  5973. // order.DrordDeptName = department.Name
  5974. // order.DrordDrCodg = "1"
  5975. // order.DrordDrName = doctor_info.UserName
  5976. // order.DrordDrProfttl = ""
  5977. // order.CurrDrordFlag = "1"
  5978. // orders = append(orders, &order)
  5979. //
  5980. // }
  5981. // if subItem.Type == 3 {
  5982. //
  5983. // var order models.FsiOrderDtos
  5984. // order.RxID = strconv.FormatInt(item.ID, 10)
  5985. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5986. // order.LongDrordFlag = "0"
  5987. // order.HilistType = "1"
  5988. // order.ChrgType = "1"
  5989. // order.DrordBhvr = "-"
  5990. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5991. // order.HosplistName = subItem.GoodInfo.GoodName
  5992. // order.HilistLv = "1"
  5993. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5994. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5995. // order.HosplistName = subItem.GoodInfo.GoodName
  5996. // order.Cnt = subItem.Count
  5997. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5998. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5999. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6000. // order.OwnpayAmt = ""
  6001. // order.SelfpayAmt = ""
  6002. // order.Spec = ""
  6003. // order.SpecUnt = ""
  6004. // order.DrordBegnDate = s_tm
  6005. // order.DrordStopDate = ""
  6006. // order.DrordDrCodg = "1"
  6007. // order.DrordDeptName = department.Name
  6008. // order.DrordDrCodg = "1"
  6009. // order.DrordDrName = doctor_info.UserName
  6010. // order.DrordDrProfttl = ""
  6011. // order.CurrDrordFlag = "1"
  6012. // orders = append(orders, &order)
  6013. //
  6014. // }
  6015. // }
  6016. //}
  6017. for _, item := range prescriptions {
  6018. for _, subItem := range item.HisDoctorAdviceInfo {
  6019. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6020. var order models.FsiOrderDtos
  6021. order.RxID = strconv.FormatInt(item.ID, 10)
  6022. order.Rxno = strconv.FormatInt(item.ID, 10)
  6023. order.LongDrordFlag = "0"
  6024. order.HilistType = "1"
  6025. order.ChrgType = "1"
  6026. order.DrordBhvr = "-"
  6027. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6028. order.HosplistName = subItem.BaseDrugLib.DrugName
  6029. order.HilistLv = "1"
  6030. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6031. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6032. order.HosplistName = subItem.BaseDrugLib.DrugName
  6033. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6034. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6035. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6036. order.OwnpayAmt = ""
  6037. order.SelfpayAmt = ""
  6038. order.Spec = ""
  6039. order.SpecUnt = ""
  6040. order.DrordBegnDate = s_tm
  6041. order.DrordStopDate = ""
  6042. order.DrordDrCodg = doctor_info.DoctorNumber
  6043. order.DrordDeptName = department.Name
  6044. order.DrordDeptCodg = department.Number
  6045. order.DrordDrName = doctor_info.UserName
  6046. order.DrordDrProfttl = "234"
  6047. order.CurrDrordFlag = "1"
  6048. orders = append(orders, &order)
  6049. }
  6050. }
  6051. for _, subItem := range item.HisPrescriptionProject {
  6052. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6053. var order models.FsiOrderDtos
  6054. order.RxID = strconv.FormatInt(item.ID, 10)
  6055. order.Rxno = strconv.FormatInt(item.ID, 10)
  6056. order.LongDrordFlag = "0"
  6057. order.HilistType = "1"
  6058. order.ChrgType = "1"
  6059. order.DrordBhvr = "-"
  6060. order.HilistCode = subItem.HisProject.MedicalCode
  6061. order.HosplistName = subItem.HisProject.ProjectName
  6062. order.HilistLv = "1"
  6063. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6064. order.HosplistCode = subItem.HisProject.MedicalCode
  6065. order.HosplistName = subItem.HisProject.ProjectName
  6066. order.Cnt = subItem.Count
  6067. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6068. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6069. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6070. order.OwnpayAmt = ""
  6071. order.SelfpayAmt = ""
  6072. order.Spec = ""
  6073. order.SpecUnt = ""
  6074. order.DrordBegnDate = s_tm
  6075. order.DrordStopDate = ""
  6076. order.DrordDrCodg = doctor_info.DoctorNumber
  6077. order.DrordDeptName = department.Name
  6078. order.DrordDeptCodg = department.Number
  6079. order.DrordDrName = doctor_info.UserName
  6080. order.DrordDrProfttl = "234"
  6081. order.CurrDrordFlag = "1"
  6082. orders = append(orders, &order)
  6083. }
  6084. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6085. var order models.FsiOrderDtos
  6086. order.RxID = strconv.FormatInt(item.ID, 10)
  6087. order.Rxno = strconv.FormatInt(item.ID, 10)
  6088. order.LongDrordFlag = "0"
  6089. order.HilistType = "1"
  6090. order.ChrgType = "1"
  6091. order.DrordBhvr = "0"
  6092. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6093. order.HosplistName = subItem.GoodInfo.GoodName
  6094. order.HilistLv = "1"
  6095. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6096. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6097. order.HosplistName = subItem.GoodInfo.GoodName
  6098. order.Cnt = subItem.Count
  6099. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6100. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6101. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6102. order.OwnpayAmt = ""
  6103. order.SelfpayAmt = ""
  6104. order.Spec = ""
  6105. order.SpecUnt = ""
  6106. order.DrordBegnDate = s_tm
  6107. order.DrordStopDate = ""
  6108. order.DrordDrCodg = doctor_info.DoctorNumber
  6109. order.DrordDeptName = department.Name
  6110. order.DrordDeptCodg = department.Number
  6111. order.DrordDrName = doctor_info.UserName
  6112. order.DrordDrProfttl = "234"
  6113. order.CurrDrordFlag = "1"
  6114. orders = append(orders, &order)
  6115. }
  6116. }
  6117. }
  6118. //处方医嘱信息
  6119. fed.MatnStas = "0"
  6120. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6121. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6122. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6123. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6124. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6125. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6126. fed.SetlTotlnum = "1"
  6127. fed.Insutype = his.Insutype
  6128. fed.ReimFlag = "0"
  6129. fed.OutSetlFlag = "0"
  6130. var fopd []*models.FsiOperationDtosData
  6131. data := make(map[string]interface{})
  6132. data["fed"] = fed
  6133. data["fdd"] = fdds
  6134. data["fod"] = orders
  6135. data["pd"] = pd
  6136. data["pp"] = pp
  6137. data["fopd"] = fopd
  6138. data["trig_scen"] = trig_scen
  6139. client := &http.Client{}
  6140. bytesData, _ := json.Marshal(data)
  6141. var req *http.Request
  6142. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6143. if miConfig.MdtrtareaAdmvs == "320921" {
  6144. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6145. } else {
  6146. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6147. }
  6148. resp, _ := client.Do(req)
  6149. defer resp.Body.Close()
  6150. body, ioErr := ioutil.ReadAll(resp.Body)
  6151. if ioErr != nil {
  6152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6154. return res
  6155. }
  6156. var respJSON map[string]interface{}
  6157. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6160. return res
  6161. }
  6162. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6163. result, _ := json.Marshal(respJSON)
  6164. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6165. utils.ErrorLog("解析失败:%v", err)
  6166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6167. return res
  6168. }
  6169. return res
  6170. } else {
  6171. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6172. saveLog(output, input, "3102", "事中")
  6173. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6174. utils.ErrorLog("解析失败:%v", err)
  6175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6176. return
  6177. }
  6178. return res
  6179. }
  6180. return res
  6181. }
  6182. func Checkgd3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Resultgd3101) {
  6183. var res Resultgd3101
  6184. adminUser := c.GetAdminUserInfo()
  6185. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6186. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6187. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6188. //record_time := c.GetString("record_time")
  6189. //trig_scen := c.GetString("trig_scen")
  6190. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6191. timeLayout := "2006-01-02"
  6192. loc, _ := time.LoadLocation("Local")
  6193. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6194. if err != nil {
  6195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6196. return res
  6197. }
  6198. recordDateTime := theTime.Unix()
  6199. var patientPrescription models.HisPrescriptionInfo
  6200. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6201. //if patientPrescription.ID == 0 {
  6202. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6203. //}
  6204. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6205. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6206. //
  6207. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6208. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6209. var pp models.PublicParams
  6210. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6211. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6212. pp.FixmedinsName = miConfig.OrgName
  6213. pp.FixmedinsCode = miConfig.Code
  6214. pp.RequestUrl = miConfig.Url
  6215. pp.Cainfo = miConfig.Cainfo
  6216. pp.SecretKey = miConfig.SecretKey
  6217. pp.AccessKey = miConfig.AccessKey
  6218. pp.OpterName = roles.UserName
  6219. var config []*models.HisXtDiagnoseConfig
  6220. for _, item := range diagnosis_ids {
  6221. id, _ := strconv.ParseInt(item, 10, 64)
  6222. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6223. config = append(config, &diagnosisConfig)
  6224. }
  6225. var pd models.PatientDtos
  6226. pd.PatnID = his.PsnNo
  6227. pd.PatnName = his.Name
  6228. pd.Gend = his.Gend
  6229. pd.Brdy = psn_info.Brdy
  6230. pd.Poolarea = miConfig.MdtrtareaAdmvs
  6231. pd.CurrMdtrtID = his.Number
  6232. var fed models.FsiEncounterDtos
  6233. fed.MdtrtID = his.Number
  6234. fed.MedinsID = miConfig.Code
  6235. fed.MedinsName = miConfig.OrgName
  6236. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6237. fed.MedMdtrtType = "1"
  6238. fed.MedinsType = "1"
  6239. fed.MedinsLv = "11"
  6240. tm := time.Unix(his.RecordDate, 0)
  6241. s_tm := tm.Format("2006-01-02 15:04:05")
  6242. fed.AdmDate = s_tm
  6243. fed.DscgDate = s_tm
  6244. fed.DscgMainDiseCodg = config[0].CountryCode
  6245. fed.DscgMainDiseName = config[0].CountryContentName
  6246. //诊断信息
  6247. var fdds []*models.FsiDiagnoseDtos
  6248. for index, item := range config {
  6249. if index == 0 {
  6250. var fdd models.FsiDiagnoseDtos
  6251. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6252. fdd.InoutDiseType = "1"
  6253. fdd.MaindiseFlag = "1"
  6254. fdd.DiseDate = s_tm
  6255. fdd.DiasSrtNo = "1"
  6256. fdd.DiseName = item.CountryContentName
  6257. fdd.DiseCodg = item.CountryCode
  6258. fdds = append(fdds, &fdd)
  6259. } else {
  6260. var fdd models.FsiDiagnoseDtos
  6261. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6262. fdd.InoutDiseType = "1"
  6263. fdd.MaindiseFlag = "1"
  6264. fdd.DiseDate = s_tm
  6265. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6266. fdd.DiseName = item.CountryContentName
  6267. fdd.DiseCodg = item.CountryCode
  6268. fdds = append(fdds, &fdd)
  6269. }
  6270. }
  6271. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6272. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6273. fed.AdmDeptName = department.Name
  6274. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6275. fed.DscgDeptName = department.Name
  6276. fed.MedMdtrtType = "1"
  6277. fed.MedType = "11"
  6278. //if his.Insutype == "390" {
  6279. // fed.MedType = "1402"
  6280. //} else {
  6281. // fed.MedType = "9933"
  6282. //}
  6283. var orders []*models.FsiOrderDtos
  6284. if trig_scen == "2" {
  6285. //处方医嘱信息
  6286. for _, item := range prescriptions {
  6287. for _, subItem := range item.HisDoctorAdviceInfo {
  6288. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6289. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6290. var order models.FsiOrderDtos
  6291. order.RxID = strconv.FormatInt(item.ID, 10)
  6292. order.Rxno = strconv.FormatInt(item.ID, 10)
  6293. order.LongDrordFlag = "0"
  6294. order.HilistType = "1"
  6295. order.ChrgType = "1"
  6296. order.DrordBhvr = "0"
  6297. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6298. order.HosplistName = subItem.BaseDrugLib.DrugName
  6299. order.HilistLv = "1"
  6300. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6301. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6302. order.HosplistName = subItem.BaseDrugLib.DrugName
  6303. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6304. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6305. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6306. order.OwnpayAmt = ""
  6307. order.SelfpayAmt = ""
  6308. order.Spec = spec
  6309. order.SpecUnt = subItem.PrescribingNumberUnit
  6310. order.DrordBegnDate = s_tm
  6311. order.DrordStopDate = ""
  6312. order.DrordDrCodg = doctor_info.DoctorNumber
  6313. order.DrordDeptName = department.Name
  6314. order.DrordDeptCodg = department.Number
  6315. order.DrordDrName = doctor_info.UserName
  6316. order.DrordDrProfttl = "234"
  6317. order.CurrDrordFlag = "1"
  6318. orders = append(orders, &order)
  6319. }
  6320. }
  6321. for _, subItem := range item.HisPrescriptionProject {
  6322. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6323. var order models.FsiOrderDtos
  6324. order.RxID = strconv.FormatInt(item.ID, 10)
  6325. order.Rxno = strconv.FormatInt(item.ID, 10)
  6326. order.LongDrordFlag = "0"
  6327. order.HilistType = "1"
  6328. order.ChrgType = "1"
  6329. order.DrordBhvr = "0"
  6330. order.HilistCode = subItem.HisProject.MedicalCode
  6331. order.HosplistName = subItem.HisProject.ProjectName
  6332. order.HilistLv = "1"
  6333. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6334. order.HosplistCode = subItem.HisProject.MedicalCode
  6335. order.HosplistName = subItem.HisProject.ProjectName
  6336. order.Cnt = subItem.Count
  6337. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6338. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6339. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6340. order.OwnpayAmt = ""
  6341. order.SelfpayAmt = ""
  6342. order.Spec = subItem.Unit
  6343. order.SpecUnt = subItem.Unit
  6344. order.DrordBegnDate = s_tm
  6345. order.DrordStopDate = ""
  6346. order.DrordDrCodg = doctor_info.DoctorNumber
  6347. order.DrordDeptName = department.Name
  6348. order.DrordDeptCodg = department.Number
  6349. order.DrordDrName = doctor_info.UserName
  6350. order.DrordDrProfttl = "234"
  6351. order.CurrDrordFlag = "1"
  6352. orders = append(orders, &order)
  6353. }
  6354. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6355. var order models.FsiOrderDtos
  6356. order.RxID = strconv.FormatInt(item.ID, 10)
  6357. order.Rxno = strconv.FormatInt(item.ID, 10)
  6358. order.LongDrordFlag = "0"
  6359. order.HilistType = "1"
  6360. order.ChrgType = "1"
  6361. order.DrordBhvr = "0"
  6362. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6363. order.HosplistName = subItem.GoodInfo.GoodName
  6364. order.HilistLv = "1"
  6365. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6366. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6367. order.HosplistName = subItem.GoodInfo.GoodName
  6368. order.Cnt = subItem.Count
  6369. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6370. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6371. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6372. order.OwnpayAmt = ""
  6373. order.SelfpayAmt = ""
  6374. order.Spec = subItem.GoodInfo.SpecificationName
  6375. order.SpecUnt = subItem.Unit
  6376. order.DrordBegnDate = s_tm
  6377. order.DrordStopDate = ""
  6378. order.DrordDrCodg = doctor_info.DoctorNumber
  6379. order.DrordDeptName = department.Name
  6380. order.DrordDeptCodg = department.Number
  6381. order.DrordDrName = doctor_info.UserName
  6382. order.DrordDrProfttl = "234"
  6383. order.CurrDrordFlag = "1"
  6384. orders = append(orders, &order)
  6385. }
  6386. }
  6387. }
  6388. //处方医嘱信息
  6389. }
  6390. fed.MatnStas = "0"
  6391. fed.MedfeeSumamt = "0"
  6392. fed.OwnpayAmt = "0"
  6393. fed.SelfpayAmt = "0"
  6394. fed.AcctPayamt = "0"
  6395. fed.MaAmt = "0"
  6396. fed.HifpPayamt = "0"
  6397. fed.SetlTotlnum = "1"
  6398. fed.Insutype = his.Insutype
  6399. fed.ReimFlag = "0"
  6400. fed.OutSetlFlag = "0"
  6401. var fopd []*models.FsiOperationDtosData
  6402. data := make(map[string]interface{})
  6403. data["fed"] = fed
  6404. data["fdd"] = fdds
  6405. data["fod"] = orders
  6406. data["pd"] = pd
  6407. data["pp"] = pp
  6408. data["fopd"] = fopd
  6409. data["trig_scen"] = trig_scen
  6410. fmt.Println(data)
  6411. fmt.Println(fed)
  6412. fmt.Println(fdds)
  6413. fmt.Println(orders)
  6414. fmt.Println(pd)
  6415. fmt.Println(pp)
  6416. fmt.Println(fopd)
  6417. client := &http.Client{}
  6418. bytesData, _ := json.Marshal(data)
  6419. var req *http.Request
  6420. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6421. if miConfig.MdtrtareaAdmvs == "320921" {
  6422. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6423. } else {
  6424. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6425. }
  6426. resp, _ := client.Do(req)
  6427. defer resp.Body.Close()
  6428. body, ioErr := ioutil.ReadAll(resp.Body)
  6429. if ioErr != nil {
  6430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6432. return res
  6433. }
  6434. var respJSON map[string]interface{}
  6435. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6438. return res
  6439. }
  6440. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6441. fmt.Println(respJSON)
  6442. result, _ := json.Marshal(respJSON)
  6443. fmt.Println(result)
  6444. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6445. utils.ErrorLog("解析失败:%v", err)
  6446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6447. return res
  6448. }
  6449. return res
  6450. } else {
  6451. //if miConfig.MdtrtareaAdmvs == "441202" {
  6452. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6453. saveLog(output, input, "3101", "事前")
  6454. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6455. utils.ErrorLog("解析失败:%v", err)
  6456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6457. return
  6458. }
  6459. return res
  6460. //}
  6461. }
  6462. }
  6463. func Checkgd3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Resultgd3101) {
  6464. adminUser := c.GetAdminUserInfo()
  6465. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6466. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6467. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6468. //record_time := c.GetString("record_time")
  6469. //trig_scen := c.GetString("trig_scen")
  6470. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6471. timeLayout := "2006-01-02"
  6472. loc, _ := time.LoadLocation("Local")
  6473. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6474. if err != nil {
  6475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6476. return res
  6477. }
  6478. recordDateTime := theTime.Unix()
  6479. var patientPrescription models.HisPrescriptionInfo
  6480. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6481. if patientPrescription.ID == 0 {
  6482. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6483. }
  6484. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6485. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6486. //
  6487. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6488. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6489. var pp models.PublicParams
  6490. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6491. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6492. pp.FixmedinsName = miConfig.OrgName
  6493. pp.FixmedinsCode = miConfig.Code
  6494. pp.RequestUrl = miConfig.Url
  6495. pp.Cainfo = miConfig.Cainfo
  6496. pp.SecretKey = miConfig.SecretKey
  6497. pp.AccessKey = miConfig.AccessKey
  6498. pp.OpterName = roles.UserName
  6499. var config []*models.HisXtDiagnoseConfig
  6500. for _, item := range diagnosis_ids {
  6501. id, _ := strconv.ParseInt(item, 10, 64)
  6502. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6503. config = append(config, &diagnosisConfig)
  6504. }
  6505. var pd models.PatientDtos
  6506. pd.PatnID = his.PsnNo
  6507. pd.PatnName = his.Name
  6508. pd.Gend = his.Gend
  6509. pd.Brdy = psn_info.Brdy
  6510. pd.Poolarea = his.InsuplcAdmdvs
  6511. pd.CurrMdtrtID = his.Number
  6512. var fed models.FsiEncounterDtos
  6513. fed.MdtrtID = his.Number
  6514. fed.MedinsID = miConfig.Code
  6515. fed.MedinsName = miConfig.OrgName
  6516. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6517. fed.MedMdtrtType = "1"
  6518. fed.MedinsType = "1"
  6519. fed.MedinsLv = "11"
  6520. tm := time.Unix(his.RecordDate, 0)
  6521. s_tm := tm.Format("2006-01-02 15:04:05")
  6522. fed.AdmDate = s_tm
  6523. fed.DscgDate = s_tm
  6524. fed.DscgMainDiseCodg = config[0].CountryCode
  6525. fed.DscgMainDiseName = config[0].CountryContentName
  6526. //诊断信息
  6527. var fdds []*models.FsiDiagnoseDtos
  6528. for index, item := range config {
  6529. if index == 0 {
  6530. var fdd models.FsiDiagnoseDtos
  6531. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6532. fdd.InoutDiseType = "1"
  6533. fdd.MaindiseFlag = "1"
  6534. fdd.DiseDate = s_tm
  6535. fdd.DiasSrtNo = "1"
  6536. fdd.DiseName = item.CountryContentName
  6537. fdd.DiseCodg = item.CountryCode
  6538. fdds = append(fdds, &fdd)
  6539. } else {
  6540. var fdd models.FsiDiagnoseDtos
  6541. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6542. fdd.InoutDiseType = "1"
  6543. fdd.MaindiseFlag = "1"
  6544. fdd.DiseDate = s_tm
  6545. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6546. fdd.DiseName = item.CountryContentName
  6547. fdd.DiseCodg = item.CountryCode
  6548. fdds = append(fdds, &fdd)
  6549. }
  6550. }
  6551. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6552. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6553. fed.AdmDeptName = department.Name
  6554. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6555. fed.DscgDeptName = department.Name
  6556. fed.MedMdtrtType = "1"
  6557. fed.MedType = "11"
  6558. //if his.Insutype == "390" {
  6559. // fed.MedType = "1402"
  6560. //} else {
  6561. // fed.MedType = "9933"
  6562. //}
  6563. var orders []*models.FsiOrderDtos
  6564. if trig_scen == "2" {
  6565. //处方医嘱信息
  6566. for _, item := range prescriptions {
  6567. for _, subItem := range item.HisDoctorAdviceInfo {
  6568. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6569. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6570. var order models.FsiOrderDtos
  6571. order.RxID = strconv.FormatInt(item.ID, 10)
  6572. order.Rxno = strconv.FormatInt(item.ID, 10)
  6573. order.LongDrordFlag = "0"
  6574. order.HilistType = "1"
  6575. order.ChrgType = "1"
  6576. order.DrordBhvr = "0"
  6577. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6578. order.HosplistName = subItem.BaseDrugLib.DrugName
  6579. order.HilistLv = "1"
  6580. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6581. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6582. order.HosplistName = subItem.BaseDrugLib.DrugName
  6583. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6584. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6585. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6586. order.OwnpayAmt = ""
  6587. order.SelfpayAmt = ""
  6588. order.Spec = spec
  6589. order.SpecUnt = subItem.PrescribingNumberUnit
  6590. order.DrordBegnDate = s_tm
  6591. order.DrordStopDate = ""
  6592. order.DrordDrCodg = doctor_info.DoctorNumber
  6593. order.DrordDeptName = department.Name
  6594. order.DrordDeptCodg = department.Number
  6595. order.DrordDrName = doctor_info.UserName
  6596. order.DrordDrProfttl = "234"
  6597. order.CurrDrordFlag = "1"
  6598. orders = append(orders, &order)
  6599. }
  6600. }
  6601. for _, subItem := range item.HisPrescriptionProject {
  6602. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6603. var order models.FsiOrderDtos
  6604. order.RxID = strconv.FormatInt(item.ID, 10)
  6605. order.Rxno = strconv.FormatInt(item.ID, 10)
  6606. order.LongDrordFlag = "0"
  6607. order.HilistType = "1"
  6608. order.ChrgType = "1"
  6609. order.DrordBhvr = "0"
  6610. order.HilistCode = subItem.HisProject.MedicalCode
  6611. order.HosplistName = subItem.HisProject.ProjectName
  6612. order.HilistLv = "1"
  6613. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6614. order.HosplistCode = subItem.HisProject.MedicalCode
  6615. order.HosplistName = subItem.HisProject.ProjectName
  6616. order.Cnt = subItem.Count
  6617. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6618. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6619. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6620. order.OwnpayAmt = ""
  6621. order.SelfpayAmt = ""
  6622. order.Spec = subItem.Unit
  6623. order.SpecUnt = subItem.Unit
  6624. order.DrordBegnDate = s_tm
  6625. order.DrordStopDate = ""
  6626. order.DrordDrCodg = doctor_info.DoctorNumber
  6627. order.DrordDeptName = department.Name
  6628. order.DrordDeptCodg = department.Number
  6629. order.DrordDrName = doctor_info.UserName
  6630. order.DrordDrProfttl = "234"
  6631. order.CurrDrordFlag = "1"
  6632. orders = append(orders, &order)
  6633. }
  6634. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6635. var order models.FsiOrderDtos
  6636. order.RxID = strconv.FormatInt(item.ID, 10)
  6637. order.Rxno = strconv.FormatInt(item.ID, 10)
  6638. order.LongDrordFlag = "0"
  6639. order.HilistType = "1"
  6640. order.ChrgType = "1"
  6641. order.DrordBhvr = "0"
  6642. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6643. order.HosplistName = subItem.GoodInfo.GoodName
  6644. order.HilistLv = "1"
  6645. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6646. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6647. order.HosplistName = subItem.GoodInfo.GoodName
  6648. order.Cnt = subItem.Count
  6649. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6650. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6651. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6652. order.OwnpayAmt = ""
  6653. order.SelfpayAmt = ""
  6654. order.Spec = subItem.GoodInfo.SpecificationName
  6655. order.SpecUnt = subItem.Unit
  6656. order.DrordBegnDate = s_tm
  6657. order.DrordStopDate = ""
  6658. order.DrordDrCodg = doctor_info.DoctorNumber
  6659. order.DrordDeptName = department.Name
  6660. order.DrordDeptCodg = department.Number
  6661. order.DrordDrName = doctor_info.UserName
  6662. order.DrordDrProfttl = "234"
  6663. order.CurrDrordFlag = "1"
  6664. orders = append(orders, &order)
  6665. }
  6666. }
  6667. }
  6668. //处方医嘱信息
  6669. }
  6670. fed.MatnStas = "0"
  6671. fed.MedfeeSumamt = "0"
  6672. fed.OwnpayAmt = "0"
  6673. fed.SelfpayAmt = "0"
  6674. fed.AcctPayamt = "0"
  6675. fed.MaAmt = "0"
  6676. fed.HifpPayamt = "0"
  6677. fed.SetlTotlnum = "1"
  6678. fed.Insutype = his.Insutype
  6679. fed.ReimFlag = "0"
  6680. fed.OutSetlFlag = "0"
  6681. var fopd []*models.FsiOperationDtosData
  6682. data := make(map[string]interface{})
  6683. data["fed"] = fed
  6684. data["fdd"] = fdds
  6685. data["fod"] = orders
  6686. data["pd"] = pd
  6687. data["pp"] = pp
  6688. data["fopd"] = fopd
  6689. data["trig_scen"] = trig_scen
  6690. fmt.Println(data)
  6691. fmt.Println(fed)
  6692. fmt.Println(fdds)
  6693. fmt.Println(orders)
  6694. fmt.Println(pd)
  6695. fmt.Println(pp)
  6696. fmt.Println(fopd)
  6697. client := &http.Client{}
  6698. bytesData, _ := json.Marshal(data)
  6699. var req *http.Request
  6700. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6701. if miConfig.MdtrtareaAdmvs == "320921" {
  6702. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6703. } else {
  6704. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6705. }
  6706. resp, _ := client.Do(req)
  6707. defer resp.Body.Close()
  6708. body, ioErr := ioutil.ReadAll(resp.Body)
  6709. if ioErr != nil {
  6710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6712. return res
  6713. }
  6714. var respJSON map[string]interface{}
  6715. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6718. return res
  6719. }
  6720. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6721. fmt.Println(respJSON)
  6722. result, _ := json.Marshal(respJSON)
  6723. fmt.Println(result)
  6724. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6725. utils.ErrorLog("解析失败:%v", err)
  6726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6727. return res
  6728. }
  6729. return res
  6730. } else {
  6731. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6732. saveLog(output, input, "3101", "事前")
  6733. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6734. utils.ErrorLog("解析失败:%v", err)
  6735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6736. return
  6737. }
  6738. return res
  6739. }
  6740. return res
  6741. }
  6742. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6743. ////patient_id, _ := c.GetInt64("patient_id")
  6744. //order_id, _ := c.GetInt64("order_id")
  6745. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6746. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6747. //trig_scen := c.GetString("trig_scen")
  6748. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6749. utils.ErrorLog("解析失败:%v", psn_info)
  6750. adminUser := c.GetAdminUserInfo()
  6751. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6752. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6753. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6754. record_time := c.GetString("record_time")
  6755. order, _ := service.GetHisOrderByID(order_id)
  6756. timeLayout := "2006-01-02"
  6757. loc, _ := time.LoadLocation("Local")
  6758. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6759. if err != nil {
  6760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6761. return
  6762. }
  6763. recordDateTime := theTime.Unix()
  6764. var patientPrescription models.HisPrescriptionInfo
  6765. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6766. if patientPrescription.ID == 0 {
  6767. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6768. }
  6769. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6770. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6771. //
  6772. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6773. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6774. var pp models.PublicParams
  6775. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6776. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6777. pp.FixmedinsName = miConfig.OrgName
  6778. pp.FixmedinsCode = miConfig.Code
  6779. pp.RequestUrl = miConfig.Url
  6780. pp.Cainfo = miConfig.Cainfo
  6781. pp.SecretKey = miConfig.SecretKey
  6782. pp.AccessKey = miConfig.AccessKey
  6783. pp.OpterName = roles.UserName
  6784. var config []*models.HisXtDiagnoseConfig
  6785. for _, item := range diagnosis_ids {
  6786. id, _ := strconv.ParseInt(item, 10, 64)
  6787. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6788. config = append(config, &diagnosisConfig)
  6789. }
  6790. var pd models.PatientDtos
  6791. pd.PatnID = his.PsnNo
  6792. pd.PatnName = his.Name
  6793. pd.Gend = his.Gend
  6794. pd.Brdy = psn_info.Brdy
  6795. pd.Poolarea = his.InsuplcAdmdvs
  6796. pd.CurrMdtrtID = his.Number
  6797. var fed models.FsiEncounterDtos
  6798. fed.MdtrtID = his.Number
  6799. fed.MedinsID = miConfig.Code
  6800. fed.MedinsName = miConfig.OrgName
  6801. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6802. fed.MedMdtrtType = "1"
  6803. fed.MedinsType = "1"
  6804. fed.MedinsLv = "11"
  6805. tm := time.Unix(his.RecordDate, 0)
  6806. s_tm := tm.Format("2006-01-02 15:04:05")
  6807. fed.AdmDate = s_tm
  6808. fed.DscgDate = s_tm
  6809. fed.DscgMainDiseCodg = config[0].CountryCode
  6810. fed.DscgMainDiseName = config[0].CountryContentName
  6811. //诊断信息
  6812. var fdds []*models.FsiDiagnoseDtos
  6813. for index, item := range config {
  6814. if index == 0 {
  6815. var fdd models.FsiDiagnoseDtos
  6816. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6817. fdd.InoutDiseType = "1"
  6818. fdd.MaindiseFlag = "1"
  6819. fdd.DiseDate = s_tm
  6820. fdd.DiasSrtNo = "1"
  6821. fdd.DiseName = item.CountryContentName
  6822. fdd.DiseCodg = item.CountryCode
  6823. fdds = append(fdds, &fdd)
  6824. } else {
  6825. var fdd models.FsiDiagnoseDtos
  6826. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6827. fdd.InoutDiseType = "1"
  6828. fdd.MaindiseFlag = "1"
  6829. fdd.DiseDate = s_tm
  6830. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6831. fdd.DiseName = item.CountryContentName
  6832. fdd.DiseCodg = item.CountryCode
  6833. fdds = append(fdds, &fdd)
  6834. }
  6835. }
  6836. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6837. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6838. fed.AdmDeptName = department.Name
  6839. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6840. fed.DscgDeptName = department.Name
  6841. fed.MedType = order.MedType
  6842. //处方医嘱信息
  6843. var orders []*models.FsiOrderDtos
  6844. //for _, item := range prescriptions {
  6845. // for _, subItem := range item.HisDoctorAdviceInfo {
  6846. // var order models.FsiOrderDtos
  6847. // order.RxID = strconv.FormatInt(item.ID, 10)
  6848. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6849. // order.LongDrordFlag = "0"
  6850. // order.HilistType = "1"
  6851. // order.ChrgType = "1"
  6852. // order.DrordBhvr = "-"
  6853. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6854. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6855. // order.HilistLv = "1"
  6856. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6857. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6858. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6859. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6860. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6861. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6862. // order.OwnpayAmt = ""
  6863. // order.SelfpayAmt = ""
  6864. // order.Spec = ""
  6865. // order.SpecUnt = ""
  6866. // order.DrordBegnDate = s_tm
  6867. // order.DrordStopDate = ""
  6868. // order.DrordDrCodg = "1"
  6869. // order.DrordDeptName = department.Name
  6870. // order.DrordDrCodg = "1"
  6871. // order.DrordDrName = doctor_info.UserName
  6872. // order.DrordDrProfttl = ""
  6873. // order.CurrDrordFlag = "1"
  6874. // orders = append(orders, &order)
  6875. // }
  6876. // for _, subItem := range item.HisPrescriptionProject {
  6877. // if subItem.Type == 2 {
  6878. // var order models.FsiOrderDtos
  6879. // order.RxID = strconv.FormatInt(item.ID, 10)
  6880. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6881. // order.LongDrordFlag = "0"
  6882. // order.HilistType = "1"
  6883. // order.ChrgType = "1"
  6884. // order.DrordBhvr = "-"
  6885. // order.HilistCode = subItem.HisProject.MedicalCode
  6886. // order.HosplistName = subItem.HisProject.ProjectName
  6887. // order.HilistLv = "1"
  6888. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6889. // order.HosplistCode = subItem.HisProject.MedicalCode
  6890. // order.HosplistName = subItem.HisProject.ProjectName
  6891. // order.Cnt = subItem.Count
  6892. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6893. //
  6894. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6895. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6896. // order.OwnpayAmt = ""
  6897. // order.SelfpayAmt = ""
  6898. // order.Spec = ""
  6899. // order.SpecUnt = ""
  6900. // order.DrordBegnDate = s_tm
  6901. // order.DrordStopDate = ""
  6902. // order.DrordDrCodg = "1"
  6903. // order.DrordDeptName = department.Name
  6904. // order.DrordDrCodg = "1"
  6905. // order.DrordDrName = doctor_info.UserName
  6906. // order.DrordDrProfttl = ""
  6907. // order.CurrDrordFlag = "1"
  6908. // orders = append(orders, &order)
  6909. //
  6910. // }
  6911. // if subItem.Type == 3 {
  6912. //
  6913. // var order models.FsiOrderDtos
  6914. // order.RxID = strconv.FormatInt(item.ID, 10)
  6915. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6916. // order.LongDrordFlag = "0"
  6917. // order.HilistType = "1"
  6918. // order.ChrgType = "1"
  6919. // order.DrordBhvr = "-"
  6920. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6921. // order.HosplistName = subItem.GoodInfo.GoodName
  6922. // order.HilistLv = "1"
  6923. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6924. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6925. // order.HosplistName = subItem.GoodInfo.GoodName
  6926. // order.Cnt = subItem.Count
  6927. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6928. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6929. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6930. // order.OwnpayAmt = ""
  6931. // order.SelfpayAmt = ""
  6932. // order.Spec = ""
  6933. // order.SpecUnt = ""
  6934. // order.DrordBegnDate = s_tm
  6935. // order.DrordStopDate = ""
  6936. // order.DrordDrCodg = "1"
  6937. // order.DrordDeptName = department.Name
  6938. // order.DrordDrCodg = "1"
  6939. // order.DrordDrName = doctor_info.UserName
  6940. // order.DrordDrProfttl = ""
  6941. // order.CurrDrordFlag = "1"
  6942. // orders = append(orders, &order)
  6943. //
  6944. // }
  6945. // }
  6946. //}
  6947. for _, item := range prescriptions {
  6948. for _, subItem := range item.HisDoctorAdviceInfo {
  6949. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6950. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6951. var order models.FsiOrderDtos
  6952. order.RxID = strconv.FormatInt(item.ID, 10)
  6953. order.Rxno = strconv.FormatInt(item.ID, 10)
  6954. order.LongDrordFlag = "0"
  6955. order.HilistType = "1"
  6956. order.ChrgType = "1"
  6957. order.DrordBhvr = "0"
  6958. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6959. order.HosplistName = subItem.BaseDrugLib.DrugName
  6960. order.HilistLv = "1"
  6961. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6962. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6963. order.HosplistName = subItem.BaseDrugLib.DrugName
  6964. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6965. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6966. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6967. order.OwnpayAmt = ""
  6968. order.SelfpayAmt = ""
  6969. order.Spec = spec
  6970. order.SpecUnt = subItem.PrescribingNumberUnit
  6971. order.DrordBegnDate = s_tm
  6972. order.DrordStopDate = ""
  6973. order.DrordDrCodg = doctor_info.DoctorNumber
  6974. order.DrordDeptName = department.Name
  6975. order.DrordDeptCodg = department.Number
  6976. order.DrordDrName = doctor_info.UserName
  6977. order.DrordDrProfttl = "234"
  6978. order.CurrDrordFlag = "1"
  6979. orders = append(orders, &order)
  6980. }
  6981. }
  6982. for _, subItem := range item.HisPrescriptionProject {
  6983. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6984. var order models.FsiOrderDtos
  6985. order.RxID = strconv.FormatInt(item.ID, 10)
  6986. order.Rxno = strconv.FormatInt(item.ID, 10)
  6987. order.LongDrordFlag = "0"
  6988. order.HilistType = "1"
  6989. order.ChrgType = "1"
  6990. order.DrordBhvr = "0"
  6991. order.HilistCode = subItem.HisProject.MedicalCode
  6992. order.HosplistName = subItem.HisProject.ProjectName
  6993. order.HilistLv = "1"
  6994. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6995. order.HosplistCode = subItem.HisProject.MedicalCode
  6996. order.HosplistName = subItem.HisProject.ProjectName
  6997. order.Cnt = subItem.Count
  6998. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6999. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7000. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7001. order.OwnpayAmt = ""
  7002. order.SelfpayAmt = ""
  7003. order.Spec = subItem.Unit
  7004. order.SpecUnt = subItem.Unit
  7005. order.DrordBegnDate = s_tm
  7006. order.DrordStopDate = ""
  7007. order.DrordDrCodg = doctor_info.DoctorNumber
  7008. order.DrordDeptName = department.Name
  7009. order.DrordDeptCodg = department.Number
  7010. order.DrordDrName = doctor_info.UserName
  7011. order.DrordDrProfttl = "234"
  7012. order.CurrDrordFlag = "1"
  7013. orders = append(orders, &order)
  7014. }
  7015. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  7016. var order models.FsiOrderDtos
  7017. order.RxID = strconv.FormatInt(item.ID, 10)
  7018. order.Rxno = strconv.FormatInt(item.ID, 10)
  7019. order.LongDrordFlag = "0"
  7020. order.HilistType = "1"
  7021. order.ChrgType = "1"
  7022. order.DrordBhvr = "0"
  7023. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7024. order.HosplistName = subItem.GoodInfo.GoodName
  7025. order.HilistLv = "1"
  7026. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7027. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7028. order.HosplistName = subItem.GoodInfo.GoodName
  7029. order.Cnt = subItem.Count
  7030. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7031. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7032. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7033. order.OwnpayAmt = ""
  7034. order.SelfpayAmt = ""
  7035. order.Spec = subItem.GoodInfo.SpecificationName
  7036. order.SpecUnt = subItem.Unit
  7037. order.DrordBegnDate = s_tm
  7038. order.DrordStopDate = ""
  7039. order.DrordDrCodg = doctor_info.DoctorNumber
  7040. order.DrordDeptName = department.Name
  7041. order.DrordDeptCodg = department.Number
  7042. order.DrordDrName = doctor_info.UserName
  7043. order.DrordDrProfttl = "234"
  7044. order.CurrDrordFlag = "1"
  7045. orders = append(orders, &order)
  7046. }
  7047. }
  7048. }
  7049. //处方医嘱信息
  7050. fed.MatnStas = "0"
  7051. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  7052. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  7053. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  7054. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  7055. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  7056. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  7057. fed.SetlTotlnum = "1"
  7058. fed.Insutype = his.Insutype
  7059. fed.ReimFlag = "0"
  7060. fed.OutSetlFlag = "0"
  7061. var fopd []*models.FsiOperationDtosData
  7062. data := make(map[string]interface{})
  7063. data["fed"] = fed
  7064. data["fdd"] = fdds
  7065. data["fod"] = orders
  7066. data["pd"] = pd
  7067. data["pp"] = pp
  7068. data["fopd"] = fopd
  7069. data["trig_scen"] = trig_scen
  7070. client := &http.Client{}
  7071. bytesData, _ := json.Marshal(data)
  7072. var req *http.Request
  7073. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7074. if miConfig.MdtrtareaAdmvs == "320921" {
  7075. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7076. } else {
  7077. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7078. }
  7079. resp, _ := client.Do(req)
  7080. defer resp.Body.Close()
  7081. body, ioErr := ioutil.ReadAll(resp.Body)
  7082. if ioErr != nil {
  7083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7085. return res
  7086. }
  7087. var respJSON map[string]interface{}
  7088. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7091. return res
  7092. }
  7093. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7094. result, _ := json.Marshal(respJSON)
  7095. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7096. utils.ErrorLog("解析失败:%v", err)
  7097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7098. return res
  7099. }
  7100. return res
  7101. } else {
  7102. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7103. saveLog(output, input, "3102", "事中")
  7104. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7105. utils.ErrorLog("解析失败:%v", err)
  7106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7107. return
  7108. }
  7109. return res
  7110. }
  7111. return res
  7112. }
  7113. func (c *HisApiController) Check() {
  7114. psn_no := c.GetString("psn_no")
  7115. in := c.GetString("in")
  7116. mt := c.GetString("mt")
  7117. baseParams := models.BaseParams{
  7118. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  7119. FixmedinsCode: "H15049901371",
  7120. InsuplcAdmdvs: "150499",
  7121. MdtrtareaAdmvs: "150499",
  7122. OrgName: "赤峰费森血液透析中心",
  7123. Doctor: "1111",
  7124. }
  7125. service.Gdyb2001(baseParams, psn_no, in, mt)
  7126. }
  7127. func (c *HisApiController) GetPsnNcdsInfo() {
  7128. admin_user_id, _ := c.GetInt64("admin_user_id")
  7129. patient_id, _ := c.GetInt64("patient_id")
  7130. //id, _ := c.GetInt64("id")
  7131. adminUser := c.GetAdminUserInfo()
  7132. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7133. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7134. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7135. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7136. //psn_record, _ := service.GetP(id)
  7137. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7138. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  7139. //
  7140. //if psn_record.ID == 0 {
  7141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7142. // return
  7143. //}
  7144. var res Result5301
  7145. var res10265 Result5301For10265
  7146. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7147. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7148. var api string
  7149. if miConfig.MdtrtareaAdmvs == "320921" {
  7150. api = "http://192.168.2.3:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  7151. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7152. } else {
  7153. 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 +
  7154. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7155. }
  7156. resp, requestErr := http.Get(api)
  7157. if requestErr != nil {
  7158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7159. return
  7160. }
  7161. body, ioErr := ioutil.ReadAll(resp.Body)
  7162. if ioErr != nil {
  7163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7165. return
  7166. }
  7167. var respJSON map[string]interface{}
  7168. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7171. return
  7172. }
  7173. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7174. result, _ := json.Marshal(respJSON)
  7175. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7176. utils.ErrorLog("解析失败:%v", err)
  7177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7178. return
  7179. }
  7180. res.ErrMsg = res10265.ErrMsg
  7181. res.Output = res10265.Output
  7182. res.InfRefmsgid = res10265.InfRefmsgid
  7183. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7184. res.Infcode = infocode
  7185. } else if miConfig.MdtrtareaAdmvs == "341203" {
  7186. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7187. var api string
  7188. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  7189. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7190. resp, requestErr := http.Get(api)
  7191. if requestErr != nil {
  7192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7193. return
  7194. }
  7195. body, ioErr := ioutil.ReadAll(resp.Body)
  7196. if ioErr != nil {
  7197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7199. return
  7200. }
  7201. var respJSON map[string]interface{}
  7202. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7205. return
  7206. }
  7207. status := respJSON["data"].(map[string]interface{})["status"].(string)
  7208. if status == "0" {
  7209. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  7210. c.ServeSuccessJSON(map[string]interface{}{
  7211. "failed_code": -10,
  7212. "msg": err_msg,
  7213. })
  7214. return
  7215. }
  7216. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7217. result, _ := json.Marshal(respJSON)
  7218. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7219. utils.ErrorLog("解析失败:%v", err)
  7220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7221. return
  7222. }
  7223. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7224. p, _ := service.GetHisPatientById(patient_id)
  7225. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7226. var dat map[string]interface{}
  7227. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7228. fmt.Println(dat)
  7229. } else {
  7230. fmt.Println(err)
  7231. }
  7232. userJSONBytes, _ := json.Marshal(dat)
  7233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7234. utils.ErrorLog("解析失败:%v", err)
  7235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7236. return
  7237. }
  7238. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7239. p, _ := service.GetHisPatientById(patient_id)
  7240. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7241. var dat map[string]interface{}
  7242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7243. fmt.Println(dat)
  7244. } else {
  7245. fmt.Println(err)
  7246. }
  7247. userJSONBytes, _ := json.Marshal(dat)
  7248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7249. utils.ErrorLog("解析失败:%v", err)
  7250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7251. return
  7252. }
  7253. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7254. p, _ := service.GetHisPatientById(patient_id)
  7255. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7256. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7257. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7258. resp, requestErr := http.Get(api)
  7259. if requestErr != nil {
  7260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7261. return
  7262. }
  7263. body, ioErr := ioutil.ReadAll(resp.Body)
  7264. if ioErr != nil {
  7265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7267. return
  7268. }
  7269. var respJSON map[string]interface{}
  7270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7273. return
  7274. }
  7275. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7276. result, _ := json.Marshal(respJSON)
  7277. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7278. utils.ErrorLog("解析失败:%v", err)
  7279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7280. return
  7281. }
  7282. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7283. p, _ := service.GetHisPatientById(patient_id)
  7284. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  7285. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7286. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7287. resp, requestErr := http.Get(api)
  7288. if requestErr != nil {
  7289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7290. return
  7291. }
  7292. body, ioErr := ioutil.ReadAll(resp.Body)
  7293. if ioErr != nil {
  7294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7296. return
  7297. }
  7298. var respJSON map[string]interface{}
  7299. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7302. return
  7303. }
  7304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7305. result, _ := json.Marshal(respJSON)
  7306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7307. utils.ErrorLog("解析失败:%v", err)
  7308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7309. return
  7310. }
  7311. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7312. p, _ := service.GetHisPatientById(patient_id)
  7313. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7314. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7315. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7316. resp, requestErr := http.Get(api)
  7317. if requestErr != nil {
  7318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7319. return
  7320. }
  7321. body, ioErr := ioutil.ReadAll(resp.Body)
  7322. if ioErr != nil {
  7323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7325. return
  7326. }
  7327. var respJSON map[string]interface{}
  7328. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7331. return
  7332. }
  7333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7334. result, _ := json.Marshal(respJSON)
  7335. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7336. utils.ErrorLog("解析失败:%v", err)
  7337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7338. return
  7339. }
  7340. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7341. p, _ := service.GetHisPatientById(patient_id)
  7342. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7343. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7345. resp, requestErr := http.Get(api)
  7346. if requestErr != nil {
  7347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7348. return
  7349. }
  7350. body, ioErr := ioutil.ReadAll(resp.Body)
  7351. if ioErr != nil {
  7352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7354. return
  7355. }
  7356. var respJSON map[string]interface{}
  7357. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7360. return
  7361. }
  7362. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7363. result, _ := json.Marshal(respJSON)
  7364. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7365. utils.ErrorLog("解析失败:%v", err)
  7366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7367. return
  7368. }
  7369. } else if miConfig.MdtrtareaAdmvs == "421300" {
  7370. p, _ := service.GetHisPatientById(patient_id)
  7371. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7372. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7373. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7374. resp, requestErr := http.Get(api)
  7375. if requestErr != nil {
  7376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7377. return
  7378. }
  7379. body, ioErr := ioutil.ReadAll(resp.Body)
  7380. if ioErr != nil {
  7381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7383. return
  7384. }
  7385. var respJSON map[string]interface{}
  7386. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7389. return
  7390. }
  7391. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7392. result, _ := json.Marshal(respJSON)
  7393. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7394. utils.ErrorLog("解析失败:%v", err)
  7395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7396. return
  7397. }
  7398. } else if miConfig.MdtrtareaAdmvs == "441799" {
  7399. p, _ := service.GetHisPatientById(patient_id)
  7400. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  7401. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7402. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7403. resp, requestErr := http.Get(api)
  7404. if requestErr != nil {
  7405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7406. return
  7407. }
  7408. body, ioErr := ioutil.ReadAll(resp.Body)
  7409. if ioErr != nil {
  7410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7412. return
  7413. }
  7414. var respJSON map[string]interface{}
  7415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7418. return
  7419. }
  7420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7421. result, _ := json.Marshal(respJSON)
  7422. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7423. utils.ErrorLog("解析失败:%v", err)
  7424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7425. return
  7426. }
  7427. } else {
  7428. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  7429. var dat map[string]interface{}
  7430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7431. fmt.Println(dat)
  7432. } else {
  7433. fmt.Println(err)
  7434. }
  7435. userJSONBytes, _ := json.Marshal(dat)
  7436. if miConfig.Code == "H15049901371" {
  7437. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7438. utils.ErrorLog("解析失败:%v", err)
  7439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7440. return
  7441. }
  7442. res.InfRefmsgid = res10265.InfRefmsgid
  7443. res.Output = res10265.Output
  7444. res.ErrMsg = res10265.ErrMsg
  7445. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7446. res.Infcode = infocode
  7447. } else {
  7448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7449. utils.ErrorLog("解析失败:%v", err)
  7450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7451. return
  7452. }
  7453. }
  7454. }
  7455. if res.Infcode == 0 {
  7456. c.ServeSuccessJSON(map[string]interface{}{
  7457. "result": res.Output.Result,
  7458. })
  7459. }
  7460. }
  7461. func (c *HisApiController) CheckInsutype() {
  7462. his_patient_id, _ := c.GetInt64("his_patient_id")
  7463. admin_user_id, _ := c.GetInt64("admin_user_id")
  7464. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7465. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7466. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7467. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7468. var dat map[string]interface{}
  7469. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7470. fmt.Println(dat)
  7471. } else {
  7472. fmt.Println(err)
  7473. }
  7474. userJSONBytes, _ := json.Marshal(dat)
  7475. var res Result90100
  7476. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7477. utils.ErrorLog("解析失败:%v", err)
  7478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7479. return
  7480. }
  7481. if res.Infcode != 0 {
  7482. c.ServeSuccessJSON(map[string]interface{}{
  7483. "failed_code": -10,
  7484. "msg": res.ErrMsg,
  7485. })
  7486. return
  7487. } else {
  7488. fmt.Println(res)
  7489. }
  7490. }
  7491. func (c *HisApiController) CheckCardPWD() {
  7492. card_pwd := c.GetString("card_pwd")
  7493. his_patient_id, _ := c.GetInt64("his_patient_id")
  7494. admin_user_id, _ := c.GetInt64("admin_user_id")
  7495. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7496. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7497. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7498. psn, _ := service.GetPsnByPatientId(his.PatientId)
  7499. bas := strings.Split(psn.CardInfo, "|")
  7500. basNumber := bas[2]
  7501. if psn.InsuplcAdmdvs[:4] == "4403" {
  7502. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  7503. var dat map[string]interface{}
  7504. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7505. fmt.Println(dat)
  7506. } else {
  7507. fmt.Println(err)
  7508. }
  7509. userJSONBytes, _ := json.Marshal(dat)
  7510. var res Result90991
  7511. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7512. utils.ErrorLog("解析失败:%v", err)
  7513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7514. return
  7515. }
  7516. if res.Infcode != 0 {
  7517. c.ServeSuccessJSON(map[string]interface{}{
  7518. "failed_code": -10,
  7519. "msg": res.ErrMsg,
  7520. })
  7521. return
  7522. } else {
  7523. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  7524. var msg string
  7525. switch res.Output.Result.CardStat {
  7526. case "00":
  7527. msg = "未激活"
  7528. break
  7529. case "10":
  7530. msg = "激活"
  7531. break
  7532. case "20":
  7533. msg = "窗口挂失"
  7534. break
  7535. case "21":
  7536. msg = "电话挂失"
  7537. break
  7538. case "22":
  7539. msg = "单位网上申报挂失"
  7540. break
  7541. case "23":
  7542. msg = "保健办挂失"
  7543. break
  7544. case "24":
  7545. msg = "个人网上挂失"
  7546. break
  7547. case "25":
  7548. msg = "网上服务大厅挂失"
  7549. break
  7550. case "30":
  7551. msg = "注销"
  7552. break
  7553. case "40":
  7554. msg = "回收"
  7555. break
  7556. case "99":
  7557. msg = "制卡中(无效卡)"
  7558. break
  7559. }
  7560. c.ServeSuccessJSON(map[string]interface{}{
  7561. "failed_code": -10,
  7562. "msg": msg,
  7563. })
  7564. return
  7565. } else {
  7566. c.ServeSuccessJSON(map[string]interface{}{
  7567. "msg": "校验成功",
  7568. })
  7569. return
  7570. }
  7571. }
  7572. } else {
  7573. c.ServeSuccessJSON(map[string]interface{}{
  7574. "msg": "校验成功",
  7575. })
  7576. return
  7577. }
  7578. }
  7579. func (c *HisApiController) CheckCardPWDTwo() {
  7580. //card_pwd := c.GetString("card_pwd")
  7581. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7582. admin_user_id, _ := c.GetInt64("admin_user_id")
  7583. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7584. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7585. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  7586. var dat map[string]interface{}
  7587. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7588. fmt.Println(dat)
  7589. } else {
  7590. fmt.Println(err)
  7591. }
  7592. userJSONBytes, _ := json.Marshal(dat)
  7593. var res Result90991
  7594. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7595. utils.ErrorLog("解析失败:%v", err)
  7596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7597. return
  7598. }
  7599. if res.Infcode != 0 {
  7600. c.ServeSuccessJSON(map[string]interface{}{
  7601. "failed_code": -10,
  7602. "msg": res.ErrMsg,
  7603. })
  7604. return
  7605. } else {
  7606. if res.Output.Result.SscnoCheckStat == "0" {
  7607. var msg string
  7608. switch res.Output.Result.CardStat {
  7609. case "00":
  7610. msg = "未激活"
  7611. break
  7612. case "10":
  7613. msg = "激活"
  7614. break
  7615. case "20":
  7616. msg = "窗口挂失"
  7617. break
  7618. case "21":
  7619. msg = "电话挂失"
  7620. break
  7621. case "22":
  7622. msg = "单位网上申报挂失"
  7623. break
  7624. case "23":
  7625. msg = "保健办挂失"
  7626. break
  7627. case "24":
  7628. msg = "个人网上挂失"
  7629. break
  7630. case "25":
  7631. msg = "网上服务大厅挂失"
  7632. break
  7633. case "30":
  7634. msg = "注销"
  7635. break
  7636. case "40":
  7637. msg = "回收"
  7638. break
  7639. case "99":
  7640. msg = "制卡中(无效卡)"
  7641. break
  7642. }
  7643. c.ServeSuccessJSON(map[string]interface{}{
  7644. "failed_code": -10,
  7645. "msg": msg,
  7646. })
  7647. return
  7648. } else {
  7649. c.ServeSuccessJSON(map[string]interface{}{
  7650. "msg": "校验成功",
  7651. })
  7652. return
  7653. }
  7654. }
  7655. }
  7656. type ELeCertData struct {
  7657. Data struct {
  7658. Extra string `json:"extra"`
  7659. IDNo string `json:"idNo"`
  7660. IDType string `json:"idType"`
  7661. EcToken string `json:"ecToken"`
  7662. InsuOrg string `json:"insuOrg"`
  7663. UserName string `json:"userName"`
  7664. EcIndexNo string `json:"ecIndexNo"`
  7665. Gender string `json:"gender"`
  7666. Birthday string `json:"birthday"`
  7667. Nationality string `json:"nationality"`
  7668. Email string `json:"email"`
  7669. } `json:"OutData"`
  7670. }
  7671. func (c *HisApiController) ReadCard() {
  7672. id_card_type, _ := c.GetInt64("id_card_type")
  7673. admin_user_id, _ := c.GetInt64("admin_user_id")
  7674. certificates, _ := c.GetInt64("certificates")
  7675. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7676. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7677. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7678. switch id_card_type {
  7679. case 1:
  7680. if miConfig.MdtrtareaAdmvs == "421300" {
  7681. var res ResultTwo
  7682. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7683. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7684. "&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)
  7685. resp, requestErr := http.Get(api)
  7686. if requestErr != nil {
  7687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7688. return
  7689. }
  7690. body, ioErr := ioutil.ReadAll(resp.Body)
  7691. if ioErr != nil {
  7692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7694. return
  7695. }
  7696. var respJSON map[string]interface{}
  7697. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7700. return
  7701. }
  7702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7703. result, _ := json.Marshal(respJSON)
  7704. fmt.Println("log")
  7705. fmt.Println(string(result))
  7706. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7707. utils.ErrorLog("解析失败:%v", err)
  7708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7709. return
  7710. }
  7711. if res.Infcode == 0 {
  7712. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7713. if err == gorm.ErrRecordNotFound {
  7714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7715. return
  7716. } else if err != nil {
  7717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7718. return
  7719. } else {
  7720. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7721. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7722. infoStr := string(Iinfos)
  7723. idetinfoStr := string(Idetinfos)
  7724. var rf []*ResultFive
  7725. json.Unmarshal([]byte(infoStr), &rf)
  7726. var insutypes []*ResultFive
  7727. var insutype string
  7728. var is390 int = 0
  7729. var is310 int = 0
  7730. for _, item := range rf {
  7731. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7732. insutypes = append(insutypes, item)
  7733. }
  7734. }
  7735. if len(insutypes) == 1 {
  7736. insutype = insutypes[0].Insutype
  7737. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7738. } else {
  7739. for _, i := range insutypes {
  7740. if i.Insutype == "390" {
  7741. is390 = 1
  7742. }
  7743. if i.Insutype == "310" {
  7744. is310 = 1
  7745. }
  7746. }
  7747. }
  7748. if is390 == 1 {
  7749. insutype = "390"
  7750. }
  7751. if is310 == 1 {
  7752. insutype = "310"
  7753. }
  7754. if len(insutypes) == 0 {
  7755. insutype = "390"
  7756. }
  7757. var insuplc_admdvs string
  7758. for _, item := range rf {
  7759. if item.Insutype == insutype {
  7760. insuplc_admdvs = item.InsuplcAdmdvs
  7761. }
  7762. }
  7763. if strings.Contains(insuplc_admdvs, "4213") {
  7764. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7765. }
  7766. psn := &models.HisPsn{
  7767. PsnNo: res.Output.Baseinfo.PsnNo,
  7768. PatientId: patient.ID,
  7769. Certno: res.Output.Baseinfo.Certno,
  7770. Gend: res.Output.Baseinfo.Gend,
  7771. Naty: res.Output.Baseinfo.Naty,
  7772. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7773. PsnName: res.Output.Baseinfo.PsnName,
  7774. Idetinfo: idetinfoStr,
  7775. Insuinfo: infoStr,
  7776. InsuplcAdmdvs: insuplc_admdvs,
  7777. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7778. }
  7779. service.CreateHisPsn(psn)
  7780. c.ServeSuccessJSON(map[string]interface{}{
  7781. "patient": patient,
  7782. "number": res.Output.Baseinfo.Certno,
  7783. })
  7784. }
  7785. } else {
  7786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7787. return
  7788. }
  7789. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7790. var res ResultTwo
  7791. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7792. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7793. "&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)
  7794. resp, requestErr := http.Get(api)
  7795. if requestErr != nil {
  7796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7797. return
  7798. }
  7799. body, ioErr := ioutil.ReadAll(resp.Body)
  7800. if ioErr != nil {
  7801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7803. return
  7804. }
  7805. var respJSON map[string]interface{}
  7806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7809. return
  7810. }
  7811. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7812. result, _ := json.Marshal(respJSON)
  7813. fmt.Println("log")
  7814. fmt.Println(string(result))
  7815. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7816. utils.ErrorLog("解析失败:%v", err)
  7817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7818. return
  7819. }
  7820. if res.Infcode == 0 {
  7821. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7822. if err == gorm.ErrRecordNotFound {
  7823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7824. return
  7825. } else if err != nil {
  7826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7827. return
  7828. } else {
  7829. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7830. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7831. infoStr := string(Iinfos)
  7832. idetinfoStr := string(Idetinfos)
  7833. psn := &models.HisPsn{
  7834. PsnNo: res.Output.Baseinfo.PsnNo,
  7835. PatientId: patient.ID,
  7836. Certno: res.Output.Baseinfo.Certno,
  7837. Gend: res.Output.Baseinfo.Gend,
  7838. Naty: res.Output.Baseinfo.Naty,
  7839. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7840. PsnName: res.Output.Baseinfo.PsnName,
  7841. Idetinfo: idetinfoStr,
  7842. Insuinfo: infoStr,
  7843. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7844. }
  7845. service.CreateHisPsn(psn)
  7846. var rf []*ResultFive
  7847. json.Unmarshal([]byte(infoStr), &rf)
  7848. var insutypes []*ResultFive
  7849. var insutype string
  7850. var is390 int = 0
  7851. var is310 int = 0
  7852. for _, item := range rf {
  7853. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7854. insutypes = append(insutypes, item)
  7855. }
  7856. }
  7857. if len(insutypes) == 1 {
  7858. insutype = insutypes[0].Insutype
  7859. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7860. } else {
  7861. for _, i := range insutypes {
  7862. if i.Insutype == "390" {
  7863. is390 = 1
  7864. }
  7865. if i.Insutype == "310" {
  7866. is310 = 1
  7867. }
  7868. }
  7869. }
  7870. if is390 == 1 {
  7871. insutype = "390"
  7872. }
  7873. if is310 == 1 {
  7874. insutype = "310"
  7875. }
  7876. if len(insutypes) == 0 {
  7877. insutype = "310"
  7878. }
  7879. c.ServeSuccessJSON(map[string]interface{}{
  7880. "patient": patient,
  7881. "number": res.Output.Baseinfo.Certno,
  7882. "insutype": insutype,
  7883. })
  7884. }
  7885. } else {
  7886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7887. return
  7888. }
  7889. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7890. var res ResultTwo
  7891. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  7892. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7893. "&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)
  7894. resp, requestErr := http.Get(api)
  7895. if requestErr != nil {
  7896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7897. return
  7898. }
  7899. body, ioErr := ioutil.ReadAll(resp.Body)
  7900. if ioErr != nil {
  7901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7903. return
  7904. }
  7905. var respJSON map[string]interface{}
  7906. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7909. return
  7910. }
  7911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7912. result, _ := json.Marshal(respJSON)
  7913. fmt.Println("log")
  7914. fmt.Println(string(result))
  7915. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7916. utils.ErrorLog("解析失败:%v", err)
  7917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7918. return
  7919. }
  7920. if res.Infcode == 0 {
  7921. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7922. if err == gorm.ErrRecordNotFound {
  7923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7924. return
  7925. } else if err != nil {
  7926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7927. return
  7928. } else {
  7929. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7930. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7931. infoStr := string(Iinfos)
  7932. idetinfoStr := string(Idetinfos)
  7933. var rf []*ResultFive
  7934. json.Unmarshal([]byte(infoStr), &rf)
  7935. var insutypes []*ResultFive
  7936. var insutype string
  7937. var is390 int = 0
  7938. var is310 int = 0
  7939. for _, item := range rf {
  7940. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7941. insutypes = append(insutypes, item)
  7942. }
  7943. }
  7944. if len(insutypes) == 1 {
  7945. insutype = insutypes[0].Insutype
  7946. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7947. } else {
  7948. for _, i := range insutypes {
  7949. if i.Insutype == "390" {
  7950. is390 = 1
  7951. }
  7952. if i.Insutype == "310" {
  7953. is310 = 1
  7954. }
  7955. }
  7956. }
  7957. if is390 == 1 {
  7958. insutype = "390"
  7959. }
  7960. if is310 == 1 {
  7961. insutype = "310"
  7962. }
  7963. if len(insutypes) == 0 {
  7964. insutype = "390"
  7965. }
  7966. var insuplc_admdvs string
  7967. for _, item := range rf {
  7968. if item.Insutype == insutype {
  7969. insuplc_admdvs = item.InsuplcAdmdvs
  7970. }
  7971. }
  7972. psn := &models.HisPsn{
  7973. PsnNo: res.Output.Baseinfo.PsnNo,
  7974. PatientId: patient.ID,
  7975. Certno: res.Output.Baseinfo.Certno,
  7976. Gend: res.Output.Baseinfo.Gend,
  7977. Naty: res.Output.Baseinfo.Naty,
  7978. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7979. PsnName: res.Output.Baseinfo.PsnName,
  7980. Idetinfo: idetinfoStr,
  7981. Insuinfo: infoStr,
  7982. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7983. InsuplcAdmdvs: insuplc_admdvs,
  7984. }
  7985. service.CreateHisPsn(psn)
  7986. for _, item := range rf {
  7987. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7988. insutypes = append(insutypes, item)
  7989. }
  7990. }
  7991. if len(insutypes) == 1 {
  7992. insutype = insutypes[0].Insutype
  7993. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7994. } else {
  7995. for _, i := range insutypes {
  7996. if i.Insutype == "390" {
  7997. is390 = 1
  7998. }
  7999. if i.Insutype == "310" {
  8000. is310 = 1
  8001. }
  8002. }
  8003. }
  8004. if is390 == 1 {
  8005. insutype = "390"
  8006. }
  8007. if is310 == 1 {
  8008. insutype = "310"
  8009. }
  8010. if len(insutypes) == 0 {
  8011. insutype = "310"
  8012. }
  8013. c.ServeSuccessJSON(map[string]interface{}{
  8014. "patient": patient,
  8015. "number": res.Output.Baseinfo.Certno,
  8016. "insutype": insutype,
  8017. })
  8018. }
  8019. } else {
  8020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8021. return
  8022. }
  8023. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8024. var res ResultTwo
  8025. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  8026. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8027. "&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)
  8028. resp, requestErr := http.Get(api)
  8029. if requestErr != nil {
  8030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8031. return
  8032. }
  8033. body, ioErr := ioutil.ReadAll(resp.Body)
  8034. if ioErr != nil {
  8035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8037. return
  8038. }
  8039. var respJSON map[string]interface{}
  8040. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8043. return
  8044. }
  8045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8046. result, _ := json.Marshal(respJSON)
  8047. fmt.Println("log")
  8048. fmt.Println(string(result))
  8049. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8050. utils.ErrorLog("解析失败:%v", err)
  8051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8052. return
  8053. }
  8054. if res.Infcode == 0 {
  8055. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8056. if err == gorm.ErrRecordNotFound {
  8057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8058. return
  8059. } else if err != nil {
  8060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8061. return
  8062. } else {
  8063. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8064. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8065. infoStr := string(Iinfos)
  8066. idetinfoStr := string(Idetinfos)
  8067. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8068. psn := &models.HisPsn{
  8069. PsnNo: res.Output.Baseinfo.PsnNo,
  8070. PatientId: patient.ID,
  8071. Certno: res.Output.Baseinfo.Certno,
  8072. Brdy: b,
  8073. Age: float64(age),
  8074. Gend: res.Output.Baseinfo.Gend,
  8075. Naty: res.Output.Baseinfo.Naty,
  8076. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8077. PsnName: res.Output.Baseinfo.PsnName,
  8078. Idetinfo: idetinfoStr,
  8079. Insuinfo: infoStr,
  8080. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8081. }
  8082. service.CreateHisPsn(psn)
  8083. var rf []*ResultFive
  8084. json.Unmarshal([]byte(infoStr), &rf)
  8085. var insutypes []*ResultFive
  8086. var insutype string
  8087. var is390 int = 0
  8088. var is310 int = 0
  8089. for _, item := range rf {
  8090. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8091. insutypes = append(insutypes, item)
  8092. }
  8093. }
  8094. if len(insutypes) == 1 {
  8095. insutype = insutypes[0].Insutype
  8096. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8097. } else {
  8098. for _, i := range insutypes {
  8099. if i.Insutype == "390" {
  8100. is390 = 1
  8101. }
  8102. if i.Insutype == "310" {
  8103. is310 = 1
  8104. }
  8105. }
  8106. }
  8107. if is390 == 1 {
  8108. insutype = "390"
  8109. }
  8110. if is310 == 1 {
  8111. insutype = "310"
  8112. }
  8113. if len(insutypes) == 0 {
  8114. insutype = "310"
  8115. }
  8116. c.ServeSuccessJSON(map[string]interface{}{
  8117. "patient": patient,
  8118. "number": res.Output.Baseinfo.Certno,
  8119. "insutype": insutype,
  8120. })
  8121. }
  8122. } else {
  8123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8124. return
  8125. }
  8126. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8127. var api string
  8128. if miConfig.MdtrtareaAdmvs == "320921" {
  8129. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8130. "&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
  8131. fmt.Println(api)
  8132. } else {
  8133. 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 +
  8134. "&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)
  8135. }
  8136. resp, requestErr := http.Get(api)
  8137. if requestErr != nil {
  8138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8139. return
  8140. }
  8141. body, ioErr := ioutil.ReadAll(resp.Body)
  8142. if ioErr != nil {
  8143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8145. return
  8146. }
  8147. var respJSON map[string]interface{}
  8148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8151. return
  8152. }
  8153. var status string
  8154. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8155. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8156. //console.log()
  8157. fmt.Println("type===")
  8158. fmt.Println(card_type)
  8159. var token string
  8160. var res ResultTwo //1101结果
  8161. var res10265 ResultTwo10265 //1101结果
  8162. var card_info string //卡信息
  8163. var busi_card_info string
  8164. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8165. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8166. if status == "0" { //读卡成功
  8167. if card_type == "1" {
  8168. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8169. result, _ := json.Marshal(respJSON)
  8170. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8171. utils.ErrorLog("解析失败:%v", err)
  8172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8173. return
  8174. }
  8175. res.ErrMsg = res10265.ErrMsg
  8176. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8177. res.Infcode = infocode
  8178. res.Output = res10265.Output
  8179. res.InfRefmsgid = res10265.InfRefmsgid
  8180. } else {
  8181. //var card_info string //卡信息
  8182. //var busi_card_info string
  8183. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8184. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8185. //fmt.Println(card_info)
  8186. //fmt.Println(busi_card_info)
  8187. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8188. result, _ := json.Marshal(respJSON)
  8189. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8190. utils.ErrorLog("解析失败:%v", err)
  8191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8192. return
  8193. }
  8194. res.ErrMsg = res10265.ErrMsg
  8195. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8196. res.Infcode = infocode
  8197. res.Output = res10265.Output
  8198. res.InfRefmsgid = res10265.InfRefmsgid
  8199. }
  8200. if res.Infcode == 0 {
  8201. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8202. if err == gorm.ErrRecordNotFound {
  8203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8204. return
  8205. } else if err != nil {
  8206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8207. return
  8208. } else {
  8209. if card_type == "1" {
  8210. bas := strings.Split(card_info, "|")
  8211. basNumber := bas[2]
  8212. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8213. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8214. infoStr := string(Iinfos)
  8215. idetinfoStr := string(Idetinfos)
  8216. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8217. psn := &models.HisPsn{
  8218. PsnNo: res.Output.Baseinfo.PsnNo,
  8219. PatientId: patient.ID,
  8220. Certno: res.Output.Baseinfo.Certno,
  8221. Brdy: b,
  8222. Age: float64(age),
  8223. Gend: res.Output.Baseinfo.Gend,
  8224. Naty: res.Output.Baseinfo.Naty,
  8225. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8226. PsnName: res.Output.Baseinfo.PsnName,
  8227. Idetinfo: idetinfoStr,
  8228. Insuinfo: infoStr,
  8229. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8230. CardInfo: card_info,
  8231. VerifyNumber: busi_card_info,
  8232. }
  8233. service.CreateHisPsn(psn)
  8234. var rf []*ResultFive
  8235. json.Unmarshal([]byte(infoStr), &rf)
  8236. var insutypes []*ResultFive
  8237. var insutype string
  8238. var is390 int = 0
  8239. var is310 int = 0
  8240. for _, item := range rf {
  8241. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8242. insutypes = append(insutypes, item)
  8243. }
  8244. }
  8245. if len(insutypes) == 1 {
  8246. insutype = insutypes[0].Insutype
  8247. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8248. } else {
  8249. for _, i := range insutypes {
  8250. if i.Insutype == "390" {
  8251. is390 = 1
  8252. }
  8253. if i.Insutype == "310" {
  8254. is310 = 1
  8255. }
  8256. }
  8257. }
  8258. if is390 == 1 {
  8259. insutype = "390"
  8260. }
  8261. if is310 == 1 {
  8262. insutype = "310"
  8263. }
  8264. if len(insutypes) == 0 {
  8265. insutype = "310"
  8266. }
  8267. c.ServeSuccessJSON(map[string]interface{}{
  8268. "patient": patient,
  8269. "number": basNumber,
  8270. "insutype": insutype,
  8271. })
  8272. } else {
  8273. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8274. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8275. infoStr := string(Iinfos)
  8276. idetinfoStr := string(Idetinfos)
  8277. psn := &models.HisPsn{
  8278. PsnNo: res.Output.Baseinfo.PsnNo,
  8279. PatientId: patient.ID,
  8280. Certno: res.Output.Baseinfo.Certno,
  8281. Gend: res.Output.Baseinfo.Gend,
  8282. Naty: res.Output.Baseinfo.Naty,
  8283. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8284. PsnName: res.Output.Baseinfo.PsnName,
  8285. Idetinfo: idetinfoStr,
  8286. Insuinfo: infoStr,
  8287. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8288. CardInfo: card_info,
  8289. VerifyNumber: token,
  8290. }
  8291. service.CreateHisPsn(psn)
  8292. c.ServeSuccessJSON(map[string]interface{}{
  8293. "patient": patient,
  8294. "number": token,
  8295. })
  8296. }
  8297. }
  8298. } else {
  8299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8300. return
  8301. }
  8302. } else { //读卡失败
  8303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8304. return
  8305. }
  8306. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8307. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  8308. cardnum = DeleteExtraSpaceTwo(cardnum)
  8309. cardCode = DeleteExtraSpaceTwo(cardCode)
  8310. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  8311. name = DeleteExtraSpaceTwo(name)
  8312. errmsg = DeleteExtraSpaceTwo(errmsg)
  8313. cardnum = Remove0000(cardnum)
  8314. cardCode = Remove0000(cardCode)
  8315. id_card_no = Remove0000(id_card_no)
  8316. name = Remove0000(name)
  8317. errmsg = Remove0000(errmsg)
  8318. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  8319. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  8320. //result2, requestLog2, errMsgLog2 := service.FJybidcomfirm(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name)
  8321. //fmt.Println(result2)
  8322. //fmt.Println(requestLog2)
  8323. //fmt.Println(errMsgLog2)
  8324. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, "", miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name, id_card_no)
  8325. saveLog(result, requestLog, "1101", "获取人员信息")
  8326. fmt.Println(errMsgLog)
  8327. if len(errMsgLog) > 0 {
  8328. } else {
  8329. var dat map[string]interface{}
  8330. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8331. fmt.Println(dat)
  8332. } else {
  8333. fmt.Println(err)
  8334. }
  8335. userJSONBytes, _ := json.Marshal(dat)
  8336. var res ResultTwo
  8337. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8338. utils.ErrorLog("解析失败:%v", err)
  8339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8340. return
  8341. }
  8342. res.ErrMsg = errMsgLog
  8343. if res.Infcode == 0 {
  8344. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8345. if err == gorm.ErrRecordNotFound {
  8346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8347. return
  8348. } else if err != nil {
  8349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8350. return
  8351. } else {
  8352. fmt.Println(res)
  8353. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8354. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8355. infoStr := string(Iinfos)
  8356. idetinfoStr := string(Idetinfos)
  8357. var rf []*ResultFive
  8358. json.Unmarshal([]byte(infoStr), &rf)
  8359. var insutypes []*ResultFive
  8360. var insutype string
  8361. var is390 int = 0
  8362. var is310 int = 0
  8363. for _, item := range rf {
  8364. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8365. insutypes = append(insutypes, item)
  8366. }
  8367. }
  8368. if len(insutypes) == 1 {
  8369. insutype = insutypes[0].Insutype
  8370. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8371. } else {
  8372. for _, i := range insutypes {
  8373. if i.Insutype == "390" {
  8374. is390 = 1
  8375. }
  8376. if i.Insutype == "310" {
  8377. is310 = 1
  8378. }
  8379. }
  8380. }
  8381. if is390 == 1 {
  8382. insutype = "390"
  8383. }
  8384. if is310 == 1 {
  8385. insutype = "310"
  8386. }
  8387. if len(insutypes) == 0 {
  8388. insutype = "390"
  8389. }
  8390. var insuplc_admdvs string
  8391. for _, item := range rf {
  8392. if item.Insutype == insutype {
  8393. insuplc_admdvs = item.InsuplcAdmdvs
  8394. }
  8395. }
  8396. psn := &models.HisPsn{
  8397. PsnNo: res.Output.Baseinfo.PsnNo,
  8398. PatientId: patient.ID,
  8399. Certno: res.Output.Baseinfo.Certno,
  8400. Gend: res.Output.Baseinfo.Gend,
  8401. Naty: res.Output.Baseinfo.Naty,
  8402. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8403. PsnName: res.Output.Baseinfo.PsnName,
  8404. Idetinfo: idetinfoStr,
  8405. Insuinfo: infoStr,
  8406. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8407. CardInfo: basStr,
  8408. VerifyNumber: "",
  8409. InsuplcAdmdvs: insuplc_admdvs,
  8410. }
  8411. service.CreateHisPsn(psn)
  8412. c.ServeSuccessJSON(map[string]interface{}{
  8413. "patient": patient,
  8414. "number": cardnum,
  8415. "insutype": insutype,
  8416. })
  8417. }
  8418. } else {
  8419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8420. return
  8421. }
  8422. }
  8423. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8424. fmt.Println(initFlag)
  8425. fmt.Println("initFlag")
  8426. if initFlag == 0 {
  8427. c.TestGetJiangXiBasBaseInit()
  8428. }
  8429. basStr := c.GetBasBaseInfo()
  8430. if len(basStr) == 0 {
  8431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8432. return
  8433. }
  8434. fmt.Println(basStr)
  8435. bas := strings.Split(basStr, "|")
  8436. basNumber := bas[1]
  8437. fmt.Println(basNumber)
  8438. card_sn := bas[3]
  8439. fmt.Println(card_sn)
  8440. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  8441. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8442. var dat map[string]interface{}
  8443. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8444. fmt.Println(dat)
  8445. } else {
  8446. fmt.Println(err)
  8447. }
  8448. userJSONBytes, _ := json.Marshal(dat)
  8449. var res ResultTwo
  8450. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8451. utils.ErrorLog("解析失败:%v", err)
  8452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8453. return
  8454. }
  8455. if res.Infcode == 0 {
  8456. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8457. if err == gorm.ErrRecordNotFound {
  8458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8459. return
  8460. } else if err != nil {
  8461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8462. return
  8463. } else {
  8464. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8465. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8466. infoStr := string(Iinfos)
  8467. idetinfoStr := string(Idetinfos)
  8468. var rf []*ResultFive
  8469. json.Unmarshal([]byte(infoStr), &rf)
  8470. var insutypes []*ResultFive
  8471. var insutype string
  8472. var is390 int = 0
  8473. var is310 int = 0
  8474. var insuplc_admdvs string
  8475. for _, item := range rf {
  8476. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8477. insutypes = append(insutypes, item)
  8478. }
  8479. }
  8480. if len(insutypes) == 1 {
  8481. insutype = insutypes[0].Insutype
  8482. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8483. } else {
  8484. for _, i := range insutypes {
  8485. if i.Insutype == "390" {
  8486. is390 = 1
  8487. }
  8488. if i.Insutype == "310" {
  8489. is310 = 1
  8490. }
  8491. }
  8492. }
  8493. if is390 == 1 {
  8494. insutype = "390"
  8495. }
  8496. if is310 == 1 {
  8497. insutype = "310"
  8498. }
  8499. if len(insutypes) == 0 {
  8500. insutype = "310"
  8501. }
  8502. for _, item := range rf {
  8503. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  8504. insuplc_admdvs = item.InsuplcAdmdvs
  8505. }
  8506. }
  8507. psn := &models.HisPsn{
  8508. PsnNo: res.Output.Baseinfo.PsnNo,
  8509. PatientId: patient.ID,
  8510. Certno: res.Output.Baseinfo.Certno,
  8511. Gend: res.Output.Baseinfo.Gend,
  8512. Naty: res.Output.Baseinfo.Naty,
  8513. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8514. PsnName: res.Output.Baseinfo.PsnName,
  8515. Idetinfo: idetinfoStr,
  8516. Insuinfo: infoStr,
  8517. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8518. CardInfo: basStr,
  8519. InsuplcAdmdvs: insuplc_admdvs,
  8520. VerifyNumber: "",
  8521. }
  8522. service.CreateHisPsn(psn)
  8523. c.ServeSuccessJSON(map[string]interface{}{
  8524. "patient": patient,
  8525. "number": basNumber,
  8526. "insutype": insutype,
  8527. })
  8528. }
  8529. } else {
  8530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8531. return
  8532. }
  8533. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8534. fmt.Println(initFlag)
  8535. fmt.Println("initFlag")
  8536. if initFlag == 0 {
  8537. c.TestGetHnBasBaseInit()
  8538. }
  8539. basStr := c.GetBasBaseInfo()
  8540. if len(basStr) == 0 {
  8541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8542. return
  8543. }
  8544. fmt.Println(basStr)
  8545. bas := strings.Split(basStr, "|")
  8546. basNumber := bas[1]
  8547. fmt.Println(basNumber)
  8548. card_sn := bas[3]
  8549. card_no := bas[2]
  8550. fmt.Println(card_sn)
  8551. name := bas[4]
  8552. name = ConvertToString(name, "gbk", "utf-8")
  8553. result, _ := service.Hnyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "", name, card_no)
  8554. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8555. var dat map[string]interface{}
  8556. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8557. fmt.Println(dat)
  8558. } else {
  8559. fmt.Println(err)
  8560. }
  8561. userJSONBytes, _ := json.Marshal(dat)
  8562. var res ResultTwo
  8563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8564. utils.ErrorLog("解析失败:%v", err)
  8565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8566. return
  8567. }
  8568. if res.Infcode == 0 {
  8569. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8570. if err == gorm.ErrRecordNotFound {
  8571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8572. return
  8573. } else if err != nil {
  8574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8575. return
  8576. } else {
  8577. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8578. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8579. infoStr := string(Iinfos)
  8580. idetinfoStr := string(Idetinfos)
  8581. psn := &models.HisPsn{
  8582. PsnNo: res.Output.Baseinfo.PsnNo,
  8583. PatientId: patient.ID,
  8584. Certno: res.Output.Baseinfo.Certno,
  8585. Gend: res.Output.Baseinfo.Gend,
  8586. Naty: res.Output.Baseinfo.Naty,
  8587. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8588. PsnName: res.Output.Baseinfo.PsnName,
  8589. Idetinfo: idetinfoStr,
  8590. Insuinfo: infoStr,
  8591. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8592. CardInfo: basStr,
  8593. VerifyNumber: "",
  8594. }
  8595. service.CreateHisPsn(psn)
  8596. var rf []*ResultFive
  8597. json.Unmarshal([]byte(infoStr), &rf)
  8598. var insutypes []*ResultFive
  8599. var insutype string
  8600. var is390 int = 0
  8601. var is310 int = 0
  8602. for _, item := range rf {
  8603. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8604. insutypes = append(insutypes, item)
  8605. }
  8606. }
  8607. if len(insutypes) == 1 {
  8608. insutype = insutypes[0].Insutype
  8609. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8610. } else {
  8611. for _, i := range insutypes {
  8612. if i.Insutype == "390" {
  8613. is390 = 1
  8614. }
  8615. if i.Insutype == "310" {
  8616. is310 = 1
  8617. }
  8618. }
  8619. }
  8620. if is390 == 1 {
  8621. insutype = "390"
  8622. }
  8623. if is310 == 1 {
  8624. insutype = "310"
  8625. }
  8626. if len(insutypes) == 0 {
  8627. insutype = "310"
  8628. }
  8629. c.ServeSuccessJSON(map[string]interface{}{
  8630. "patient": patient,
  8631. "number": basNumber,
  8632. "insutype": insutype,
  8633. })
  8634. }
  8635. } else {
  8636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8637. return
  8638. }
  8639. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8640. var api string
  8641. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8642. "&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
  8643. fmt.Println(api)
  8644. resp, requestErr := http.Get(api)
  8645. if requestErr != nil {
  8646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8647. return
  8648. }
  8649. body, ioErr := ioutil.ReadAll(resp.Body)
  8650. if ioErr != nil {
  8651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8653. return
  8654. }
  8655. var respJSON map[string]interface{}
  8656. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8659. return
  8660. }
  8661. var res ResultTwo //1101结果
  8662. var res10265 ResultTwo10265 //1101结果
  8663. var card_info string //卡信息
  8664. token := respJSON["data"].(map[string]interface{})["token"].(string)
  8665. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8666. result, _ := json.Marshal(respJSON)
  8667. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8668. utils.ErrorLog("解析失败:%v", err)
  8669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8670. return
  8671. }
  8672. res.ErrMsg = res10265.ErrMsg
  8673. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8674. res.Infcode = infocode
  8675. res.Output = res10265.Output
  8676. res.InfRefmsgid = res10265.InfRefmsgid
  8677. if res.Infcode == 0 {
  8678. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8679. if err == gorm.ErrRecordNotFound {
  8680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8681. return
  8682. } else if err != nil {
  8683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8684. return
  8685. } else {
  8686. bas := strings.Split(card_info, "|")
  8687. basNumber := bas[2]
  8688. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8689. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8690. infoStr := string(Iinfos)
  8691. idetinfoStr := string(Idetinfos)
  8692. psn := &models.HisPsn{
  8693. PsnNo: res.Output.Baseinfo.PsnNo,
  8694. PatientId: patient.ID,
  8695. Certno: res.Output.Baseinfo.Certno,
  8696. Gend: res.Output.Baseinfo.Gend,
  8697. Naty: res.Output.Baseinfo.Naty,
  8698. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8699. PsnName: res.Output.Baseinfo.PsnName,
  8700. Idetinfo: idetinfoStr,
  8701. Insuinfo: infoStr,
  8702. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8703. CardInfo: card_info,
  8704. VerifyNumber: token,
  8705. }
  8706. service.CreateHisPsn(psn)
  8707. var rf []*ResultFive
  8708. json.Unmarshal([]byte(infoStr), &rf)
  8709. var insutypes []*ResultFive
  8710. var insutype string
  8711. var is390 int = 0
  8712. var is310 int = 0
  8713. for _, item := range rf {
  8714. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8715. insutypes = append(insutypes, item)
  8716. }
  8717. }
  8718. if len(insutypes) == 1 {
  8719. insutype = insutypes[0].Insutype
  8720. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8721. } else {
  8722. for _, i := range insutypes {
  8723. if i.Insutype == "390" {
  8724. is390 = 1
  8725. }
  8726. if i.Insutype == "310" {
  8727. is310 = 1
  8728. }
  8729. }
  8730. }
  8731. if is390 == 1 {
  8732. insutype = "390"
  8733. }
  8734. if is310 == 1 {
  8735. insutype = "310"
  8736. }
  8737. if len(insutypes) == 0 {
  8738. insutype = "310"
  8739. }
  8740. c.ServeSuccessJSON(map[string]interface{}{
  8741. "patient": patient,
  8742. "number": basNumber,
  8743. "insutype": insutype,
  8744. })
  8745. }
  8746. } else {
  8747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8748. return
  8749. }
  8750. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8751. res := c.GetoleInfo()
  8752. if res.Infcode == 0 {
  8753. var result string
  8754. if res.Output.MdtrtCertType == "01" {
  8755. result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, certificates, res.Output.PsnName, res.Output.EcToken, admin_user_id)
  8756. } else if res.Output.MdtrtCertType == "02" {
  8757. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, certificates, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  8758. } else if res.Output.MdtrtCertType == "03" {
  8759. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, certificates, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  8760. }
  8761. var dat map[string]interface{}
  8762. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8763. fmt.Println(dat)
  8764. } else {
  8765. fmt.Println(err)
  8766. }
  8767. userJSONBytes, _ := json.Marshal(dat)
  8768. var res2 ResultTwo
  8769. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8770. utils.ErrorLog("解析失败:%v", err)
  8771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8772. return
  8773. }
  8774. if res2.Infcode == 0 {
  8775. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8776. if err == gorm.ErrRecordNotFound {
  8777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8778. return
  8779. } else if err != nil {
  8780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8781. return
  8782. } else {
  8783. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8784. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8785. infoStr := string(Iinfos)
  8786. idetinfoStr := string(Idetinfos)
  8787. var rf []*ResultFive
  8788. json.Unmarshal([]byte(infoStr), &rf)
  8789. var insutypes []*ResultFive
  8790. var insutype string
  8791. var is390 int = 0
  8792. var is310 int = 0
  8793. //var insuplc_admdvs string
  8794. for _, item := range rf {
  8795. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8796. insutypes = append(insutypes, item)
  8797. }
  8798. }
  8799. if len(insutypes) == 1 {
  8800. insutype = insutypes[0].Insutype
  8801. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8802. } else {
  8803. for _, i := range insutypes {
  8804. if i.Insutype == "390" {
  8805. is390 = 1
  8806. }
  8807. if i.Insutype == "310" {
  8808. is310 = 1
  8809. }
  8810. }
  8811. }
  8812. if is390 == 1 {
  8813. insutype = "390"
  8814. }
  8815. if is310 == 1 {
  8816. insutype = "310"
  8817. }
  8818. if len(insutypes) == 0 {
  8819. insutype = "310"
  8820. }
  8821. psn := &models.HisPsn{
  8822. PsnNo: res2.Output.Baseinfo.PsnNo,
  8823. PatientId: patient.ID,
  8824. Certno: res2.Output.Baseinfo.Certno,
  8825. Gend: res2.Output.Baseinfo.Gend,
  8826. Naty: res2.Output.Baseinfo.Naty,
  8827. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8828. PsnName: res2.Output.Baseinfo.PsnName,
  8829. Idetinfo: idetinfoStr,
  8830. Insuinfo: infoStr,
  8831. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8832. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8833. VerifyNumber: res.Output.EcToken,
  8834. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8835. }
  8836. if res.Output.MdtrtCertType == "01" {
  8837. psn.VerifyNumber = res.Output.EcToken
  8838. //result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, certificates, res.Output.PsnName, res.Output.EcToken,admin_user_id)
  8839. } else if res.Output.MdtrtCertType == "02" {
  8840. psn.VerifyNumber = res.Output.MdtrtCertNo
  8841. //result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, certificates, res.Output.PsnName, res.Output.CardNo,admin_user_id)
  8842. } else if res.Output.MdtrtCertType == "03" {
  8843. psn.VerifyNumber = res.Output.MdtrtCertNo
  8844. //result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, certificates, res.Output.PsnName, res.Output.CardNo,admin_user_id)
  8845. }
  8846. var balc float64
  8847. for _, item := range rf {
  8848. if item.Insutype == insutype {
  8849. balc = item.Balc
  8850. }
  8851. }
  8852. service.CreateHisPsn(psn)
  8853. c.ServeSuccessJSON(map[string]interface{}{
  8854. "patient": patient,
  8855. "number": res.Output.CardNo,
  8856. "insutype": insutype,
  8857. "blac": balc,
  8858. "desc": idetinfoStr,
  8859. })
  8860. }
  8861. } else {
  8862. c.ServeSuccessJSON(map[string]interface{}{
  8863. "failed_code": -10,
  8864. "msg": res2.ErrMsg,
  8865. })
  8866. }
  8867. } else {
  8868. c.ServeSuccessJSON(map[string]interface{}{
  8869. "failed_code": -10,
  8870. "msg": res.ErrMsg,
  8871. })
  8872. }
  8873. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8874. var api string
  8875. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8876. "&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
  8877. fmt.Println(api)
  8878. resp, requestErr := http.Get(api)
  8879. if requestErr != nil {
  8880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8881. return
  8882. }
  8883. body, ioErr := ioutil.ReadAll(resp.Body)
  8884. if ioErr != nil {
  8885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8887. return
  8888. }
  8889. var respJSON map[string]interface{}
  8890. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8893. return
  8894. }
  8895. var status string
  8896. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8897. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8898. //console.log()
  8899. fmt.Println("type===")
  8900. fmt.Println(card_type)
  8901. var token string
  8902. var res ResultTwo //1101结果
  8903. //var res10265 ResultTwoesultTwo10265 //1101结果
  8904. var card_info string //卡信息
  8905. var busi_card_info string
  8906. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8907. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8908. if status == "0" { //读卡成功
  8909. if card_type == "1" {
  8910. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8911. result, _ := json.Marshal(respJSON)
  8912. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8913. utils.ErrorLog("解析失败:%v", err)
  8914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8915. return
  8916. }
  8917. } else {
  8918. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8919. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8920. result, _ := json.Marshal(respJSON)
  8921. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8922. utils.ErrorLog("解析失败:%v", err)
  8923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8924. return
  8925. }
  8926. }
  8927. if res.Infcode == 0 {
  8928. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8929. if err == gorm.ErrRecordNotFound {
  8930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8931. return
  8932. } else if err != nil {
  8933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8934. return
  8935. } else {
  8936. if card_type == "1" {
  8937. bas := strings.Split(card_info, "|")
  8938. basNumber := bas[2]
  8939. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8940. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8941. infoStr := string(Iinfos)
  8942. idetinfoStr := string(Idetinfos)
  8943. psn := &models.HisPsn{
  8944. PsnNo: res.Output.Baseinfo.PsnNo,
  8945. PatientId: patient.ID,
  8946. Certno: res.Output.Baseinfo.Certno,
  8947. Gend: res.Output.Baseinfo.Gend,
  8948. Naty: res.Output.Baseinfo.Naty,
  8949. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8950. PsnName: res.Output.Baseinfo.PsnName,
  8951. Idetinfo: idetinfoStr,
  8952. Insuinfo: infoStr,
  8953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8954. CardInfo: card_info,
  8955. VerifyNumber: busi_card_info,
  8956. }
  8957. service.CreateHisPsn(psn)
  8958. var rf []*ResultFive
  8959. json.Unmarshal([]byte(infoStr), &rf)
  8960. var insutypes []*ResultFive
  8961. var insutype string
  8962. var is390 int = 0
  8963. var is310 int = 0
  8964. for _, item := range rf {
  8965. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8966. insutypes = append(insutypes, item)
  8967. }
  8968. }
  8969. if len(insutypes) == 1 {
  8970. insutype = insutypes[0].Insutype
  8971. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8972. } else {
  8973. for _, i := range insutypes {
  8974. if i.Insutype == "390" {
  8975. is390 = 1
  8976. }
  8977. if i.Insutype == "310" {
  8978. is310 = 1
  8979. }
  8980. }
  8981. }
  8982. if is390 == 1 {
  8983. insutype = "390"
  8984. }
  8985. if is310 == 1 {
  8986. insutype = "310"
  8987. }
  8988. if len(insutypes) == 0 {
  8989. insutype = "310"
  8990. }
  8991. c.ServeSuccessJSON(map[string]interface{}{
  8992. "patient": patient,
  8993. "number": basNumber,
  8994. "insutype": insutype,
  8995. })
  8996. } else {
  8997. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8998. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8999. infoStr := string(Iinfos)
  9000. idetinfoStr := string(Idetinfos)
  9001. psn := &models.HisPsn{
  9002. PsnNo: res.Output.Baseinfo.PsnNo,
  9003. PatientId: patient.ID,
  9004. Certno: res.Output.Baseinfo.Certno,
  9005. Gend: res.Output.Baseinfo.Gend,
  9006. Naty: res.Output.Baseinfo.Naty,
  9007. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9008. PsnName: res.Output.Baseinfo.PsnName,
  9009. Idetinfo: idetinfoStr,
  9010. Insuinfo: infoStr,
  9011. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9012. CardInfo: card_info,
  9013. VerifyNumber: token,
  9014. }
  9015. service.CreateHisPsn(psn)
  9016. c.ServeSuccessJSON(map[string]interface{}{
  9017. "patient": patient,
  9018. "number": token,
  9019. })
  9020. }
  9021. }
  9022. } else {
  9023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9024. return
  9025. }
  9026. } else { //读卡失败
  9027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9028. return
  9029. }
  9030. } else {
  9031. if initFlag == 0 {
  9032. c.TestGetBasBaseInit()
  9033. }
  9034. basStr := c.GetBasBaseInfo()
  9035. if len(basStr) == 0 {
  9036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9037. return
  9038. }
  9039. fmt.Println(basStr)
  9040. bas := strings.Split(basStr, "|")
  9041. basNumber := bas[1]
  9042. fmt.Println(basNumber)
  9043. card_sn := bas[3]
  9044. fmt.Println(card_sn)
  9045. cardNumber := bas[2]
  9046. fmt.Println(cardNumber)
  9047. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  9048. var result string
  9049. if bas[0][:2] == "44" {
  9050. result = service.Gdyb1101f(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber)
  9051. } else {
  9052. result = service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber, admin_user_id)
  9053. }
  9054. var dat map[string]interface{}
  9055. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9056. fmt.Println(dat)
  9057. } else {
  9058. fmt.Println(err)
  9059. }
  9060. userJSONBytes, _ := json.Marshal(dat)
  9061. var res ResultTwo
  9062. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9063. utils.ErrorLog("解析失败:%v", err)
  9064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9065. return
  9066. }
  9067. if res.Infcode == 0 {
  9068. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  9069. if err == gorm.ErrRecordNotFound {
  9070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9071. return
  9072. } else if err != nil {
  9073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9074. return
  9075. } else {
  9076. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9077. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9078. infoStr := string(Iinfos)
  9079. idetinfoStr := string(Idetinfos)
  9080. var rf []*ResultFive
  9081. json.Unmarshal([]byte(infoStr), &rf)
  9082. var insutypes []*ResultFive
  9083. var insutype string
  9084. var is390 int = 0
  9085. var is310 int = 0
  9086. var insuplc_admdvs string
  9087. for _, item := range rf {
  9088. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9089. insutypes = append(insutypes, item)
  9090. }
  9091. }
  9092. if len(insutypes) == 1 {
  9093. insutype = insutypes[0].Insutype
  9094. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9095. } else {
  9096. for _, i := range insutypes {
  9097. if i.Insutype == "390" {
  9098. is390 = 1
  9099. }
  9100. if i.Insutype == "310" {
  9101. is310 = 1
  9102. }
  9103. }
  9104. }
  9105. if is390 == 1 {
  9106. insutype = "390"
  9107. }
  9108. if is310 == 1 {
  9109. insutype = "310"
  9110. }
  9111. if len(insutypes) == 0 {
  9112. insutype = "310"
  9113. }
  9114. for _, item := range rf {
  9115. if item.Insutype == insutype {
  9116. insuplc_admdvs = item.InsuplcAdmdvs
  9117. }
  9118. }
  9119. psn := &models.HisPsn{
  9120. PsnNo: res.Output.Baseinfo.PsnNo,
  9121. PatientId: patient.ID,
  9122. Certno: res.Output.Baseinfo.Certno,
  9123. Gend: res.Output.Baseinfo.Gend,
  9124. Naty: res.Output.Baseinfo.Naty,
  9125. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9126. PsnName: res.Output.Baseinfo.PsnName,
  9127. Idetinfo: idetinfoStr,
  9128. Insuinfo: infoStr,
  9129. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9130. CardInfo: basStr,
  9131. VerifyNumber: "",
  9132. InsuplcAdmdvs: insuplc_admdvs,
  9133. }
  9134. service.CreateHisPsn(psn)
  9135. c.ServeSuccessJSON(map[string]interface{}{
  9136. "patient": patient,
  9137. "number": basNumber,
  9138. })
  9139. }
  9140. } else {
  9141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9142. return
  9143. }
  9144. break
  9145. }
  9146. case 2:
  9147. if miConfig.MdtrtareaAdmvs == "430800" {
  9148. if initFlag == 0 {
  9149. c.TestGetHnBasBaseInit()
  9150. }
  9151. SFZStr := c.GetSFZBaseInfo()
  9152. if len(SFZStr) == 0 {
  9153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9154. return
  9155. }
  9156. fmt.Println(SFZStr)
  9157. id_card_str := strings.Split(SFZStr, "^")
  9158. card_no := id_card_str[0]
  9159. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9160. //name := id_card_str[1]
  9161. //name = ConvertToString(name, "gbk", "utf-8")
  9162. result, _ := service.Hnyb1101(card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", patient.Name, card_no)
  9163. var dat map[string]interface{}
  9164. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9165. fmt.Println(dat)
  9166. } else {
  9167. fmt.Println(err)
  9168. }
  9169. userJSONBytes, _ := json.Marshal(dat)
  9170. var res ResultTwo
  9171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9172. utils.ErrorLog("解析失败:%v", err)
  9173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9174. return
  9175. }
  9176. if res.Infcode == 0 {
  9177. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9178. if err == gorm.ErrRecordNotFound {
  9179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9180. return
  9181. } else if err != nil {
  9182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9183. return
  9184. } else {
  9185. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9186. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9187. infoStr := string(Iinfos)
  9188. idetinfoStr := string(Idetinfos)
  9189. var rf []*ResultFive
  9190. json.Unmarshal([]byte(infoStr), &rf)
  9191. var insutypes []*ResultFive
  9192. var insutype string
  9193. var is390 int = 0
  9194. var is310 int = 0
  9195. for _, item := range rf {
  9196. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9197. insutypes = append(insutypes, item)
  9198. }
  9199. }
  9200. if len(insutypes) == 1 {
  9201. insutype = insutypes[0].Insutype
  9202. } else {
  9203. for _, i := range insutypes {
  9204. if i.Insutype == "390" {
  9205. is390 = 1
  9206. }
  9207. if i.Insutype == "310" {
  9208. is310 = 1
  9209. }
  9210. }
  9211. }
  9212. if is390 == 1 {
  9213. insutype = "390"
  9214. }
  9215. if is310 == 1 {
  9216. insutype = "310"
  9217. }
  9218. if len(insutypes) == 0 {
  9219. insutype = "310"
  9220. }
  9221. var InsuplcAdmdvs string
  9222. for _, item := range rf {
  9223. if item.Insutype == insutype {
  9224. InsuplcAdmdvs = item.InsuplcAdmdvs
  9225. }
  9226. }
  9227. psn := &models.HisPsn{
  9228. PsnNo: res.Output.Baseinfo.PsnNo,
  9229. PatientId: patient.ID,
  9230. Certno: res.Output.Baseinfo.Certno,
  9231. Gend: res.Output.Baseinfo.Gend,
  9232. Naty: res.Output.Baseinfo.Naty,
  9233. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9234. PsnName: res.Output.Baseinfo.PsnName,
  9235. Idetinfo: idetinfoStr,
  9236. Insuinfo: infoStr,
  9237. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9238. CardInfo: SFZStr,
  9239. VerifyNumber: "",
  9240. InsuplcAdmdvs: InsuplcAdmdvs,
  9241. }
  9242. service.CreateHisPsn(psn)
  9243. c.ServeSuccessJSON(map[string]interface{}{
  9244. "patient": patient,
  9245. "number": card_no,
  9246. "insutype": insutype,
  9247. })
  9248. }
  9249. } else {
  9250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9251. return
  9252. }
  9253. } else if miConfig.MdtrtareaAdmvs == "420200" {
  9254. var res ResultTwo
  9255. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  9256. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9257. "&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)
  9258. resp, requestErr := http.Get(api)
  9259. if requestErr != nil {
  9260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9261. return
  9262. }
  9263. body, ioErr := ioutil.ReadAll(resp.Body)
  9264. if ioErr != nil {
  9265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9267. return
  9268. }
  9269. var respJSON map[string]interface{}
  9270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9273. return
  9274. }
  9275. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9276. result, _ := json.Marshal(respJSON)
  9277. fmt.Println("log")
  9278. fmt.Println(string(result))
  9279. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9280. utils.ErrorLog("解析失败:%v", err)
  9281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9282. return
  9283. }
  9284. if res.Infcode == 0 {
  9285. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9286. if err == gorm.ErrRecordNotFound {
  9287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9288. return
  9289. } else if err != nil {
  9290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9291. return
  9292. } else {
  9293. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9294. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9295. infoStr := string(Iinfos)
  9296. idetinfoStr := string(Idetinfos)
  9297. psn := &models.HisPsn{
  9298. PsnNo: res.Output.Baseinfo.PsnNo,
  9299. PatientId: patient.ID,
  9300. Certno: res.Output.Baseinfo.Certno,
  9301. Gend: res.Output.Baseinfo.Gend,
  9302. Naty: res.Output.Baseinfo.Naty,
  9303. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9304. PsnName: res.Output.Baseinfo.PsnName,
  9305. Idetinfo: idetinfoStr,
  9306. Insuinfo: infoStr,
  9307. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9308. }
  9309. service.CreateHisPsn(psn)
  9310. c.ServeSuccessJSON(map[string]interface{}{
  9311. "patient": patient,
  9312. "number": res.Output.Baseinfo.Certno,
  9313. })
  9314. }
  9315. } else {
  9316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9317. return
  9318. }
  9319. } else if miConfig.MdtrtareaAdmvs == "421182" {
  9320. var res ResultTwo
  9321. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9322. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9323. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  9324. resp, requestErr := http.Get(api)
  9325. if requestErr != nil {
  9326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9327. return
  9328. }
  9329. body, ioErr := ioutil.ReadAll(resp.Body)
  9330. if ioErr != nil {
  9331. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9333. return
  9334. }
  9335. var respJSON map[string]interface{}
  9336. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9339. return
  9340. }
  9341. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9342. result, _ := json.Marshal(respJSON)
  9343. fmt.Println("log")
  9344. fmt.Println(string(result))
  9345. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9346. utils.ErrorLog("解析失败:%v", err)
  9347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9348. return
  9349. }
  9350. if res.Infcode == 0 {
  9351. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9352. if err == gorm.ErrRecordNotFound {
  9353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9354. return
  9355. } else if err != nil {
  9356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9357. return
  9358. } else {
  9359. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9360. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9361. infoStr := string(Iinfos)
  9362. idetinfoStr := string(Idetinfos)
  9363. psn := &models.HisPsn{
  9364. PsnNo: res.Output.Baseinfo.PsnNo,
  9365. PatientId: patient.ID,
  9366. Certno: res.Output.Baseinfo.Certno,
  9367. Gend: res.Output.Baseinfo.Gend,
  9368. Naty: res.Output.Baseinfo.Naty,
  9369. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9370. PsnName: res.Output.Baseinfo.PsnName,
  9371. Idetinfo: idetinfoStr,
  9372. Insuinfo: infoStr,
  9373. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9374. }
  9375. service.CreateHisPsn(psn)
  9376. c.ServeSuccessJSON(map[string]interface{}{
  9377. "patient": patient,
  9378. "number": res.Output.Baseinfo.Certno,
  9379. })
  9380. }
  9381. } else {
  9382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9383. return
  9384. }
  9385. } else if miConfig.MdtrtareaAdmvs == "420902" {
  9386. var res ResultTwo
  9387. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9388. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9389. "&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)
  9390. resp, requestErr := http.Get(api)
  9391. if requestErr != nil {
  9392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9393. return
  9394. }
  9395. body, ioErr := ioutil.ReadAll(resp.Body)
  9396. if ioErr != nil {
  9397. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9399. return
  9400. }
  9401. var respJSON map[string]interface{}
  9402. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9405. return
  9406. }
  9407. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9408. result, _ := json.Marshal(respJSON)
  9409. fmt.Println("log")
  9410. fmt.Println(string(result))
  9411. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9412. utils.ErrorLog("解析失败:%v", err)
  9413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9414. return
  9415. }
  9416. if res.Infcode == 0 {
  9417. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9418. if err == gorm.ErrRecordNotFound {
  9419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9420. return
  9421. } else if err != nil {
  9422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9423. return
  9424. } else {
  9425. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9426. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9427. infoStr := string(Iinfos)
  9428. idetinfoStr := string(Idetinfos)
  9429. var rf []*ResultFive
  9430. json.Unmarshal([]byte(infoStr), &rf)
  9431. var insutypes []*ResultFive
  9432. var insutype string
  9433. var is390 int = 0
  9434. var is310 int = 0
  9435. for _, item := range rf {
  9436. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9437. insutypes = append(insutypes, item)
  9438. }
  9439. }
  9440. if len(insutypes) == 1 {
  9441. insutype = insutypes[0].Insutype
  9442. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9443. } else {
  9444. for _, i := range insutypes {
  9445. if i.Insutype == "390" {
  9446. is390 = 1
  9447. }
  9448. if i.Insutype == "310" {
  9449. is310 = 1
  9450. }
  9451. }
  9452. }
  9453. if is390 == 1 {
  9454. insutype = "390"
  9455. }
  9456. if is310 == 1 {
  9457. insutype = "310"
  9458. }
  9459. if len(insutypes) == 0 {
  9460. insutype = "390"
  9461. }
  9462. var insuplc_admdvs string
  9463. for _, item := range rf {
  9464. if item.Insutype == insutype {
  9465. insuplc_admdvs = item.InsuplcAdmdvs
  9466. }
  9467. }
  9468. psn := &models.HisPsn{
  9469. PsnNo: res.Output.Baseinfo.PsnNo,
  9470. PatientId: patient.ID,
  9471. Certno: res.Output.Baseinfo.Certno,
  9472. Gend: res.Output.Baseinfo.Gend,
  9473. Naty: res.Output.Baseinfo.Naty,
  9474. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9475. PsnName: res.Output.Baseinfo.PsnName,
  9476. Idetinfo: idetinfoStr,
  9477. Insuinfo: infoStr,
  9478. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9479. InsuplcAdmdvs: insuplc_admdvs,
  9480. }
  9481. service.CreateHisPsn(psn)
  9482. c.ServeSuccessJSON(map[string]interface{}{
  9483. "patient": patient,
  9484. "number": res.Output.Baseinfo.Certno,
  9485. })
  9486. }
  9487. } else {
  9488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9489. return
  9490. }
  9491. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9492. res := c.GetoleInfo()
  9493. if res.Infcode == 0 {
  9494. var result string
  9495. if res.Output.MdtrtCertType == "01" {
  9496. result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, 1, res.Output.PsnName, res.Output.EcToken, admin_user_id)
  9497. } else if res.Output.MdtrtCertType == "02" {
  9498. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  9499. } else if res.Output.MdtrtCertType == "03" {
  9500. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  9501. }
  9502. var dat map[string]interface{}
  9503. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9504. fmt.Println(dat)
  9505. } else {
  9506. fmt.Println(err)
  9507. }
  9508. userJSONBytes, _ := json.Marshal(dat)
  9509. var res2 ResultTwo
  9510. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9511. utils.ErrorLog("解析失败:%v", err)
  9512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9513. return
  9514. }
  9515. if res2.Infcode == 0 {
  9516. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9517. if err == gorm.ErrRecordNotFound {
  9518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9519. return
  9520. } else if err != nil {
  9521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9522. return
  9523. } else {
  9524. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9525. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9526. infoStr := string(Iinfos)
  9527. idetinfoStr := string(Idetinfos)
  9528. var rf []*ResultFive
  9529. json.Unmarshal([]byte(infoStr), &rf)
  9530. var insutypes []*ResultFive
  9531. var insutype string
  9532. var is390 int = 0
  9533. var is310 int = 0
  9534. //var insuplc_admdvs string
  9535. for _, item := range rf {
  9536. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9537. insutypes = append(insutypes, item)
  9538. }
  9539. }
  9540. if len(insutypes) == 1 {
  9541. insutype = insutypes[0].Insutype
  9542. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9543. } else {
  9544. for _, i := range insutypes {
  9545. if i.Insutype == "390" {
  9546. is390 = 1
  9547. }
  9548. if i.Insutype == "310" {
  9549. is310 = 1
  9550. }
  9551. }
  9552. }
  9553. if is390 == 1 {
  9554. insutype = "390"
  9555. }
  9556. if is310 == 1 {
  9557. insutype = "310"
  9558. }
  9559. if len(insutypes) == 0 {
  9560. insutype = "310"
  9561. }
  9562. psn := &models.HisPsn{
  9563. PsnNo: res2.Output.Baseinfo.PsnNo,
  9564. PatientId: patient.ID,
  9565. //Brdy: res2.Output.Baseinfo.Brdy,
  9566. Certno: res2.Output.Baseinfo.Certno,
  9567. Gend: res2.Output.Baseinfo.Gend,
  9568. Naty: res2.Output.Baseinfo.Naty,
  9569. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9570. PsnName: res2.Output.Baseinfo.PsnName,
  9571. Idetinfo: idetinfoStr,
  9572. Insuinfo: infoStr,
  9573. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9574. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9575. VerifyNumber: res.Output.EcToken,
  9576. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9577. }
  9578. service.CreateHisPsn(psn)
  9579. var balc float64
  9580. for _, item := range rf {
  9581. if item.Insutype == insutype {
  9582. balc = item.Balc
  9583. }
  9584. }
  9585. c.ServeSuccessJSON(map[string]interface{}{
  9586. "patient": patient,
  9587. "number": res.Output.CardNo,
  9588. "insutype": insutype,
  9589. "blac": balc,
  9590. "desc": idetinfoStr,
  9591. })
  9592. }
  9593. } else {
  9594. c.ServeSuccessJSON(map[string]interface{}{
  9595. "failed_code": -10,
  9596. "msg": res2.ErrMsg,
  9597. })
  9598. }
  9599. } else {
  9600. c.ServeSuccessJSON(map[string]interface{}{
  9601. "failed_code": -10,
  9602. "msg": res.ErrMsg,
  9603. })
  9604. }
  9605. } else {
  9606. SFZStr := c.GetSFZBaseInfo()
  9607. id_card_str := strings.Split(SFZStr, "^")
  9608. id_card_number := id_card_str[0]
  9609. card_sn := ""
  9610. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "", admin_user_id)
  9611. var dat map[string]interface{}
  9612. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9613. fmt.Println(dat)
  9614. } else {
  9615. fmt.Println(err)
  9616. }
  9617. userJSONBytes, _ := json.Marshal(dat)
  9618. var res ResultTwo
  9619. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9620. utils.ErrorLog("解析失败:%v", err)
  9621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9622. return
  9623. }
  9624. if res.Infcode == 0 {
  9625. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  9626. if err == gorm.ErrRecordNotFound {
  9627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9628. return
  9629. } else if err != nil {
  9630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9631. return
  9632. } else {
  9633. c.ServeSuccessJSON(map[string]interface{}{
  9634. "patient": patient,
  9635. "number": id_card_number,
  9636. })
  9637. }
  9638. } else {
  9639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9640. return
  9641. }
  9642. }
  9643. break
  9644. case 3:
  9645. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9646. var api string
  9647. if miConfig.MdtrtareaAdmvs == "320921" {
  9648. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9649. "&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
  9650. fmt.Println(api)
  9651. } else {
  9652. 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 +
  9653. "&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)
  9654. }
  9655. resp, requestErr := http.Get(api)
  9656. if requestErr != nil {
  9657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9658. return
  9659. }
  9660. body, ioErr := ioutil.ReadAll(resp.Body)
  9661. if ioErr != nil {
  9662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9664. return
  9665. }
  9666. var respJSON map[string]interface{}
  9667. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9670. return
  9671. }
  9672. var status string
  9673. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9674. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9675. var token string
  9676. var res ResultTwo //1101结果
  9677. var res10265 ResultTwo10265 //1101结果
  9678. var card_info string //卡信息
  9679. var busi_card_info string
  9680. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9681. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9682. if status == "0" { //读卡成功
  9683. if card_type == "1" {
  9684. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9685. result, _ := json.Marshal(respJSON)
  9686. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9687. utils.ErrorLog("解析失败:%v", err)
  9688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9689. return
  9690. }
  9691. res.ErrMsg = res10265.ErrMsg
  9692. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9693. res.Infcode = infocode
  9694. res.Output = res10265.Output
  9695. res.InfRefmsgid = res10265.InfRefmsgid
  9696. } else {
  9697. //var card_info string //卡信息
  9698. //var busi_card_info string
  9699. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9700. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9701. //fmt.Println(card_info)
  9702. //fmt.Println(busi_card_info)
  9703. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9704. result, _ := json.Marshal(respJSON)
  9705. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9706. utils.ErrorLog("解析失败:%v", err)
  9707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9708. return
  9709. }
  9710. res.ErrMsg = res10265.ErrMsg
  9711. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9712. res.Infcode = infocode
  9713. res.Output = res10265.Output
  9714. res.InfRefmsgid = res10265.InfRefmsgid
  9715. }
  9716. if res.Infcode == 0 {
  9717. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9718. if err == gorm.ErrRecordNotFound {
  9719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9720. return
  9721. } else if err != nil {
  9722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9723. return
  9724. } else {
  9725. if card_type == "1" {
  9726. bas := strings.Split(card_info, "|")
  9727. basNumber := bas[2]
  9728. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9729. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9730. infoStr := string(Iinfos)
  9731. idetinfoStr := string(Idetinfos)
  9732. psn := &models.HisPsn{
  9733. PsnNo: res.Output.Baseinfo.PsnNo,
  9734. PatientId: patient.ID,
  9735. Certno: res.Output.Baseinfo.Certno,
  9736. //Brdy: res.Output.Baseinfo.Brdy,
  9737. Gend: res.Output.Baseinfo.Gend,
  9738. Naty: res.Output.Baseinfo.Naty,
  9739. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9740. PsnName: res.Output.Baseinfo.PsnName,
  9741. Idetinfo: idetinfoStr,
  9742. Insuinfo: infoStr,
  9743. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9744. CardInfo: card_info,
  9745. VerifyNumber: busi_card_info,
  9746. }
  9747. service.CreateHisPsn(psn)
  9748. c.ServeSuccessJSON(map[string]interface{}{
  9749. "patient": patient,
  9750. "number": basNumber,
  9751. })
  9752. } else {
  9753. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9754. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9755. infoStr := string(Iinfos)
  9756. idetinfoStr := string(Idetinfos)
  9757. psn := &models.HisPsn{
  9758. PsnNo: res.Output.Baseinfo.PsnNo,
  9759. PatientId: patient.ID,
  9760. Certno: res.Output.Baseinfo.Certno,
  9761. Gend: res.Output.Baseinfo.Gend,
  9762. Naty: res.Output.Baseinfo.Naty,
  9763. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9764. PsnName: res.Output.Baseinfo.PsnName,
  9765. Idetinfo: idetinfoStr,
  9766. Insuinfo: infoStr,
  9767. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9768. CardInfo: card_info,
  9769. VerifyNumber: token,
  9770. }
  9771. service.CreateHisPsn(psn)
  9772. var rf []*ResultFive
  9773. json.Unmarshal([]byte(infoStr), &rf)
  9774. var insutypes []*ResultFive
  9775. var insutype string
  9776. var is390 int = 0
  9777. var is310 int = 0
  9778. for _, item := range rf {
  9779. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9780. insutypes = append(insutypes, item)
  9781. }
  9782. }
  9783. if len(insutypes) == 1 {
  9784. insutype = insutypes[0].Insutype
  9785. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9786. } else {
  9787. for _, i := range insutypes {
  9788. if i.Insutype == "390" {
  9789. is390 = 1
  9790. }
  9791. if i.Insutype == "310" {
  9792. is310 = 1
  9793. }
  9794. }
  9795. }
  9796. if is390 == 1 {
  9797. insutype = "390"
  9798. }
  9799. if is310 == 1 {
  9800. insutype = "310"
  9801. }
  9802. if len(insutypes) == 0 {
  9803. insutype = "310"
  9804. }
  9805. c.ServeSuccessJSON(map[string]interface{}{
  9806. "patient": patient,
  9807. "number": token,
  9808. "insutype": insutype,
  9809. })
  9810. }
  9811. }
  9812. } else {
  9813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9814. return
  9815. }
  9816. } else { //读卡失败
  9817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9818. return
  9819. }
  9820. }
  9821. break
  9822. case 4:
  9823. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9824. var api string
  9825. if miConfig.MdtrtareaAdmvs == "320921" {
  9826. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9827. "&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
  9828. fmt.Println(api)
  9829. } else {
  9830. 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 +
  9831. "&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)
  9832. }
  9833. resp, requestErr := http.Get(api)
  9834. if requestErr != nil {
  9835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9836. return
  9837. }
  9838. body, ioErr := ioutil.ReadAll(resp.Body)
  9839. if ioErr != nil {
  9840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9842. return
  9843. }
  9844. var respJSON map[string]interface{}
  9845. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9848. return
  9849. }
  9850. var status string
  9851. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9852. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9853. var token string
  9854. var res ResultTwo //1101结果
  9855. var res10265 ResultTwo10265 //1101结果
  9856. if status == "0" { //读卡成功
  9857. var card_info string //卡信息
  9858. var busi_card_info string
  9859. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9860. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9861. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9862. fmt.Println(card_info)
  9863. fmt.Println(busi_card_info)
  9864. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9865. result, _ := json.Marshal(respJSON)
  9866. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9867. utils.ErrorLog("解析失败:%v", err)
  9868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9869. return
  9870. }
  9871. res.ErrMsg = res10265.ErrMsg
  9872. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9873. res.Infcode = infocode
  9874. res.Output = res10265.Output
  9875. res.InfRefmsgid = res10265.InfRefmsgid
  9876. if res.Infcode == 0 {
  9877. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9878. if err == gorm.ErrRecordNotFound {
  9879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9880. return
  9881. } else if err != nil {
  9882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9883. return
  9884. } else {
  9885. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9886. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9887. infoStr := string(Iinfos)
  9888. idetinfoStr := string(Idetinfos)
  9889. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9890. psn := &models.HisPsn{
  9891. PsnNo: res.Output.Baseinfo.PsnNo,
  9892. PatientId: patient.ID,
  9893. Certno: res.Output.Baseinfo.Certno,
  9894. Brdy: b,
  9895. Age: float64(age),
  9896. //Brdy: res.Output.Baseinfo.Brdy,
  9897. Gend: res.Output.Baseinfo.Gend,
  9898. Naty: res.Output.Baseinfo.Naty,
  9899. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9900. PsnName: res.Output.Baseinfo.PsnName,
  9901. Idetinfo: idetinfoStr,
  9902. Insuinfo: infoStr,
  9903. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9904. CardInfo: card_info,
  9905. VerifyNumber: token,
  9906. }
  9907. var rf []*ResultFive
  9908. json.Unmarshal([]byte(infoStr), &rf)
  9909. var insutypes []*ResultFive
  9910. var insutype string
  9911. var is390 int = 0
  9912. var is310 int = 0
  9913. for _, item := range rf {
  9914. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9915. insutypes = append(insutypes, item)
  9916. }
  9917. }
  9918. if len(insutypes) == 1 {
  9919. insutype = insutypes[0].Insutype
  9920. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9921. } else {
  9922. for _, i := range insutypes {
  9923. if i.Insutype == "390" {
  9924. is390 = 1
  9925. }
  9926. if i.Insutype == "310" {
  9927. is310 = 1
  9928. }
  9929. }
  9930. }
  9931. if is390 == 1 {
  9932. insutype = "390"
  9933. }
  9934. if is310 == 1 {
  9935. insutype = "310"
  9936. }
  9937. if len(insutypes) == 0 {
  9938. insutype = "310"
  9939. }
  9940. service.CreateHisPsn(psn)
  9941. c.ServeSuccessJSON(map[string]interface{}{
  9942. "patient": patient,
  9943. "number": token,
  9944. "insutype": insutype,
  9945. })
  9946. }
  9947. } else {
  9948. c.ServeSuccessJSON(map[string]interface{}{
  9949. "failed_code": -10,
  9950. "msg": res.ErrMsg,
  9951. })
  9952. }
  9953. } else { //读卡失败
  9954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9955. return
  9956. }
  9957. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9958. var api string
  9959. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9960. "&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
  9961. resp, requestErr := http.Get(api)
  9962. if requestErr != nil {
  9963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9964. return
  9965. }
  9966. body, ioErr := ioutil.ReadAll(resp.Body)
  9967. if ioErr != nil {
  9968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9970. return
  9971. }
  9972. var respJSON map[string]interface{}
  9973. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9976. return
  9977. }
  9978. var status string
  9979. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9980. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9981. var token string
  9982. var res ResultTwo //1101结果
  9983. if status == "1" { //读卡成功
  9984. var card_info string //卡信息
  9985. var busi_card_info string
  9986. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9987. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9988. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9989. fmt.Println(card_info)
  9990. fmt.Println(busi_card_info)
  9991. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9992. result, _ := json.Marshal(respJSON)
  9993. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9994. utils.ErrorLog("解析失败:%v", err)
  9995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9996. return
  9997. }
  9998. if res.Infcode == 0 {
  9999. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10000. if err == gorm.ErrRecordNotFound {
  10001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10002. return
  10003. } else if err != nil {
  10004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10005. return
  10006. } else {
  10007. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10008. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10009. infoStr := string(Iinfos)
  10010. idetinfoStr := string(Idetinfos)
  10011. psn := &models.HisPsn{
  10012. PsnNo: res.Output.Baseinfo.PsnNo,
  10013. PatientId: patient.ID,
  10014. Certno: res.Output.Baseinfo.Certno,
  10015. Gend: res.Output.Baseinfo.Gend,
  10016. Naty: res.Output.Baseinfo.Naty,
  10017. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10018. PsnName: res.Output.Baseinfo.PsnName,
  10019. Idetinfo: idetinfoStr,
  10020. Insuinfo: infoStr,
  10021. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10022. CardInfo: card_info,
  10023. VerifyNumber: token,
  10024. }
  10025. var rf []*ResultFive
  10026. json.Unmarshal([]byte(infoStr), &rf)
  10027. var insutypes []*ResultFive
  10028. var insutype string
  10029. var is390 int = 0
  10030. var is310 int = 0
  10031. for _, item := range rf {
  10032. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10033. insutypes = append(insutypes, item)
  10034. }
  10035. }
  10036. if len(insutypes) == 1 {
  10037. insutype = insutypes[0].Insutype
  10038. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10039. } else {
  10040. for _, i := range insutypes {
  10041. if i.Insutype == "390" {
  10042. is390 = 1
  10043. }
  10044. if i.Insutype == "310" {
  10045. is310 = 1
  10046. }
  10047. }
  10048. }
  10049. if is390 == 1 {
  10050. insutype = "390"
  10051. }
  10052. if is310 == 1 {
  10053. insutype = "310"
  10054. }
  10055. if len(insutypes) == 0 {
  10056. insutype = "310"
  10057. }
  10058. service.CreateHisPsn(psn)
  10059. c.ServeSuccessJSON(map[string]interface{}{
  10060. "patient": patient,
  10061. "number": token,
  10062. "insutype": insutype,
  10063. })
  10064. }
  10065. } else {
  10066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10067. return
  10068. }
  10069. } else { //读卡失败
  10070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10071. return
  10072. }
  10073. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10074. idNo := c.GetString("idNo")
  10075. userName := c.GetString("userName")
  10076. ecToken := c.GetString("ecToken")
  10077. insuOrg := c.GetString("insuOrg")
  10078. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10079. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10080. var res ResultTwo
  10081. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10082. utils.ErrorLog("解析失败:%v", err)
  10083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10084. return
  10085. }
  10086. if res.Infcode == 0 {
  10087. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10088. if err == gorm.ErrRecordNotFound {
  10089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10090. return
  10091. } else if err != nil {
  10092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10093. return
  10094. } else {
  10095. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10096. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10097. infoStr := string(Iinfos)
  10098. idetinfoStr := string(Idetinfos)
  10099. psn := &models.HisPsn{
  10100. PsnNo: res.Output.Baseinfo.PsnNo,
  10101. PatientId: patient.ID,
  10102. Certno: res.Output.Baseinfo.Certno,
  10103. Gend: res.Output.Baseinfo.Gend,
  10104. Naty: res.Output.Baseinfo.Naty,
  10105. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10106. PsnName: res.Output.Baseinfo.PsnName,
  10107. Idetinfo: idetinfoStr,
  10108. Insuinfo: infoStr,
  10109. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10110. CardInfo: "",
  10111. Stage: "1",
  10112. VerifyNumber: ecToken,
  10113. InsuplcAdmdvs: insuOrg,
  10114. }
  10115. service.CreateHisPsn(psn)
  10116. var rf []*ResultFive
  10117. json.Unmarshal([]byte(infoStr), &rf)
  10118. var insutypes []*ResultFive
  10119. var insutype string
  10120. var is390 int = 0
  10121. var is310 int = 0
  10122. for _, item := range rf {
  10123. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10124. insutypes = append(insutypes, item)
  10125. }
  10126. }
  10127. if len(insutypes) == 1 {
  10128. insutype = insutypes[0].Insutype
  10129. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10130. } else {
  10131. for _, i := range insutypes {
  10132. if i.Insutype == "390" {
  10133. is390 = 1
  10134. }
  10135. if i.Insutype == "310" {
  10136. is310 = 1
  10137. }
  10138. }
  10139. }
  10140. if is390 == 1 {
  10141. insutype = "390"
  10142. }
  10143. if is310 == 1 {
  10144. insutype = "310"
  10145. }
  10146. if len(insutypes) == 0 {
  10147. insutype = "310"
  10148. }
  10149. c.ServeSuccessJSON(map[string]interface{}{
  10150. "patient": patient,
  10151. "number": ecToken,
  10152. "insutype": insutype,
  10153. })
  10154. }
  10155. } else {
  10156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10157. return
  10158. }
  10159. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10160. //if initFlag == 0 {
  10161. //c.TestGetJiangXiBasBaseInit()
  10162. //}
  10163. //if initEleFlag == 0 {
  10164. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10165. //}
  10166. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  10167. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  10168. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10169. type ELeData struct {
  10170. Data struct {
  10171. IdNo string `json:"idNo"`
  10172. IdType string `json:"idType"`
  10173. UserName string `json:"userName"`
  10174. EcToken string `json:"ecToken"`
  10175. InsuOrg string `json:"insuOrg"`
  10176. Gender string `json:"gender"`
  10177. Birthday string `json:"birthday"`
  10178. Nationality string `json:"nationality"`
  10179. Email string `json:"email"`
  10180. Extra string `json:"extra"`
  10181. } `json:"data"`
  10182. Code int `json:"code"`
  10183. Message string `json:"message"`
  10184. }
  10185. var ele ELeData
  10186. err := json.Unmarshal([]byte(result), &ele)
  10187. if err != nil {
  10188. utils.ErrorLog("解析失败:%v", err)
  10189. }
  10190. token := ele.Data.EcToken
  10191. token = Remove0000(token)
  10192. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  10193. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10194. var res ResultTwo
  10195. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10196. utils.ErrorLog("解析失败:%v", err)
  10197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10198. return
  10199. }
  10200. if res.Infcode == 0 {
  10201. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10202. if err == gorm.ErrRecordNotFound {
  10203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10204. return
  10205. } else if err != nil {
  10206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10207. return
  10208. } else {
  10209. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10210. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10211. infoStr := string(Iinfos)
  10212. idetinfoStr := string(Idetinfos)
  10213. psn := &models.HisPsn{
  10214. PsnNo: res.Output.Baseinfo.PsnNo,
  10215. PatientId: patient.ID,
  10216. Certno: res.Output.Baseinfo.Certno,
  10217. Gend: res.Output.Baseinfo.Gend,
  10218. Naty: res.Output.Baseinfo.Naty,
  10219. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10220. PsnName: res.Output.Baseinfo.PsnName,
  10221. Idetinfo: idetinfoStr,
  10222. Insuinfo: infoStr,
  10223. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10224. CardInfo: "",
  10225. VerifyNumber: token,
  10226. }
  10227. service.CreateHisPsn(psn)
  10228. var rf []*ResultFive
  10229. json.Unmarshal([]byte(infoStr), &rf)
  10230. var insutypes []*ResultFive
  10231. var insutype string
  10232. var is390 int = 0
  10233. var is310 int = 0
  10234. for _, item := range rf {
  10235. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10236. insutypes = append(insutypes, item)
  10237. }
  10238. }
  10239. if len(insutypes) == 1 {
  10240. insutype = insutypes[0].Insutype
  10241. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10242. } else {
  10243. for _, i := range insutypes {
  10244. if i.Insutype == "390" {
  10245. is390 = 1
  10246. }
  10247. if i.Insutype == "310" {
  10248. is310 = 1
  10249. }
  10250. }
  10251. }
  10252. if is390 == 1 {
  10253. insutype = "390"
  10254. }
  10255. if is310 == 1 {
  10256. insutype = "310"
  10257. }
  10258. if len(insutypes) == 0 {
  10259. insutype = "310"
  10260. }
  10261. c.ServeSuccessJSON(map[string]interface{}{
  10262. "patient": patient,
  10263. "number": token,
  10264. "insutype": insutype,
  10265. })
  10266. }
  10267. } else {
  10268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10269. return
  10270. }
  10271. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10272. //if initFlag == 0 {
  10273. c.TestGetJiangXiBasBaseInit()
  10274. //}
  10275. //if initEleFlag == 0 {
  10276. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10277. //}
  10278. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10279. type ELeData struct {
  10280. Data struct {
  10281. IdNo string `json:"idNo"`
  10282. IdType string `json:"idType"`
  10283. UserName string `json:"userName"`
  10284. EcToken string `json:"ecToken"`
  10285. InsuOrg string `json:"insuOrg"`
  10286. Gender string `json:"gender"`
  10287. Birthday string `json:"birthday"`
  10288. Nationality string `json:"nationality"`
  10289. Email string `json:"email"`
  10290. Extra string `json:"extra"`
  10291. } `json:"data"`
  10292. Code int `json:"code"`
  10293. Message string `json:"message"`
  10294. }
  10295. var ele ELeData
  10296. err := json.Unmarshal([]byte(json_result), &ele)
  10297. if err != nil {
  10298. utils.ErrorLog("解析失败:%v", err)
  10299. }
  10300. token := ele.Data.EcToken
  10301. token = Remove0000(token)
  10302. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  10303. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10304. var res ResultTwo
  10305. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10306. utils.ErrorLog("解析失败:%v", err)
  10307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10308. return
  10309. }
  10310. if res.Infcode == 0 {
  10311. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10312. if err == gorm.ErrRecordNotFound {
  10313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10314. return
  10315. } else if err != nil {
  10316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10317. return
  10318. } else {
  10319. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10320. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10321. infoStr := string(Iinfos)
  10322. idetinfoStr := string(Idetinfos)
  10323. psn := &models.HisPsn{
  10324. PsnNo: res.Output.Baseinfo.PsnNo,
  10325. PatientId: patient.ID,
  10326. Certno: res.Output.Baseinfo.Certno,
  10327. Gend: res.Output.Baseinfo.Gend,
  10328. Naty: res.Output.Baseinfo.Naty,
  10329. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10330. PsnName: res.Output.Baseinfo.PsnName,
  10331. Idetinfo: idetinfoStr,
  10332. Insuinfo: infoStr,
  10333. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10334. CardInfo: "",
  10335. VerifyNumber: token,
  10336. }
  10337. service.CreateHisPsn(psn)
  10338. var rf []*ResultFive
  10339. json.Unmarshal([]byte(infoStr), &rf)
  10340. var insutypes []*ResultFive
  10341. var insutype string
  10342. var is390 int = 0
  10343. var is310 int = 0
  10344. for _, item := range rf {
  10345. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10346. insutypes = append(insutypes, item)
  10347. }
  10348. }
  10349. if len(insutypes) == 1 {
  10350. insutype = insutypes[0].Insutype
  10351. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10352. } else {
  10353. for _, i := range insutypes {
  10354. if i.Insutype == "390" {
  10355. is390 = 1
  10356. }
  10357. if i.Insutype == "310" {
  10358. is310 = 1
  10359. }
  10360. }
  10361. }
  10362. if is390 == 1 {
  10363. insutype = "390"
  10364. }
  10365. if is310 == 1 {
  10366. insutype = "310"
  10367. }
  10368. if len(insutypes) == 0 {
  10369. insutype = "310"
  10370. }
  10371. c.ServeSuccessJSON(map[string]interface{}{
  10372. "patient": patient,
  10373. "number": token,
  10374. "insutype": insutype,
  10375. })
  10376. }
  10377. } else {
  10378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10379. return
  10380. }
  10381. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10382. type ELeData struct {
  10383. Code string `json:"code"`
  10384. Data struct {
  10385. Aac002 string `json:"aac002"`
  10386. Aaz500 string `json:"aaz500"`
  10387. ActCardNo string `json:"actCardNo"`
  10388. Bab520 string `json:"bab520"`
  10389. Bkz543 string `json:"bkz543"`
  10390. BusinessType string `json:"businessType"`
  10391. CertfCodg string `json:"certfCodg"`
  10392. EcIndexNo string `json:"ecIndexNo"`
  10393. EcToken string `json:"ecToken"`
  10394. ID0000 string `json:"id0000"`
  10395. IDNo string `json:"idNo"`
  10396. IDType string `json:"idType"`
  10397. Idcode string `json:"idcode"`
  10398. IdentityToken string `json:"identity_token"`
  10399. InsuOrg string `json:"insuOrg"`
  10400. OfficeID string `json:"officeId"`
  10401. OfficeName string `json:"officeName"`
  10402. OperatorID string `json:"operatorId"`
  10403. OperatorName string `json:"operatorName"`
  10404. OrgID string `json:"orgId"`
  10405. UserName string `json:"userName"`
  10406. } `json:"data"`
  10407. Infno interface{} `json:"infno"`
  10408. Message string `json:"message"`
  10409. OrgID string `json:"orgId"`
  10410. TransType string `json:"transType"`
  10411. }
  10412. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  10413. outPutInfo = Remove0000(outPutInfo)
  10414. if len(outPutInfo) > 0 {
  10415. var ele ELeData
  10416. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10417. if err != nil {
  10418. utils.ErrorLog("解析失败:%v", err)
  10419. }
  10420. token := ele.Data.EcToken
  10421. fmt.Println(inputInfo)
  10422. fmt.Println(outPutInfo)
  10423. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  10424. saveLog(result, requestLog, "1101", "获取人员信息")
  10425. var dat map[string]interface{}
  10426. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10427. fmt.Println(dat)
  10428. } else {
  10429. fmt.Println(err)
  10430. }
  10431. userJSONBytes, _ := json.Marshal(dat)
  10432. var res ResultTwo
  10433. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10434. utils.ErrorLog("解析失败:%v", err)
  10435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10436. return
  10437. }
  10438. res.ErrMsg = errMsgLog
  10439. if res.Infcode == 0 {
  10440. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10441. if err == gorm.ErrRecordNotFound {
  10442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10443. return
  10444. } else if err != nil {
  10445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10446. return
  10447. } else {
  10448. fmt.Println(res)
  10449. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10450. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10451. infoStr := string(Iinfos)
  10452. idetinfoStr := string(Idetinfos)
  10453. psn := &models.HisPsn{
  10454. PsnNo: res.Output.Baseinfo.PsnNo,
  10455. PatientId: patient.ID,
  10456. Certno: res.Output.Baseinfo.Certno,
  10457. Gend: res.Output.Baseinfo.Gend,
  10458. Naty: res.Output.Baseinfo.Naty,
  10459. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10460. PsnName: res.Output.Baseinfo.PsnName,
  10461. Idetinfo: idetinfoStr,
  10462. Insuinfo: infoStr,
  10463. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10464. CardInfo: outPutInfo,
  10465. VerifyNumber: token,
  10466. InsuplcAdmdvs: ele.Data.InsuOrg,
  10467. }
  10468. service.CreateHisPsn(psn)
  10469. var rf []*ResultFive
  10470. json.Unmarshal([]byte(infoStr), &rf)
  10471. var insutypes []*ResultFive
  10472. var insutype string
  10473. var is390 int = 0
  10474. var is310 int = 0
  10475. for _, item := range rf {
  10476. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10477. insutypes = append(insutypes, item)
  10478. }
  10479. }
  10480. if len(insutypes) == 1 {
  10481. insutype = insutypes[0].Insutype
  10482. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10483. } else {
  10484. for _, i := range insutypes {
  10485. if i.Insutype == "390" {
  10486. is390 = 1
  10487. }
  10488. if i.Insutype == "310" {
  10489. is310 = 1
  10490. }
  10491. }
  10492. }
  10493. if is390 == 1 {
  10494. insutype = "390"
  10495. }
  10496. if is310 == 1 {
  10497. insutype = "310"
  10498. }
  10499. if len(insutypes) == 0 {
  10500. insutype = "310"
  10501. }
  10502. c.ServeSuccessJSON(map[string]interface{}{
  10503. "patient": patient,
  10504. "number": token,
  10505. "insutype": insutype,
  10506. })
  10507. }
  10508. } else {
  10509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10510. return
  10511. }
  10512. }
  10513. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10514. var api string
  10515. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  10516. "&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
  10517. resp, requestErr := http.Get(api)
  10518. if requestErr != nil {
  10519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10520. return
  10521. }
  10522. body, ioErr := ioutil.ReadAll(resp.Body)
  10523. if ioErr != nil {
  10524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10526. return
  10527. }
  10528. var respJSON map[string]interface{}
  10529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10532. return
  10533. }
  10534. var status string
  10535. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10536. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10537. var token string
  10538. var res ResultTwo //1101结果
  10539. var res10265 ResultTwo10265 //1101结果
  10540. if status == "0" { //读卡成功
  10541. var card_info string //卡信息
  10542. var busi_card_info string
  10543. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10544. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10545. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10546. fmt.Println(card_info)
  10547. fmt.Println(busi_card_info)
  10548. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10549. result, _ := json.Marshal(respJSON)
  10550. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10551. utils.ErrorLog("解析失败:%v", err)
  10552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10553. return
  10554. }
  10555. res.ErrMsg = res10265.ErrMsg
  10556. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10557. res.Infcode = infocode
  10558. res.Output = res10265.Output
  10559. res.InfRefmsgid = res10265.InfRefmsgid
  10560. if res.Infcode == 0 {
  10561. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10562. if err == gorm.ErrRecordNotFound {
  10563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10564. return
  10565. } else if err != nil {
  10566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10567. return
  10568. } else {
  10569. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10570. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10571. infoStr := string(Iinfos)
  10572. idetinfoStr := string(Idetinfos)
  10573. psn := &models.HisPsn{
  10574. PsnNo: res.Output.Baseinfo.PsnNo,
  10575. PatientId: patient.ID,
  10576. Certno: res.Output.Baseinfo.Certno,
  10577. Gend: res.Output.Baseinfo.Gend,
  10578. Naty: res.Output.Baseinfo.Naty,
  10579. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10580. PsnName: res.Output.Baseinfo.PsnName,
  10581. Idetinfo: idetinfoStr,
  10582. Insuinfo: infoStr,
  10583. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10584. CardInfo: card_info,
  10585. VerifyNumber: token,
  10586. }
  10587. var rf []*ResultFive
  10588. json.Unmarshal([]byte(infoStr), &rf)
  10589. var insutypes []*ResultFive
  10590. var insutype string
  10591. var is390 int = 0
  10592. var is310 int = 0
  10593. for _, item := range rf {
  10594. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10595. insutypes = append(insutypes, item)
  10596. }
  10597. }
  10598. if len(insutypes) == 1 {
  10599. insutype = insutypes[0].Insutype
  10600. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10601. } else {
  10602. for _, i := range insutypes {
  10603. if i.Insutype == "390" {
  10604. is390 = 1
  10605. }
  10606. if i.Insutype == "310" {
  10607. is310 = 1
  10608. }
  10609. }
  10610. }
  10611. if is390 == 1 {
  10612. insutype = "390"
  10613. }
  10614. if is310 == 1 {
  10615. insutype = "310"
  10616. }
  10617. if len(insutypes) == 0 {
  10618. insutype = "310"
  10619. }
  10620. service.CreateHisPsn(psn)
  10621. c.ServeSuccessJSON(map[string]interface{}{
  10622. "patient": patient,
  10623. "number": token,
  10624. "insutype": insutype,
  10625. })
  10626. }
  10627. } else {
  10628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10629. return
  10630. }
  10631. } else { //读卡失败
  10632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10633. return
  10634. }
  10635. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10636. res := c.GetoleInfo()
  10637. if res.Infcode == 0 {
  10638. var result string
  10639. if res.Output.MdtrtCertType == "01" {
  10640. result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, 1, res.Output.PsnName, res.Output.EcToken, admin_user_id)
  10641. } else if res.Output.MdtrtCertType == "02" {
  10642. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  10643. } else if res.Output.MdtrtCertType == "03" {
  10644. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  10645. }
  10646. var dat map[string]interface{}
  10647. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10648. fmt.Println(dat)
  10649. } else {
  10650. fmt.Println(err)
  10651. }
  10652. userJSONBytes, _ := json.Marshal(dat)
  10653. var res2 ResultTwo
  10654. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10655. utils.ErrorLog("解析失败:%v", err)
  10656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10657. return
  10658. }
  10659. if res2.Infcode == 0 {
  10660. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10661. if err == gorm.ErrRecordNotFound {
  10662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10663. return
  10664. } else if err != nil {
  10665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10666. return
  10667. } else {
  10668. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10669. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10670. infoStr := string(Iinfos)
  10671. idetinfoStr := string(Idetinfos)
  10672. var rf []*ResultFive
  10673. json.Unmarshal([]byte(infoStr), &rf)
  10674. var insutypes []*ResultFive
  10675. var insutype string
  10676. var is390 int = 0
  10677. var is310 int = 0
  10678. //var insuplc_admdvs string
  10679. for _, item := range rf {
  10680. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10681. insutypes = append(insutypes, item)
  10682. }
  10683. }
  10684. if len(insutypes) == 1 {
  10685. insutype = insutypes[0].Insutype
  10686. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10687. } else {
  10688. for _, i := range insutypes {
  10689. if i.Insutype == "390" {
  10690. is390 = 1
  10691. }
  10692. if i.Insutype == "310" {
  10693. is310 = 1
  10694. }
  10695. }
  10696. }
  10697. if is390 == 1 {
  10698. insutype = "390"
  10699. }
  10700. if is310 == 1 {
  10701. insutype = "310"
  10702. }
  10703. if len(insutypes) == 0 {
  10704. insutype = "310"
  10705. }
  10706. psn := &models.HisPsn{
  10707. PsnNo: res2.Output.Baseinfo.PsnNo,
  10708. PatientId: patient.ID,
  10709. Certno: res2.Output.Baseinfo.Certno,
  10710. Gend: res2.Output.Baseinfo.Gend,
  10711. Naty: res2.Output.Baseinfo.Naty,
  10712. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10713. PsnName: res2.Output.Baseinfo.PsnName,
  10714. Idetinfo: idetinfoStr,
  10715. Insuinfo: infoStr,
  10716. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10717. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10718. VerifyNumber: res.Output.EcToken,
  10719. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10720. }
  10721. if res.Output.MdtrtCertType == "01" {
  10722. psn.VerifyNumber = res.Output.EcToken
  10723. //result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, 1, res.Output.PsnName, res.Output.EcToken,admin_user_id)
  10724. } else if res.Output.MdtrtCertType == "02" {
  10725. psn.VerifyNumber = res.Output.CardNo
  10726. //result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo,admin_user_id)
  10727. } else if res.Output.MdtrtCertType == "03" {
  10728. psn.VerifyNumber = res.Output.MdtrtCertNo
  10729. //result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo,admin_user_id)
  10730. }
  10731. service.CreateHisPsn(psn)
  10732. var balc float64
  10733. for _, item := range rf {
  10734. if item.Insutype == insutype {
  10735. balc = item.Balc
  10736. }
  10737. }
  10738. c.ServeSuccessJSON(map[string]interface{}{
  10739. "patient": patient,
  10740. "number": res.Output.CardNo,
  10741. "insutype": insutype,
  10742. "blac": balc,
  10743. "desc": idetinfoStr,
  10744. })
  10745. }
  10746. } else {
  10747. c.ServeSuccessJSON(map[string]interface{}{
  10748. "failed_code": -10,
  10749. "msg": res2.ErrMsg,
  10750. })
  10751. }
  10752. } else {
  10753. c.ServeSuccessJSON(map[string]interface{}{
  10754. "failed_code": -10,
  10755. "msg": res.ErrMsg,
  10756. })
  10757. }
  10758. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10759. var res ResultTwo
  10760. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10761. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10762. "&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)
  10763. resp, requestErr := http.Get(api)
  10764. if requestErr != nil {
  10765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10766. return
  10767. }
  10768. body, ioErr := ioutil.ReadAll(resp.Body)
  10769. if ioErr != nil {
  10770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10772. return
  10773. }
  10774. var respJSON map[string]interface{}
  10775. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10778. return
  10779. }
  10780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10781. result, _ := json.Marshal(respJSON)
  10782. fmt.Println("log")
  10783. fmt.Println(string(result))
  10784. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10785. utils.ErrorLog("解析失败:%v", err)
  10786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10787. return
  10788. }
  10789. if res.Infcode == 0 {
  10790. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10791. if err == gorm.ErrRecordNotFound {
  10792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10793. return
  10794. } else if err != nil {
  10795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10796. return
  10797. } else {
  10798. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10799. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10800. infoStr := string(Iinfos)
  10801. idetinfoStr := string(Idetinfos)
  10802. var rf []*ResultFive
  10803. json.Unmarshal([]byte(infoStr), &rf)
  10804. var insutypes []*ResultFive
  10805. var insutype string
  10806. var is390 int = 0
  10807. var is310 int = 0
  10808. for _, item := range rf {
  10809. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10810. insutypes = append(insutypes, item)
  10811. }
  10812. }
  10813. if len(insutypes) == 1 {
  10814. insutype = insutypes[0].Insutype
  10815. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10816. } else {
  10817. for _, i := range insutypes {
  10818. if i.Insutype == "390" {
  10819. is390 = 1
  10820. }
  10821. if i.Insutype == "310" {
  10822. is310 = 1
  10823. }
  10824. }
  10825. }
  10826. if is390 == 1 {
  10827. insutype = "390"
  10828. }
  10829. if is310 == 1 {
  10830. insutype = "310"
  10831. }
  10832. if len(insutypes) == 0 {
  10833. insutype = "390"
  10834. }
  10835. var insuplc_admdvs string
  10836. for _, item := range rf {
  10837. if item.Insutype == insutype {
  10838. insuplc_admdvs = item.InsuplcAdmdvs
  10839. }
  10840. }
  10841. psn := &models.HisPsn{
  10842. PsnNo: res.Output.Baseinfo.PsnNo,
  10843. PatientId: patient.ID,
  10844. Certno: res.Output.Baseinfo.Certno,
  10845. Gend: res.Output.Baseinfo.Gend,
  10846. Naty: res.Output.Baseinfo.Naty,
  10847. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10848. PsnName: res.Output.Baseinfo.PsnName,
  10849. Idetinfo: idetinfoStr,
  10850. Insuinfo: infoStr,
  10851. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10852. InsuplcAdmdvs: insuplc_admdvs,
  10853. }
  10854. service.CreateHisPsn(psn)
  10855. c.ServeSuccessJSON(map[string]interface{}{
  10856. "patient": patient,
  10857. "number": res.Output.Baseinfo.Certno,
  10858. })
  10859. }
  10860. } else {
  10861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10862. return
  10863. }
  10864. } else {
  10865. type ELeData struct {
  10866. Code string `json:"code"`
  10867. Data struct {
  10868. Aac002 string `json:"aac002"`
  10869. Aaz500 string `json:"aaz500"`
  10870. ActCardNo string `json:"actCardNo"`
  10871. Bab520 string `json:"bab520"`
  10872. Bkz543 string `json:"bkz543"`
  10873. BusinessType string `json:"businessType"`
  10874. CertfCodg string `json:"certfCodg"`
  10875. EcIndexNo string `json:"ecIndexNo"`
  10876. EcToken string `json:"ecToken"`
  10877. ID0000 string `json:"id0000"`
  10878. IDNo string `json:"idNo"`
  10879. IDType string `json:"idType"`
  10880. Idcode string `json:"idcode"`
  10881. IdentityToken string `json:"identity_token"`
  10882. InsuOrg string `json:"insuOrg"`
  10883. OfficeID string `json:"officeId"`
  10884. OfficeName string `json:"officeName"`
  10885. OperatorID string `json:"operatorId"`
  10886. OperatorName string `json:"operatorName"`
  10887. OrgID string `json:"orgId"`
  10888. UserName string `json:"userName"`
  10889. } `json:"data"`
  10890. Infno interface{} `json:"infno"`
  10891. Message string `json:"message"`
  10892. OrgID string `json:"orgId"`
  10893. TransType string `json:"transType"`
  10894. }
  10895. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  10896. fmt.Println(result)
  10897. outPutInfo := Remove0000(result)
  10898. fmt.Println(outPutInfo)
  10899. if len(outPutInfo) > 0 {
  10900. var ele ELeData
  10901. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10902. if err != nil {
  10903. utils.ErrorLog("解析失败:%v", err)
  10904. }
  10905. token := ele.Data.EcToken
  10906. fmt.Println(outPutInfo)
  10907. result, requestLog := service.Gdyb1101ForEleCert1111(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo, certificates)
  10908. saveLog(result, requestLog, "1101", "获取人员信息")
  10909. var dat map[string]interface{}
  10910. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10911. fmt.Println(dat)
  10912. } else {
  10913. fmt.Println(err)
  10914. }
  10915. userJSONBytes, _ := json.Marshal(dat)
  10916. var res ResultTwo
  10917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10918. utils.ErrorLog("解析失败:%v", err)
  10919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10920. return
  10921. }
  10922. if res.Infcode == 0 {
  10923. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10924. if err == gorm.ErrRecordNotFound {
  10925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10926. return
  10927. } else if err != nil {
  10928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10929. return
  10930. } else {
  10931. fmt.Println(res)
  10932. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10933. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10934. infoStr := string(Iinfos)
  10935. idetinfoStr := string(Idetinfos)
  10936. psn := &models.HisPsn{
  10937. PsnNo: res.Output.Baseinfo.PsnNo,
  10938. PatientId: patient.ID,
  10939. Certno: res.Output.Baseinfo.Certno,
  10940. Gend: res.Output.Baseinfo.Gend,
  10941. Naty: res.Output.Baseinfo.Naty,
  10942. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10943. PsnName: res.Output.Baseinfo.PsnName,
  10944. Idetinfo: idetinfoStr,
  10945. Insuinfo: infoStr,
  10946. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10947. CardInfo: outPutInfo,
  10948. VerifyNumber: token,
  10949. InsuplcAdmdvs: ele.Data.InsuOrg,
  10950. }
  10951. service.CreateHisPsn(psn)
  10952. var rf []*ResultFive
  10953. json.Unmarshal([]byte(infoStr), &rf)
  10954. var insutypes []*ResultFive
  10955. var insutype string
  10956. var is390 int = 0
  10957. var is310 int = 0
  10958. for _, item := range rf {
  10959. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10960. insutypes = append(insutypes, item)
  10961. }
  10962. }
  10963. if len(insutypes) == 1 {
  10964. insutype = insutypes[0].Insutype
  10965. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10966. } else {
  10967. for _, i := range insutypes {
  10968. if i.Insutype == "390" {
  10969. is390 = 1
  10970. }
  10971. if i.Insutype == "310" {
  10972. is310 = 1
  10973. }
  10974. }
  10975. }
  10976. if is390 == 1 {
  10977. insutype = "390"
  10978. }
  10979. if is310 == 1 {
  10980. insutype = "310"
  10981. }
  10982. if len(insutypes) == 0 {
  10983. insutype = "310"
  10984. }
  10985. c.ServeSuccessJSON(map[string]interface{}{
  10986. "patient": patient,
  10987. "number": token,
  10988. "insutype": insutype,
  10989. })
  10990. }
  10991. } else {
  10992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10993. return
  10994. }
  10995. }
  10996. //fmt.Println(result)
  10997. //
  10998. //if initFlag == 0 {
  10999. // c.TestGetBasBaseInit()
  11000. //}
  11001. //token := c.GetEleBaseInfo()
  11002. //
  11003. //token = Remove0000(token)
  11004. //
  11005. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  11006. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  11007. ////
  11008. //var res ResultTwo
  11009. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11010. // utils.ErrorLog("解析失败:%v", err)
  11011. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11012. // return
  11013. //}
  11014. //
  11015. //if res.Infcode == 0 {
  11016. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11017. // if err == gorm.ErrRecordNotFound {
  11018. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11019. // return
  11020. // } else if err != nil {
  11021. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11022. // return
  11023. //
  11024. // } else {
  11025. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11026. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11027. // infoStr := string(Iinfos)
  11028. // idetinfoStr := string(Idetinfos)
  11029. //
  11030. //
  11031. //
  11032. //
  11033. // var rf []*ResultFive
  11034. // json.Unmarshal([]byte(infoStr), &rf)
  11035. //
  11036. // var insutypes []*ResultFive
  11037. // var insutype string
  11038. // var is390 int = 0
  11039. // var is310 int = 0
  11040. // var insuplc_admdvs string
  11041. //
  11042. // for _, item := range rf {
  11043. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11044. // insutypes = append(insutypes, item)
  11045. // }
  11046. // }
  11047. //
  11048. // if len(insutypes) == 1 {
  11049. // insutype = insutypes[0].Insutype
  11050. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11051. // } else {
  11052. // for _, i := range insutypes {
  11053. // if i.Insutype == "390" {
  11054. // is390 = 1
  11055. // }
  11056. //
  11057. // if i.Insutype == "310" {
  11058. // is310 = 1
  11059. // }
  11060. // }
  11061. // }
  11062. // if is390 == 1 {
  11063. // insutype = "390"
  11064. // }
  11065. //
  11066. // if is310 == 1 {
  11067. // insutype = "310"
  11068. // }
  11069. // if len(insutypes) == 0 {
  11070. // insutype = "310"
  11071. // }
  11072. // for _, item := range rf {
  11073. // if item.Insutype == insutype {
  11074. // insuplc_admdvs = item.InsuplcAdmdvs
  11075. // }
  11076. // }
  11077. // psn := &models.HisPsn{
  11078. // PsnNo: res.Output.Baseinfo.PsnNo,
  11079. // Age: res.Output.Baseinfo.Age,
  11080. // PatientId: patient.ID,
  11081. // Certno: res.Output.Baseinfo.Certno,
  11082. // Brdy: res.Output.Baseinfo.Brdy,
  11083. // Gend: res.Output.Baseinfo.Gend,
  11084. // Naty: res.Output.Baseinfo.Naty,
  11085. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  11086. // PsnName: res.Output.Baseinfo.PsnName,
  11087. // Idetinfo: idetinfoStr,
  11088. // Insuinfo: infoStr,
  11089. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11090. // CardInfo: "",
  11091. // VerifyNumber: token,
  11092. // InsuplcAdmdvs: insuplc_admdvs,
  11093. // }
  11094. // service.CreateHisPsn(psn)
  11095. //
  11096. // c.ServeSuccessJSON(map[string]interface{}{
  11097. // "patient": patient,
  11098. // "number": token,
  11099. // })
  11100. // }
  11101. //} else {
  11102. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11103. // return
  11104. //}
  11105. }
  11106. break
  11107. case 5:
  11108. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11109. var api string
  11110. if miConfig.MdtrtareaAdmvs == "320921" {
  11111. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  11112. "&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
  11113. fmt.Println(api)
  11114. } else {
  11115. 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 +
  11116. "&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)
  11117. }
  11118. resp, requestErr := http.Get(api)
  11119. if requestErr != nil {
  11120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11121. return
  11122. }
  11123. body, ioErr := ioutil.ReadAll(resp.Body)
  11124. if ioErr != nil {
  11125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11127. return
  11128. }
  11129. var respJSON map[string]interface{}
  11130. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11133. return
  11134. }
  11135. var status string
  11136. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11137. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11138. var token string
  11139. var res ResultTwo //1101结果
  11140. var res10265 ResultTwo10265 //1101结果
  11141. if status == "0" { //读卡成功
  11142. var card_info string //卡信息
  11143. //var busi_card_info string
  11144. var auth_info string
  11145. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11146. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11147. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11148. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  11149. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11150. result, _ := json.Marshal(respJSON)
  11151. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11152. utils.ErrorLog("解析失败:%v", err)
  11153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11154. return
  11155. }
  11156. res.ErrMsg = res10265.ErrMsg
  11157. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11158. res.Infcode = infocode
  11159. res.Output = res10265.Output
  11160. res.InfRefmsgid = res10265.InfRefmsgid
  11161. if res.Infcode == 0 {
  11162. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11163. if err == gorm.ErrRecordNotFound {
  11164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11165. return
  11166. } else if err != nil {
  11167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11168. return
  11169. } else {
  11170. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11171. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11172. infoStr := string(Iinfos)
  11173. idetinfoStr := string(Idetinfos)
  11174. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  11175. psn := &models.HisPsn{
  11176. PsnNo: res.Output.Baseinfo.PsnNo,
  11177. PatientId: patient.ID,
  11178. Certno: res.Output.Baseinfo.Certno,
  11179. Gend: res.Output.Baseinfo.Gend,
  11180. Brdy: b,
  11181. Age: float64(age),
  11182. Naty: res.Output.Baseinfo.Naty,
  11183. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11184. PsnName: res.Output.Baseinfo.PsnName,
  11185. Idetinfo: idetinfoStr,
  11186. Insuinfo: infoStr,
  11187. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11188. CardInfo: card_info,
  11189. VerifyNumber: token,
  11190. AuthInfo: auth_info,
  11191. }
  11192. var rf []*ResultFive
  11193. json.Unmarshal([]byte(infoStr), &rf)
  11194. var insutypes []*ResultFive
  11195. var insutype string
  11196. var is390 int = 0
  11197. var is310 int = 0
  11198. for _, item := range rf {
  11199. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11200. insutypes = append(insutypes, item)
  11201. }
  11202. }
  11203. if len(insutypes) == 1 {
  11204. insutype = insutypes[0].Insutype
  11205. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11206. } else {
  11207. for _, i := range insutypes {
  11208. if i.Insutype == "390" {
  11209. is390 = 1
  11210. }
  11211. if i.Insutype == "310" {
  11212. is310 = 1
  11213. }
  11214. }
  11215. }
  11216. if is390 == 1 {
  11217. insutype = "390"
  11218. }
  11219. if is310 == 1 {
  11220. insutype = "310"
  11221. }
  11222. if len(insutypes) == 0 {
  11223. insutype = "310"
  11224. }
  11225. service.CreateHisPsn(psn)
  11226. c.ServeSuccessJSON(map[string]interface{}{
  11227. "patient": patient,
  11228. "number": token,
  11229. "insutype": insutype,
  11230. })
  11231. }
  11232. } else {
  11233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11234. return
  11235. }
  11236. } else { //读卡失败
  11237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11238. return
  11239. }
  11240. }
  11241. break
  11242. }
  11243. }
  11244. var initFlag int64 = 0
  11245. var initEleFlag int64 = 0
  11246. func (c *HisApiController) TestGetBasBaseInit() {
  11247. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11248. Iinit := DllDef.MustFindProc("Init")
  11249. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11250. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  11251. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  11252. if ret != 0 {
  11253. fmt.Println("SSCard的报错原因:", err)
  11254. fmt.Println("SSCard的运算结果为:", ret)
  11255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11256. return
  11257. }
  11258. result := int(ret)
  11259. fmt.Println("SSCard的运算结果为1:", result)
  11260. initFlag = 1
  11261. return
  11262. }
  11263. func (c *HisApiController) HandleJiangXiReadCard() {
  11264. fmt.Println("~~~~~~")
  11265. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11266. admin_user_id, _ := c.GetInt64("admin_user_id")
  11267. id_card_type, _ := c.GetInt64("id_card_type")
  11268. //certificates, _ := c.GetInt64("certificates")
  11269. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11270. if initFlag == 0 {
  11271. c.TestGetJiangXiBasBaseInit()
  11272. }
  11273. basStr := c.GetBasBaseInfo()
  11274. if len(basStr) == 0 {
  11275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11276. return
  11277. }
  11278. fmt.Println(basStr)
  11279. bas := strings.Split(basStr, "|")
  11280. basNumber := bas[1]
  11281. fmt.Println(basNumber)
  11282. card_sn := bas[3]
  11283. fmt.Println(card_sn)
  11284. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  11285. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  11286. var dat map[string]interface{}
  11287. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11288. fmt.Println(dat)
  11289. } else {
  11290. fmt.Println(err)
  11291. }
  11292. userJSONBytes, _ := json.Marshal(dat)
  11293. var res ResultTwo
  11294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11295. utils.ErrorLog("解析失败:%v", err)
  11296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11297. return
  11298. }
  11299. if res.Infcode == 0 {
  11300. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  11301. if err == gorm.ErrRecordNotFound {
  11302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11303. return
  11304. } else if err != nil {
  11305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11306. return
  11307. } else {
  11308. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11309. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11310. infoStr := string(Iinfos)
  11311. idetinfoStr := string(Idetinfos)
  11312. psn := &models.HisPsn{
  11313. PsnNo: res.Output.Baseinfo.PsnNo,
  11314. PatientId: patient.ID,
  11315. Certno: res.Output.Baseinfo.Certno,
  11316. Gend: res.Output.Baseinfo.Gend,
  11317. Naty: res.Output.Baseinfo.Naty,
  11318. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11319. PsnName: res.Output.Baseinfo.PsnName,
  11320. Idetinfo: idetinfoStr,
  11321. Insuinfo: infoStr,
  11322. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11323. CardInfo: basStr,
  11324. VerifyNumber: "",
  11325. }
  11326. service.CreateHisPsn(psn)
  11327. c.ServeSuccessJSON(map[string]interface{}{
  11328. "patient": patient,
  11329. "number": basNumber,
  11330. })
  11331. }
  11332. } else {
  11333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11334. return
  11335. }
  11336. }
  11337. func (c *HisApiController) TestGetHnBasBaseInit() {
  11338. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11339. Iinit := DllDef.MustFindProc("Init")
  11340. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11341. //http://10.77.211.236/CSB/hsa-fsi-1303
  11342. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  11343. if ret != 0 {
  11344. fmt.Println("SSCard的报错原因:", err)
  11345. fmt.Println("SSCard的运算结果为:", ret)
  11346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11347. return
  11348. }
  11349. result := int(ret)
  11350. fmt.Println("SSCard的运算结果为1:", result)
  11351. initFlag = 1
  11352. return
  11353. }
  11354. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  11355. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11356. Iinit := DllDef.MustFindProc("Init")
  11357. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11358. //http://10.77.211.236/CSB/hsa-fsi-1303
  11359. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  11360. if ret != 0 {
  11361. fmt.Println("SSCard的报错原因:", err)
  11362. fmt.Println("SSCard的运算结果为:", ret)
  11363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11364. return
  11365. }
  11366. result := int(ret)
  11367. fmt.Println("SSCard的运算结果为1:", result)
  11368. initFlag = 1
  11369. return
  11370. }
  11371. func (c *HisApiController) GetSFZBaseInfo() string {
  11372. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11373. readCard := DllDef.MustFindProc("ReadSFZ")
  11374. if readCard == nil {
  11375. fmt.Println("readcard is nil")
  11376. readCard = DllDef.MustFindProc("ReadSFZ")
  11377. }
  11378. str := make([]byte, 8096)
  11379. str1 := make([]byte, 8096)
  11380. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  11381. fmt.Println(r)
  11382. return Remove0000(string(str))
  11383. }
  11384. func (c *HisApiController) GetEleBaseInfo() string {
  11385. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11386. readCard := DllDef.MustFindProc("GetQRBase")
  11387. fmt.Println(readCard)
  11388. if readCard == nil {
  11389. fmt.Println("readcard is nil")
  11390. readCard = DllDef.MustFindProc("GetQRBase")
  11391. }
  11392. str := make([]byte, 1024)
  11393. str1 := make([]byte, 1024)
  11394. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11395. fmt.Println(ret2)
  11396. fmt.Println(string(str1))
  11397. fmt.Println(string(str))
  11398. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11399. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11400. if ret2 != 0 {
  11401. return ""
  11402. }
  11403. return string(str)
  11404. }
  11405. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11406. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11407. readCard := DllDef.MustFindProc("NationEcTrans")
  11408. fmt.Println(readCard)
  11409. fmt.Println("!!!!!")
  11410. pBusiCardInfo := make([]byte, 2048)
  11411. input := make(map[string]interface{})
  11412. inputData := make(map[string]interface{})
  11413. inputData["orgId"] = code
  11414. inputData["businessType"] = "01101"
  11415. inputData["operatorId"] = "1"
  11416. inputData["operatorName"] = "admin"
  11417. inputData["officeId"] = "001"
  11418. inputData["officeName"] = "血透室"
  11419. inputData["deviceType"] = ""
  11420. input["data"] = inputData
  11421. input["orgId"] = code
  11422. input["transType"] = "ec.query"
  11423. bytesData, _ := json.Marshal(input)
  11424. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11425. fmt.Println(ret2)
  11426. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11427. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11428. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  11429. }
  11430. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11431. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11432. readCard := DllDef.MustFindProc("NationEcTrans")
  11433. fmt.Println(readCard)
  11434. fmt.Println("!!!!!")
  11435. pBusiCardInfo := make([]byte, 2048)
  11436. input := make(map[string]interface{})
  11437. inputData := make(map[string]interface{})
  11438. inputData["orgId"] = code
  11439. inputData["businessType"] = "01101"
  11440. inputData["operatorId"] = "9"
  11441. inputData["operatorName"] = "admin"
  11442. inputData["officeId"] = "001"
  11443. inputData["officeName"] = "血透室"
  11444. inputData["deviceType"] = ""
  11445. input["data"] = inputData
  11446. input["orgId"] = code
  11447. input["transType"] = "ec.query"
  11448. bytesData, _ := json.Marshal(input)
  11449. ret2, _, _ := readCard.Call(StrPtr("http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11450. fmt.Println(ret2)
  11451. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11452. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11453. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11454. }
  11455. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  11456. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11457. readCard := DllDef.MustFindProc("NationEcTrans")
  11458. fmt.Println(readCard)
  11459. fmt.Println("!!!!!")
  11460. pBusiCardInfo := make([]byte, 2048)
  11461. input := make(map[string]interface{})
  11462. inputData := make(map[string]interface{})
  11463. inputData["orgId"] = code
  11464. inputData["businessType"] = "01301"
  11465. inputData["operatorId"] = "9"
  11466. inputData["operatorName"] = "admin"
  11467. inputData["officeId"] = "001"
  11468. inputData["officeName"] = "血透室"
  11469. inputData["deviceType"] = ""
  11470. input["data"] = inputData
  11471. input["orgId"] = code
  11472. input["transType"] = "ec.query"
  11473. bytesData, _ := json.Marshal(input)
  11474. ret2, _, _ := readCard.Call(StrPtr("http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11475. fmt.Println(ret2)
  11476. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11477. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11478. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11479. }
  11480. func GetJxEleBaseInfo(org_id int64) string {
  11481. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11482. readCard := DllDef.MustFindProc("NationEcTrans")
  11483. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11484. if readCard == nil {
  11485. fmt.Println("readcard is nil")
  11486. readCard = DllDef.MustFindProc("NationEcTrans")
  11487. }
  11488. str1 := make([]byte, 1024)
  11489. data := make(map[string]interface{})
  11490. inputData := make(map[string]interface{})
  11491. inputData["orgId"] = miConfig.Code
  11492. inputData["businessType"] = "01101"
  11493. inputData["operatorId"] = "test001"
  11494. inputData["operatorName"] = "cn"
  11495. inputData["officeId"] = "32760"
  11496. inputData["officeName"] = "waike"
  11497. inputData["deviceType"] = ""
  11498. data["data"] = inputData
  11499. data["transType"] = "ec.query"
  11500. data["extra "] = ""
  11501. data["orgId"] = miConfig.Code
  11502. bytesData, _ := json.Marshal(data)
  11503. //bytesData, _ := json.Marshal(data)
  11504. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11505. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11506. fmt.Println(ret2)
  11507. fmt.Println(string(str1))
  11508. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11509. if ret2 != 0 {
  11510. return ""
  11511. }
  11512. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11513. }
  11514. func GetJxEleBaseInitInfo(org_id int64) string {
  11515. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11516. readCard := DllDef.MustFindProc("NationEcTrans")
  11517. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11518. if readCard == nil {
  11519. fmt.Println("readcard is nil")
  11520. readCard = DllDef.MustFindProc("NationEcTrans")
  11521. }
  11522. str1 := make([]byte, 2048)
  11523. data := make(map[string]interface{})
  11524. inputData := make(map[string]interface{})
  11525. inputData["orgId"] = miConfig.Code
  11526. inputData["businessType"] = "01101"
  11527. inputData["operatorId"] = "1"
  11528. inputData["operatorName"] = "huangchuang"
  11529. inputData["officeId"] = "101"
  11530. inputData["officeName"] = "xuetou"
  11531. inputData["deviceType"] = ""
  11532. data["data"] = inputData
  11533. data["transType"] = "ec.query"
  11534. data["orgId"] = miConfig.Code
  11535. bytesData, _ := json.Marshal(data)
  11536. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11537. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11538. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  11539. fmt.Println(ret2)
  11540. fmt.Println(string(str1))
  11541. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11542. if ret2 != 0 {
  11543. return ""
  11544. }
  11545. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  11546. initEleFlag = 1
  11547. }
  11548. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11549. }
  11550. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  11551. // // 构建命令
  11552. // cmd := exec.Command("python", "b.py")
  11553. //
  11554. // // 执行命令并等待完成
  11555. // output, err := cmd.CombinedOutput()
  11556. // if err != nil {
  11557. // fmt.Println("Error executing Python script:", err)
  11558. // return
  11559. // }
  11560. //
  11561. // // 打印Python脚本的输出
  11562. // fmt.Println(string(output))
  11563. //}
  11564. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  11565. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  11566. readCard := DllDef.MustFindProc("gxyb_call")
  11567. if readCard == nil {
  11568. fmt.Println("readcard is nil")
  11569. readCard = DllDef.MustFindProc("gxyb_call")
  11570. }
  11571. str := make([]byte, 1024)
  11572. str1 := make([]byte, 1024)
  11573. //data := make(map[string]interface{})
  11574. currentTime := time.Now()
  11575. // 格式化时间为 "YYYYMMDDHH24MISS"
  11576. formattedTime := currentTime.Format("20060102150405")
  11577. inputData := make(map[string]interface{})
  11578. inputData2 := make(map[string]interface{})
  11579. inputData["transNo"] = "1401"
  11580. inputData["transType"] = "passwordCheck"
  11581. inputData["timestamp"] = formattedTime
  11582. inputData2["fixmedinsCode"] = code
  11583. inputData2["psnNo"] = ""
  11584. inputData["data"] = inputData2
  11585. jsonBytes, err := json.Marshal(inputData)
  11586. if err != nil {
  11587. fmt.Println("Error encoding map to JSON:", err)
  11588. }
  11589. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11590. fmt.Println(string(str1))
  11591. fmt.Println(string(str))
  11592. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11593. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11594. if ret2 != 0 {
  11595. return ""
  11596. }
  11597. return string(str)
  11598. }
  11599. func (c *HisApiController) GetoleInfo() Response {
  11600. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  11601. defer ole.CoUninitialize()
  11602. // Replace with the ProgID or CLSID of your COM object
  11603. progID := "YinHai.XJ.Actual.Interface.New"
  11604. // Create COM object
  11605. unknown, err := oleutil.CreateObject(progID)
  11606. if err != nil {
  11607. fmt.Println("Unable to create COM object:", err)
  11608. }
  11609. defer unknown.Release()
  11610. // Query for the IDispatch interface
  11611. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  11612. if err != nil {
  11613. fmt.Println("Unable to get IDispatch interface:", err)
  11614. }
  11615. defer dispatch.Release()
  11616. // Prepare parameters
  11617. transNo := "1401"
  11618. transType := "passwordCheck"
  11619. timestamp := time.Now().Unix()
  11620. fixmedinsCode := "H45072101171"
  11621. psnNo := ""
  11622. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  11623. result2 := ""
  11624. // Call COM object's method using the IDispatch interface
  11625. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  11626. fmt.Println(resulr)
  11627. fmt.Println(result2)
  11628. if err != nil {
  11629. fmt.Println("调用COM对象方法失败:", err)
  11630. }
  11631. var response Response
  11632. err2 := json.Unmarshal([]byte(result2), &response)
  11633. if err2 != nil {
  11634. fmt.Println("解析JSON失败:", err)
  11635. }
  11636. return response
  11637. }
  11638. func (c *HisApiController) GetBasBaseInfo() string {
  11639. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11640. readCard := DllDef.MustFindProc("ReadCardBas")
  11641. if readCard == nil {
  11642. fmt.Println("readcard is nil")
  11643. readCard = DllDef.MustFindProc("ReadCardBas")
  11644. }
  11645. str := make([]byte, 1024)
  11646. str1 := make([]byte, 1024)
  11647. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11648. fmt.Println(string(str1))
  11649. fmt.Println(string(str))
  11650. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11651. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11652. if ret2 != 0 {
  11653. return ""
  11654. }
  11655. return string(str)
  11656. }
  11657. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  11658. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  11659. readCard := DllDef.MustFindProc("read_cardinfo")
  11660. if readCard == nil {
  11661. fmt.Println("readcard is nil")
  11662. readCard = DllDef.MustFindProc("read_cardinfo")
  11663. }
  11664. str := make([]byte, 1024) //卡号
  11665. str1 := make([]byte, 1024) //卡识别码
  11666. str2 := make([]byte, 1024) //身份证号
  11667. str3 := make([]byte, 1024) //姓名
  11668. str4 := make([]byte, 1024) //错误信息
  11669. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  11670. fmt.Println(string(str1))
  11671. fmt.Println(string(str))
  11672. fmt.Println(string(str2))
  11673. fmt.Println(string(str3))
  11674. fmt.Println(string(str4))
  11675. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11676. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11677. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  11678. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  11679. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  11680. if ret2 != 0 {
  11681. return "", "", "", "", ""
  11682. }
  11683. return string(str), string(str1), string(str2), string(str3), string(str4)
  11684. }
  11685. type CustomFundPay struct {
  11686. FundPayType string `json:"fund_pay_type"`
  11687. FundPayamt float64 `json:"fund_payamt"`
  11688. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11689. }
  11690. //func (c *HisApiController) GetBatchSettleList() {
  11691. // start_time_str := c.GetString("start_time")
  11692. // //end_time_str := c.GetString("end_time")
  11693. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11694. //
  11695. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  11696. //
  11697. // for _, item := range orders {
  11698. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  11699. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11700. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11701. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11702. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11703. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11704. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11705. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11706. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11707. //
  11708. // if order.ID == 0 {
  11709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11710. // return
  11711. // }
  11712. //
  11713. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11714. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11715. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11716. // //fmt.Println(count)
  11717. // //var zero string
  11718. // //number := count + 1
  11719. // //if number >= 1000 {
  11720. // // zero = "0000" + strconv.FormatInt(number, 10)
  11721. // //} else if number >= 10000 {
  11722. // // zero = "000" + strconv.FormatInt(number, 10)
  11723. // //} else if number >= 100000 {
  11724. // // zero = "00" + strconv.FormatInt(number, 10)
  11725. // //} else if number >= 1000000 {
  11726. // // zero = "0" + strconv.FormatInt(number, 10)
  11727. // //} else {
  11728. // // zero = strconv.FormatInt(number, 10)
  11729. // //}
  11730. // //fmt.Println(zero)
  11731. //
  11732. // struct4101 := service.Struct4101{
  11733. // PsnNo: order.PsnNo,
  11734. // MdtrtId: order.MdtrtId,
  11735. // SetlId: order.SetlId,
  11736. // PsnName: order.PsnName,
  11737. // Gend: order.Gend,
  11738. // Brdy: his.Brdy,
  11739. // Age: his.Age,
  11740. // Naty: order.Naty,
  11741. // PatnCertType: "01",
  11742. // Certno: order.Certno,
  11743. // Prfs: "90",
  11744. // ConerName: roles[0].UserName,
  11745. // PatnRlts: "99",
  11746. // ConerAddr: miConfig.OrgName,
  11747. // ConerTel: admin.Mobile,
  11748. // HiType: order.Insutype,
  11749. // Insuplc: miConfig.InsuplcAdmdvs,
  11750. // MaindiagFlag: "1",
  11751. // BillCode: order.SetlId,
  11752. // BillNo: order.SetlId,
  11753. // BizSn: order.Number,
  11754. // PsnSelfPay: order.PsnPartAmt,
  11755. // PsnOwnPay: order.PsnPartAmt,
  11756. // AcctPay: order.AcctPay,
  11757. // PsnCashpay: order.PsnCashPay,
  11758. // HiPaymtd: "1",
  11759. // Hsorg: miConfig.InsuplcAdmdvs,
  11760. // HsorgOpter: miConfig.InsuplcAdmdvs,
  11761. // MedinsFillPsn: curRoles.UserName,
  11762. // MedinsFillDept: miConfig.OrgName,
  11763. // IptMedType: "2",
  11764. // }
  11765. // struct4101.SetlBegnDate = order.SetlTime
  11766. // struct4101.SetlEndDate = order.SetlTime
  11767. // time_arr := strings.Split(order.SetlTime, " ")
  11768. // struct4101.AdmTime = time_arr[0]
  11769. // struct4101.AdmEndTime = time_arr[0]
  11770. //
  11771. // var rf []CustomFundPay
  11772. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  11773. //
  11774. // var tempFunPays []service.CustomStruct
  11775. // for _, item := range rf {
  11776. // var tempFunPay service.CustomStruct
  11777. // tempFunPay.FundPayamt = item.FundPayamt
  11778. // tempFunPay.FundPayType = item.FundPayType
  11779. // tempFunPays = append(tempFunPays, tempFunPay)
  11780. // }
  11781. // struct4101.CustomStruct = tempFunPays
  11782. //
  11783. // var tempDiaginfos []service.DiaginfoStructTwo
  11784. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11785. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11786. //
  11787. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11788. // var config []*models.HisXtDiagnoseConfig
  11789. // for _, item := range diagnosis_ids {
  11790. // id, _ := strconv.ParseInt(item, 10, 64)
  11791. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  11792. // config = append(config, &diagnosisConfig)
  11793. // }
  11794. //
  11795. // for index, item := range config {
  11796. // if index == 0 {
  11797. // var tempDiaginfo service.DiaginfoStructTwo
  11798. // tempDiaginfo.DiagCode = item.CountryCode
  11799. // tempDiaginfo.DiagName = item.CountryContentName
  11800. // tempDiaginfo.DiagType = "1"
  11801. // tempDiaginfo.MaindiagFlag = "1"
  11802. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11803. // } else {
  11804. // var tempDiaginfo service.DiaginfoStructTwo
  11805. // tempDiaginfo.DiagCode = item.CountryCode
  11806. // tempDiaginfo.DiagName = item.CountryContentName
  11807. // tempDiaginfo.DiagType = "1"
  11808. // tempDiaginfo.MaindiagFlag = "0"
  11809. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11810. // }
  11811. // }
  11812. // struct4101.Diseinfo = tempDiaginfos
  11813. //
  11814. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  11815. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11816. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11817. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11818. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11819. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11820. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11821. //
  11822. // var iteminfo service.IteminfoStruct
  11823. //
  11824. // var bedCostTotal float64 = 0 //床位总费
  11825. // var bedCostSelfTotal float64 = 0 //床位自费
  11826. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11827. //
  11828. // var operationCostTotal float64 = 0 //手术费
  11829. // var operationCostSelfTotal float64 = 0 //手术费
  11830. // var operationCostPartSelfTotal float64 = 0 //手术费
  11831. //
  11832. // var otherCostTotal float64 = 0 //其他费用
  11833. // var otherCostSelfTotal float64 = 0 //其他费用
  11834. // var otherCostPartSelfTotal float64 = 0 //其他费用
  11835. //
  11836. // var materialCostTotal float64 = 0 //材料费
  11837. // var materialCostSelfTotal float64 = 0 //材料费
  11838. // var materialCostPartSelfTotal float64 = 0 //材料费
  11839. //
  11840. // var westernMedicineCostTotal float64 = 0 //西药费
  11841. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  11842. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11843. //
  11844. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11845. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11846. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11847. //
  11848. // var checkCostTotal float64 = 0 //检查费
  11849. // var checkCostSelfTotal float64 = 0 //检查费
  11850. // var checkCostPartSelfTotal float64 = 0 //检查费
  11851. //
  11852. // var laboratoryCostTotal float64 = 0 //化验费
  11853. // var laboratoryCostSelfTotal float64 = 0 //化验费
  11854. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11855. //
  11856. // var treatCostTotal float64 = 0 //治疗费用
  11857. // var treatCostSelfTotal float64 = 0 //治疗费用
  11858. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  11859. //
  11860. // decimal.DivisionPrecision = 2
  11861. //
  11862. // var bed_fulamt_ownpay_amt float64 = 0
  11863. // var operation_fulamt_ownpay_amt float64 = 0
  11864. // var other_fulamt_ownpay_amt float64 = 0
  11865. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  11866. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11867. // var check_fulamt_ownpay_amt float64 = 0
  11868. // var material_fulamt_ownpay_amt float64 = 0
  11869. // var laboratory_fulamt_ownpay_amt float64 = 0
  11870. // var treat_fulamt_ownpay_amt float64 = 0
  11871. //
  11872. // var bed_claa_sunmfee float64 = 0
  11873. // var bed_clab_amt float64 = 0
  11874. // var bed_other_amt float64 = 0
  11875. //
  11876. // var operation_claa_sunmfee float64 = 0
  11877. // var operation_clab_amt float64 = 0
  11878. // var operation_other_amt float64 = 0
  11879. //
  11880. // var other_claa_sunmfee float64 = 0
  11881. // var other_clab_amt float64 = 0
  11882. // var other_other_amt float64 = 0
  11883. //
  11884. // var westernMedicine_claa_sunmfee float64 = 0
  11885. // var westernMedicine_clab_amt float64 = 0
  11886. // var westernMedicine_other_amt float64 = 0
  11887. //
  11888. // var chineseTraditional_claa_sunmfee float64 = 0
  11889. // var chineseTraditional_clab_amt float64 = 0
  11890. // var chineseTraditional_other_amt float64 = 0
  11891. //
  11892. // var check_claa_sunmfee float64 = 0
  11893. // var check_clab_amt float64 = 0
  11894. // var check_other_amt float64 = 0
  11895. //
  11896. // var material_claa_sunmfee float64 = 0
  11897. // var material_clab_amt float64 = 0
  11898. // var material_other_amt float64 = 0
  11899. //
  11900. // var laboratory_claa_sunmfee float64 = 0
  11901. // var laboratory_clab_amt float64 = 0
  11902. // var laboratory_other_amt float64 = 0
  11903. //
  11904. // var treat_claa_sunmfee float64 = 0
  11905. // var treat_clab_amt float64 = 0
  11906. // var treat_other_amt float64 = 0
  11907. //
  11908. // for _, item := range order.HisOrderInfo {
  11909. // if item.MedChrgitmType == "01" { //床位费
  11910. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11911. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11912. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11913. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11914. // if item.ChrgitmLv == "1" {
  11915. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11916. // }
  11917. // if item.ChrgitmLv == "2" {
  11918. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11919. //
  11920. // }
  11921. // if item.ChrgitmLv == "3" {
  11922. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11923. // }
  11924. //
  11925. // }
  11926. //
  11927. // if item.MedChrgitmType == "03" { //检查费
  11928. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11929. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11930. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11931. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11932. // if item.ChrgitmLv == "1" {
  11933. //
  11934. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11935. //
  11936. // }
  11937. // if item.ChrgitmLv == "2" {
  11938. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11939. //
  11940. // }
  11941. // if item.ChrgitmLv == "3" {
  11942. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11943. // }
  11944. // }
  11945. //
  11946. // if item.MedChrgitmType == "04" { //化验费
  11947. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11948. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11949. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11950. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11951. // if item.ChrgitmLv == "1" {
  11952. //
  11953. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11954. //
  11955. // }
  11956. // if item.ChrgitmLv == "2" {
  11957. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11958. //
  11959. // }
  11960. // if item.ChrgitmLv == "3" {
  11961. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11962. // }
  11963. // }
  11964. //
  11965. // if item.MedChrgitmType == "05" { //治疗费
  11966. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11967. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11968. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11969. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11970. // if item.ChrgitmLv == "1" {
  11971. //
  11972. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11973. //
  11974. // }
  11975. // if item.ChrgitmLv == "2" {
  11976. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11977. //
  11978. // }
  11979. // if item.ChrgitmLv == "3" {
  11980. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11981. // }
  11982. // }
  11983. //
  11984. // if item.MedChrgitmType == "06" { //手术费
  11985. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11986. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11987. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11988. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11989. //
  11990. // if item.ChrgitmLv == "1" {
  11991. //
  11992. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11993. //
  11994. // }
  11995. // if item.ChrgitmLv == "2" {
  11996. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11997. //
  11998. // }
  11999. // if item.ChrgitmLv == "3" {
  12000. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12001. // }
  12002. // }
  12003. //
  12004. // if item.MedChrgitmType == "08" { //材料费
  12005. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12006. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12007. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12008. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12009. // if item.ChrgitmLv == "1" {
  12010. //
  12011. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12012. //
  12013. // }
  12014. // if item.ChrgitmLv == "2" {
  12015. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12016. //
  12017. // }
  12018. // if item.ChrgitmLv == "3" {
  12019. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12020. // }
  12021. // }
  12022. //
  12023. // if item.MedChrgitmType == "09" { //西药费
  12024. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12025. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12026. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12027. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12028. // if item.ChrgitmLv == "1" {
  12029. //
  12030. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12031. //
  12032. // }
  12033. // if item.ChrgitmLv == "2" {
  12034. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12035. //
  12036. // }
  12037. // if item.ChrgitmLv == "3" {
  12038. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12039. // }
  12040. // }
  12041. //
  12042. // if item.MedChrgitmType == "11" { //中成费
  12043. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12044. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12045. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12046. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12047. // if item.ChrgitmLv == "1" {
  12048. //
  12049. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12050. //
  12051. // }
  12052. // if item.ChrgitmLv == "2" {
  12053. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12054. //
  12055. // }
  12056. // if item.ChrgitmLv == "3" {
  12057. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12058. // }
  12059. // }
  12060. //
  12061. // if item.MedChrgitmType == "14" { //其他费
  12062. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12063. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12064. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12065. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12066. // if item.ChrgitmLv == "1" {
  12067. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12068. //
  12069. // }
  12070. // if item.ChrgitmLv == "2" {
  12071. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12072. //
  12073. // }
  12074. // if item.ChrgitmLv == "3" {
  12075. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12076. // }
  12077. // }
  12078. //
  12079. // }
  12080. //
  12081. // var iteminfoStructs []service.IteminfoStruct
  12082. //
  12083. // if bedCostTotal != 0 {
  12084. // iteminfo.MedChrgitm = "01"
  12085. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12086. // iteminfo.Amt = bedCostTotal
  12087. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  12088. // iteminfo.ClabAmt = bed_clab_amt
  12089. // iteminfo.OthAmt = bed_other_amt
  12090. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12091. // }
  12092. //
  12093. // if checkCostTotal != 0 {
  12094. // iteminfo.MedChrgitm = "03"
  12095. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12096. // iteminfo.Amt = checkCostTotal
  12097. // iteminfo.ClaaSumfee = check_claa_sunmfee
  12098. // iteminfo.ClabAmt = check_clab_amt
  12099. // iteminfo.OthAmt = check_other_amt
  12100. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12101. //
  12102. // }
  12103. //
  12104. // if laboratoryCostTotal != 0 {
  12105. // iteminfo.MedChrgitm = "04"
  12106. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12107. // iteminfo.Amt = laboratoryCostTotal
  12108. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12109. // iteminfo.ClabAmt = laboratory_clab_amt
  12110. // iteminfo.OthAmt = laboratory_other_amt
  12111. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12112. //
  12113. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12114. //
  12115. // }
  12116. //
  12117. // if treatCostTotal != 0 {
  12118. // iteminfo.MedChrgitm = "05"
  12119. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12120. // iteminfo.Amt = treatCostTotal
  12121. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  12122. // iteminfo.ClabAmt = treat_clab_amt
  12123. // iteminfo.OthAmt = treat_other_amt
  12124. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12125. // //(struct4101.IteminfoStruct, iteminfo)
  12126. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12127. // }
  12128. //
  12129. // if operationCostTotal != 0 {
  12130. // iteminfo.MedChrgitm = "06"
  12131. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12132. // iteminfo.Amt = operationCostTotal
  12133. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  12134. // iteminfo.ClabAmt = operation_clab_amt
  12135. // iteminfo.OthAmt = operation_other_amt
  12136. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12137. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12138. // }
  12139. //
  12140. // if materialCostTotal != 0 {
  12141. // iteminfo.MedChrgitm = "08"
  12142. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12143. // iteminfo.Amt = materialCostTotal
  12144. // iteminfo.ClaaSumfee = material_claa_sunmfee
  12145. // iteminfo.ClabAmt = material_clab_amt
  12146. // iteminfo.OthAmt = material_other_amt
  12147. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12148. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12149. // }
  12150. //
  12151. // if westernMedicineCostTotal != 0 {
  12152. // iteminfo.MedChrgitm = "09"
  12153. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12154. // iteminfo.Amt = westernMedicineCostTotal
  12155. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12156. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12157. // iteminfo.OthAmt = westernMedicine_other_amt
  12158. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12159. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12160. //
  12161. // }
  12162. // if chineseTraditionalMedicineCostTotal != 0 {
  12163. // iteminfo.MedChrgitm = "11"
  12164. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12165. // iteminfo.Amt = westernMedicineCostTotal
  12166. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12167. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12168. // iteminfo.OthAmt = westernMedicine_other_amt
  12169. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12170. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12171. //
  12172. // }
  12173. // if otherCostTotal != 0 {
  12174. // iteminfo.MedChrgitm = "14"
  12175. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12176. // iteminfo.Amt = otherCostTotal
  12177. // iteminfo.ClaaSumfee = other_claa_sunmfee
  12178. // iteminfo.ClabAmt = other_clab_amt
  12179. // iteminfo.OthAmt = other_other_amt
  12180. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12181. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12182. //
  12183. // }
  12184. // struct4101.IteminfoStruct = iteminfoStructs
  12185. // struct4101.Ntly = "中国"
  12186. // struct4101.AdmCaty = "A03.06"
  12187. //
  12188. // struct4101.DoctorName = doctor.UserName
  12189. // struct4101.DoctorCode = doctor.DoctorNumber
  12190. //
  12191. // var res ResultSeventeen
  12192. //
  12193. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12194. // struct4101.BillCode = order.Number
  12195. // struct4101.BillNo = order.SetlId
  12196. // var resOther ResultSeventeenOther
  12197. // var pp models.PublicParams
  12198. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12199. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12200. // pp.FixmedinsName = miConfig.OrgName
  12201. // pp.FixmedinsCode = miConfig.Code
  12202. // pp.RequestUrl = miConfig.Url
  12203. // pp.Cainfo = miConfig.Cainfo
  12204. // pp.SecretKey = miConfig.SecretKey
  12205. // pp.AccessKey = miConfig.AccessKey
  12206. // pp.OpterName = curRoles.UserName
  12207. //
  12208. // client := &http.Client{}
  12209. // var req *http.Request
  12210. // data := make(map[string]interface{})
  12211. // data["struct4101"] = struct4101
  12212. // data["pp"] = pp
  12213. // bytesData, _ := json.Marshal(data)
  12214. // if miConfig.MdtrtareaAdmvs == "320921" {
  12215. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12216. // } else {
  12217. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12218. // }
  12219. // resp, _ := client.Do(req)
  12220. // defer resp.Body.Close()
  12221. // body, ioErr := ioutil.ReadAll(resp.Body)
  12222. // if ioErr != nil {
  12223. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12224. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12225. // return
  12226. // }
  12227. // var respJSON map[string]interface{}
  12228. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12229. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12230. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12231. // return
  12232. // }
  12233. //
  12234. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12235. // userJSONBytes, _ := json.Marshal(respJSON)
  12236. // fmt.Println("log")
  12237. // fmt.Println(string(userJSONBytes))
  12238. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12239. // utils.ErrorLog("解析失败:%v", err)
  12240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12241. // return
  12242. // }
  12243. // res.InfRefmsgid = resOther.InfRefmsgid
  12244. // res.Output = resOther.Output
  12245. // res.ErrMsg = resOther.ErrMsg
  12246. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12247. // res.Infcode = infocode
  12248. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  12249. //
  12250. // var pp models.PublicParams
  12251. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12252. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12253. // pp.FixmedinsName = miConfig.OrgName
  12254. // pp.FixmedinsCode = miConfig.Code
  12255. // pp.RequestUrl = miConfig.Url
  12256. // pp.Cainfo = miConfig.Cainfo
  12257. // pp.SecretKey = miConfig.SecretKey
  12258. // pp.AccessKey = miConfig.AccessKey
  12259. // pp.OpterName = curRoles.UserName
  12260. // result, _ := service.Jxyb4101(struct4101, pp)
  12261. // var dat map[string]interface{}
  12262. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12263. // fmt.Println(dat)
  12264. // } else {
  12265. // fmt.Println(err)
  12266. // }
  12267. // userJSONBytes, _ := json.Marshal(dat)
  12268. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12269. // utils.ErrorLog("解析失败:%v", err)
  12270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12271. // return
  12272. // }
  12273. //
  12274. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  12275. // var pp models.PublicParams
  12276. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12277. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12278. // pp.FixmedinsName = miConfig.OrgName
  12279. // pp.FixmedinsCode = miConfig.Code
  12280. // pp.RequestUrl = miConfig.Url
  12281. // pp.Cainfo = miConfig.Cainfo
  12282. // pp.SecretKey = miConfig.SecretKey
  12283. // pp.AccessKey = miConfig.AccessKey
  12284. // pp.OpterName = curRoles.UserName
  12285. // result, _ := service.Hnyb4101(struct4101, pp)
  12286. // var dat map[string]interface{}
  12287. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12288. // fmt.Println(dat)
  12289. // } else {
  12290. // fmt.Println(err)
  12291. // }
  12292. // userJSONBytes, _ := json.Marshal(dat)
  12293. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12294. // utils.ErrorLog("解析失败:%v", err)
  12295. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12296. // return
  12297. // }
  12298. //
  12299. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  12300. // var resOther ResultSeventeenOther
  12301. //
  12302. // var pp models.PublicParams
  12303. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12304. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12305. // pp.FixmedinsName = miConfig.OrgName
  12306. // pp.FixmedinsCode = miConfig.Code
  12307. // pp.RequestUrl = miConfig.Url
  12308. // pp.Cainfo = miConfig.Cainfo
  12309. // pp.SecretKey = miConfig.SecretKey
  12310. // pp.AccessKey = miConfig.AccessKey
  12311. // pp.OpterName = curRoles.UserName
  12312. // client := &http.Client{}
  12313. // var req *http.Request
  12314. // data := make(map[string]interface{})
  12315. // data["struct4101"] = struct4101
  12316. // data["pp"] = pp
  12317. // bytesData, _ := json.Marshal(data)
  12318. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12319. // resp, _ := client.Do(req)
  12320. // defer resp.Body.Close()
  12321. // body, ioErr := ioutil.ReadAll(resp.Body)
  12322. // if ioErr != nil {
  12323. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12325. // return
  12326. // }
  12327. // var respJSON map[string]interface{}
  12328. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12329. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12331. // return
  12332. // }
  12333. //
  12334. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12335. // userJSONBytes, _ := json.Marshal(respJSON)
  12336. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12337. // utils.ErrorLog("解析失败:%v", err)
  12338. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12339. // return
  12340. // }
  12341. // res.InfRefmsgid = resOther.InfRefmsgid
  12342. // res.Output = resOther.Output
  12343. // res.ErrMsg = resOther.ErrMsg
  12344. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12345. // res.Infcode = infocode
  12346. //
  12347. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  12348. // var pp models.PublicParams
  12349. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12350. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12351. // pp.FixmedinsName = miConfig.OrgName
  12352. // pp.FixmedinsCode = miConfig.Code
  12353. // pp.RequestUrl = miConfig.Url
  12354. // pp.Cainfo = miConfig.Cainfo
  12355. // pp.SecretKey = miConfig.SecretKey
  12356. // pp.AccessKey = miConfig.AccessKey
  12357. // pp.OpterName = curRoles.UserName
  12358. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12359. // fmt.Println(requestLog)
  12360. // fmt.Println(errMsgLog)
  12361. //
  12362. // saveLog(result, requestLog, "4101a", "上传清单")
  12363. //
  12364. // var dat map[string]interface{}
  12365. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12366. // fmt.Println(dat)
  12367. // } else {
  12368. // fmt.Println(err)
  12369. // }
  12370. // userJSONBytes, _ := json.Marshal(dat)
  12371. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12372. // utils.ErrorLog("解析失败:%v", err)
  12373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12374. // return
  12375. // }
  12376. //
  12377. // } else {
  12378. //
  12379. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  12380. // var dat map[string]interface{}
  12381. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12382. // fmt.Println(dat)
  12383. // } else {
  12384. // fmt.Println(err)
  12385. // }
  12386. // userJSONBytes, _ := json.Marshal(dat)
  12387. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12388. // utils.ErrorLog("解析失败:%v", err)
  12389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12390. // return
  12391. // }
  12392. // }
  12393. //
  12394. // if res.Infcode != 0 {
  12395. // adminUser := c.GetAdminUserInfo()
  12396. // errlog := &models.HisOrderError{
  12397. // UserOrgId: adminUser.CurrentOrgId,
  12398. // Ctime: time.Now().Unix(),
  12399. // Mtime: time.Now().Unix(),
  12400. // ErrMsg: res.ErrMsg,
  12401. // Status: 1,
  12402. // PatientId: order.ID,
  12403. // Stage: 10265,
  12404. // }
  12405. // service.CreateErrMsgLog(errlog)
  12406. // continue
  12407. // } else {
  12408. // //order.FaPiaoNumber = zero
  12409. // //order.FaPiaoCode = last_order.FaPiaoCode
  12410. // //service.UpdateOrder(order)
  12411. // hisFundSettleListResult := &models.HisFundSettleListResult{
  12412. // Number: res.Output.SetlListId,
  12413. // Status: 1,
  12414. // Ctime: time.Now().Unix(),
  12415. // Mtime: time.Now().Unix(),
  12416. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12417. // IsUpload: 1,
  12418. // OrderId: order.ID,
  12419. // }
  12420. // service.CreateUploadRecord(hisFundSettleListResult)
  12421. // c.ServeSuccessJSON(map[string]interface{}{
  12422. // "msg": "上传成功",
  12423. // "result": hisFundSettleListResult,
  12424. // })
  12425. // continue
  12426. // }
  12427. // }
  12428. //}
  12429. func (c *HisApiController) GetbatchSettleList() {
  12430. //order_id, _ := c.GetInt64("order_id")
  12431. admin_user_id, _ := c.GetInt64("admin_user_id")
  12432. orders, _ := service.GetAllHisOrderTwo10485()
  12433. for _, item := range orders {
  12434. order, _ := service.GetHisOrderByIDTwo(item.ID)
  12435. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12436. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12437. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12438. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12439. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12440. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12441. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12442. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12443. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12444. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12445. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12446. //fmt.Println(count)
  12447. //var zero string
  12448. //number := count + 1
  12449. //if number >= 1000 {
  12450. // zero = "0000" + strconv.FormatInt(number, 10)
  12451. //} else if number >= 10000 {
  12452. // zero = "000" + strconv.FormatInt(number, 10)
  12453. //} else if number >= 100000 {
  12454. // zero = "00" + strconv.FormatInt(number, 10)
  12455. //} else if number >= 1000000 {
  12456. // zero = "0" + strconv.FormatInt(number, 10)
  12457. //} else {
  12458. // zero = strconv.FormatInt(number, 10)
  12459. //}
  12460. //fmt.Println(zero)
  12461. struct4101 := service.Struct4101{
  12462. PsnNo: order.PsnNo,
  12463. MdtrtId: order.MdtrtId,
  12464. SetlId: order.SetlId,
  12465. PsnName: order.PsnName,
  12466. Gend: order.Gend,
  12467. Brdy: his.Brdy,
  12468. Age: his.Age,
  12469. Naty: order.Naty,
  12470. PatnCertType: "01",
  12471. Certno: order.Certno,
  12472. Prfs: "90",
  12473. ConerName: roles[0].UserName,
  12474. PatnRlts: "99",
  12475. ConerAddr: miConfig.OrgName,
  12476. ConerTel: admin.Mobile,
  12477. HiType: order.Insutype,
  12478. Insuplc: miConfig.InsuplcAdmdvs,
  12479. MaindiagFlag: "1",
  12480. BillCode: order.SetlId,
  12481. BillNo: order.SetlId,
  12482. BizSn: order.Number,
  12483. PsnSelfPay: order.PsnPartAmt,
  12484. PsnOwnPay: order.PsnPartAmt,
  12485. AcctPay: order.AcctPay,
  12486. PsnCashpay: order.PsnCashPay,
  12487. HiPaymtd: "1",
  12488. Hsorg: miConfig.InsuplcAdmdvs,
  12489. HsorgOpter: miConfig.InsuplcAdmdvs,
  12490. MedinsFillPsn: curRoles.UserName,
  12491. MedinsFillDept: miConfig.OrgName,
  12492. IptMedType: "2",
  12493. }
  12494. struct4101.SetlBegnDate = order.SetlTime
  12495. struct4101.SetlEndDate = order.SetlTime
  12496. time_arr := strings.Split(order.SetlTime, " ")
  12497. struct4101.AdmTime = time_arr[0]
  12498. struct4101.AdmEndTime = time_arr[0]
  12499. //var rf []CustomFundPay
  12500. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12501. //
  12502. //var tempFunPays []service.CustomStruct
  12503. //for _, item := range rf {
  12504. // var tempFunPay service.CustomStruct
  12505. // tempFunPay.FundPayamt = item.FundPayamt
  12506. // tempFunPay.FundPayType = item.FundPayType
  12507. // tempFunPays = append(tempFunPays, tempFunPay)
  12508. //}
  12509. //struct4101.CustomStruct = tempFunPays
  12510. var tempDiaginfos []service.DiaginfoStructTwo
  12511. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12512. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12513. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12514. var config []*models.HisXtDiagnoseConfig
  12515. for _, item := range diagnosis_ids {
  12516. id, _ := strconv.ParseInt(item, 10, 64)
  12517. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12518. config = append(config, &diagnosisConfig)
  12519. }
  12520. for index, item := range config {
  12521. if index == 0 {
  12522. var tempDiaginfo service.DiaginfoStructTwo
  12523. tempDiaginfo.DiagCode = item.CountryCode
  12524. tempDiaginfo.DiagName = item.CountryContentName
  12525. tempDiaginfo.DiagType = "1"
  12526. tempDiaginfo.MaindiagFlag = "1"
  12527. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12528. } else {
  12529. var tempDiaginfo service.DiaginfoStructTwo
  12530. tempDiaginfo.DiagCode = item.CountryCode
  12531. tempDiaginfo.DiagName = item.CountryContentName
  12532. tempDiaginfo.DiagType = "1"
  12533. tempDiaginfo.MaindiagFlag = "0"
  12534. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12535. }
  12536. }
  12537. struct4101.Diseinfo = tempDiaginfos
  12538. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12539. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12540. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12541. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12542. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12543. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12544. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12545. var iteminfo service.IteminfoStruct
  12546. var bedCostTotal float64 = 0 //床位总费
  12547. var bedCostSelfTotal float64 = 0 //床位自费
  12548. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12549. var operationCostTotal float64 = 0 //手术费
  12550. var operationCostSelfTotal float64 = 0 //手术费
  12551. var operationCostPartSelfTotal float64 = 0 //手术费
  12552. var otherCostTotal float64 = 0 //其他费用
  12553. var otherCostSelfTotal float64 = 0 //其他费用
  12554. var otherCostPartSelfTotal float64 = 0 //其他费用
  12555. var materialCostTotal float64 = 0 //材料费
  12556. var materialCostSelfTotal float64 = 0 //材料费
  12557. var materialCostPartSelfTotal float64 = 0 //材料费
  12558. var westernMedicineCostTotal float64 = 0 //西药费
  12559. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12560. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12561. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12562. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12563. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12564. var checkCostTotal float64 = 0 //检查费
  12565. var checkCostSelfTotal float64 = 0 //检查费
  12566. var checkCostPartSelfTotal float64 = 0 //检查费
  12567. var laboratoryCostTotal float64 = 0 //化验费
  12568. var laboratoryCostSelfTotal float64 = 0 //化验费
  12569. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12570. var treatCostTotal float64 = 0 //治疗费用
  12571. var treatCostSelfTotal float64 = 0 //治疗费用
  12572. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12573. decimal.DivisionPrecision = 2
  12574. var bed_fulamt_ownpay_amt float64 = 0
  12575. var operation_fulamt_ownpay_amt float64 = 0
  12576. var other_fulamt_ownpay_amt float64 = 0
  12577. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12578. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12579. var check_fulamt_ownpay_amt float64 = 0
  12580. var material_fulamt_ownpay_amt float64 = 0
  12581. var laboratory_fulamt_ownpay_amt float64 = 0
  12582. var treat_fulamt_ownpay_amt float64 = 0
  12583. var bed_claa_sunmfee float64 = 0
  12584. var bed_clab_amt float64 = 0
  12585. var bed_other_amt float64 = 0
  12586. var operation_claa_sunmfee float64 = 0
  12587. var operation_clab_amt float64 = 0
  12588. var operation_other_amt float64 = 0
  12589. var other_claa_sunmfee float64 = 0
  12590. var other_clab_amt float64 = 0
  12591. var other_other_amt float64 = 0
  12592. var westernMedicine_claa_sunmfee float64 = 0
  12593. var westernMedicine_clab_amt float64 = 0
  12594. var westernMedicine_other_amt float64 = 0
  12595. var chineseTraditional_claa_sunmfee float64 = 0
  12596. var chineseTraditional_clab_amt float64 = 0
  12597. var chineseTraditional_other_amt float64 = 0
  12598. var check_claa_sunmfee float64 = 0
  12599. var check_clab_amt float64 = 0
  12600. var check_other_amt float64 = 0
  12601. var material_claa_sunmfee float64 = 0
  12602. var material_clab_amt float64 = 0
  12603. var material_other_amt float64 = 0
  12604. var laboratory_claa_sunmfee float64 = 0
  12605. var laboratory_clab_amt float64 = 0
  12606. var laboratory_other_amt float64 = 0
  12607. var treat_claa_sunmfee float64 = 0
  12608. var treat_clab_amt float64 = 0
  12609. var treat_other_amt float64 = 0
  12610. for _, item := range order.HisOrderInfo {
  12611. if item.MedChrgitmType == "01" { //床位费
  12612. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12613. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12614. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12615. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12616. if item.ChrgitmLv == "1" {
  12617. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12618. }
  12619. if item.ChrgitmLv == "2" {
  12620. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12621. }
  12622. if item.ChrgitmLv == "3" {
  12623. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12624. }
  12625. }
  12626. if item.MedChrgitmType == "03" { //检查费
  12627. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12628. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12629. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12630. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12631. if item.ChrgitmLv == "1" {
  12632. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12633. }
  12634. if item.ChrgitmLv == "2" {
  12635. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12636. }
  12637. if item.ChrgitmLv == "3" {
  12638. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12639. }
  12640. }
  12641. if item.MedChrgitmType == "04" { //化验费
  12642. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12643. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12644. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12645. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12646. if item.ChrgitmLv == "1" {
  12647. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12648. }
  12649. if item.ChrgitmLv == "2" {
  12650. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12651. }
  12652. if item.ChrgitmLv == "3" {
  12653. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12654. }
  12655. }
  12656. if item.MedChrgitmType == "05" { //治疗费
  12657. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12658. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12659. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12660. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12661. if item.ChrgitmLv == "1" {
  12662. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12663. }
  12664. if item.ChrgitmLv == "2" {
  12665. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12666. }
  12667. if item.ChrgitmLv == "3" {
  12668. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12669. }
  12670. }
  12671. if item.MedChrgitmType == "06" { //手术费
  12672. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12673. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12674. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12675. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12676. if item.ChrgitmLv == "1" {
  12677. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12678. }
  12679. if item.ChrgitmLv == "2" {
  12680. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12681. }
  12682. if item.ChrgitmLv == "3" {
  12683. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12684. }
  12685. }
  12686. if item.MedChrgitmType == "08" { //材料费
  12687. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12688. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12689. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12690. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12691. if item.ChrgitmLv == "1" {
  12692. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12693. }
  12694. if item.ChrgitmLv == "2" {
  12695. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12696. }
  12697. if item.ChrgitmLv == "3" {
  12698. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12699. }
  12700. }
  12701. if item.MedChrgitmType == "09" { //西药费
  12702. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12703. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12704. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12705. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12706. if item.ChrgitmLv == "1" {
  12707. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12708. }
  12709. if item.ChrgitmLv == "2" {
  12710. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12711. }
  12712. if item.ChrgitmLv == "3" {
  12713. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12714. }
  12715. }
  12716. if item.MedChrgitmType == "11" { //中成费
  12717. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12718. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12719. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12720. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12721. if item.ChrgitmLv == "1" {
  12722. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12723. }
  12724. if item.ChrgitmLv == "2" {
  12725. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12726. }
  12727. if item.ChrgitmLv == "3" {
  12728. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12729. }
  12730. }
  12731. if item.MedChrgitmType == "14" { //其他费
  12732. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12733. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12734. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12735. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12736. if item.ChrgitmLv == "1" {
  12737. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12738. }
  12739. if item.ChrgitmLv == "2" {
  12740. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12741. }
  12742. if item.ChrgitmLv == "3" {
  12743. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12744. }
  12745. }
  12746. }
  12747. var iteminfoStructs []service.IteminfoStruct
  12748. if bedCostTotal != 0 {
  12749. iteminfo.MedChrgitm = "01"
  12750. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12751. iteminfo.Amt = bedCostTotal
  12752. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12753. iteminfo.ClabAmt = bed_clab_amt
  12754. iteminfo.OthAmt = bed_other_amt
  12755. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12756. }
  12757. if checkCostTotal != 0 {
  12758. iteminfo.MedChrgitm = "03"
  12759. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12760. iteminfo.Amt = checkCostTotal
  12761. iteminfo.ClaaSumfee = check_claa_sunmfee
  12762. iteminfo.ClabAmt = check_clab_amt
  12763. iteminfo.OthAmt = check_other_amt
  12764. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12765. }
  12766. if laboratoryCostTotal != 0 {
  12767. iteminfo.MedChrgitm = "04"
  12768. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12769. iteminfo.Amt = laboratoryCostTotal
  12770. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12771. iteminfo.ClabAmt = laboratory_clab_amt
  12772. iteminfo.OthAmt = laboratory_other_amt
  12773. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12774. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12775. }
  12776. if treatCostTotal != 0 {
  12777. iteminfo.MedChrgitm = "05"
  12778. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12779. iteminfo.Amt = treatCostTotal
  12780. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12781. iteminfo.ClabAmt = treat_clab_amt
  12782. iteminfo.OthAmt = treat_other_amt
  12783. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12784. //(struct4101.IteminfoStruct, iteminfo)
  12785. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12786. }
  12787. if operationCostTotal != 0 {
  12788. iteminfo.MedChrgitm = "06"
  12789. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12790. iteminfo.Amt = operationCostTotal
  12791. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12792. iteminfo.ClabAmt = operation_clab_amt
  12793. iteminfo.OthAmt = operation_other_amt
  12794. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12795. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12796. }
  12797. if materialCostTotal != 0 {
  12798. iteminfo.MedChrgitm = "08"
  12799. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12800. iteminfo.Amt = materialCostTotal
  12801. iteminfo.ClaaSumfee = material_claa_sunmfee
  12802. iteminfo.ClabAmt = material_clab_amt
  12803. iteminfo.OthAmt = material_other_amt
  12804. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12805. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12806. }
  12807. if westernMedicineCostTotal != 0 {
  12808. iteminfo.MedChrgitm = "09"
  12809. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12810. iteminfo.Amt = westernMedicineCostTotal
  12811. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12812. iteminfo.ClabAmt = westernMedicine_clab_amt
  12813. iteminfo.OthAmt = westernMedicine_other_amt
  12814. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12815. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12816. }
  12817. if chineseTraditionalMedicineCostTotal != 0 {
  12818. iteminfo.MedChrgitm = "11"
  12819. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12820. iteminfo.Amt = westernMedicineCostTotal
  12821. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12822. iteminfo.ClabAmt = westernMedicine_clab_amt
  12823. iteminfo.OthAmt = westernMedicine_other_amt
  12824. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12825. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12826. }
  12827. if otherCostTotal != 0 {
  12828. iteminfo.MedChrgitm = "14"
  12829. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12830. iteminfo.Amt = otherCostTotal
  12831. iteminfo.ClaaSumfee = other_claa_sunmfee
  12832. iteminfo.ClabAmt = other_clab_amt
  12833. iteminfo.OthAmt = other_other_amt
  12834. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12835. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12836. }
  12837. struct4101.IteminfoStruct = iteminfoStructs
  12838. struct4101.Ntly = "中国"
  12839. struct4101.AdmCaty = "A03.06"
  12840. struct4101.DoctorName = doctor.UserName
  12841. struct4101.DoctorCode = doctor.DoctorNumber
  12842. var res ResultSeventeen
  12843. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12844. struct4101.BillCode = order.Number
  12845. struct4101.BillNo = order.SetlId
  12846. var resOther ResultSeventeenOther
  12847. var pp models.PublicParams
  12848. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12849. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12850. pp.FixmedinsName = miConfig.OrgName
  12851. pp.FixmedinsCode = miConfig.Code
  12852. pp.RequestUrl = miConfig.Url
  12853. pp.Cainfo = miConfig.Cainfo
  12854. pp.SecretKey = miConfig.SecretKey
  12855. pp.AccessKey = miConfig.AccessKey
  12856. pp.OpterName = curRoles.UserName
  12857. client := &http.Client{}
  12858. var req *http.Request
  12859. data := make(map[string]interface{})
  12860. data["struct4101"] = struct4101
  12861. data["pp"] = pp
  12862. bytesData, _ := json.Marshal(data)
  12863. if miConfig.MdtrtareaAdmvs == "320921" {
  12864. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12865. } else {
  12866. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12867. }
  12868. resp, _ := client.Do(req)
  12869. defer resp.Body.Close()
  12870. body, ioErr := ioutil.ReadAll(resp.Body)
  12871. if ioErr != nil {
  12872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12874. return
  12875. }
  12876. var respJSON map[string]interface{}
  12877. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12880. return
  12881. }
  12882. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12883. userJSONBytes, _ := json.Marshal(respJSON)
  12884. fmt.Println("log")
  12885. fmt.Println(string(userJSONBytes))
  12886. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12887. utils.ErrorLog("解析失败:%v", err)
  12888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12889. return
  12890. }
  12891. res.InfRefmsgid = resOther.InfRefmsgid
  12892. res.Output = resOther.Output
  12893. res.ErrMsg = resOther.ErrMsg
  12894. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12895. res.Infcode = infocode
  12896. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12897. var pp models.PublicParams
  12898. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12899. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12900. pp.FixmedinsName = miConfig.OrgName
  12901. pp.FixmedinsCode = miConfig.Code
  12902. pp.RequestUrl = miConfig.Url
  12903. pp.Cainfo = miConfig.Cainfo
  12904. pp.SecretKey = miConfig.SecretKey
  12905. pp.AccessKey = miConfig.AccessKey
  12906. pp.OpterName = curRoles.UserName
  12907. result, _ := service.Jxyb4101(struct4101, pp)
  12908. var dat map[string]interface{}
  12909. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12910. fmt.Println(dat)
  12911. } else {
  12912. fmt.Println(err)
  12913. }
  12914. userJSONBytes, _ := json.Marshal(dat)
  12915. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12916. utils.ErrorLog("解析失败:%v", err)
  12917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12918. return
  12919. }
  12920. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12921. var pp models.PublicParams
  12922. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12923. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12924. pp.FixmedinsName = miConfig.OrgName
  12925. pp.FixmedinsCode = miConfig.Code
  12926. pp.RequestUrl = miConfig.Url
  12927. pp.Cainfo = miConfig.Cainfo
  12928. pp.SecretKey = miConfig.SecretKey
  12929. pp.AccessKey = miConfig.AccessKey
  12930. pp.OpterName = curRoles.UserName
  12931. result, _ := service.Hnyb4101(struct4101, pp)
  12932. var dat map[string]interface{}
  12933. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12934. fmt.Println(dat)
  12935. } else {
  12936. fmt.Println(err)
  12937. }
  12938. userJSONBytes, _ := json.Marshal(dat)
  12939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12940. utils.ErrorLog("解析失败:%v", err)
  12941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12942. return
  12943. }
  12944. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12945. var resOther ResultSeventeenOther
  12946. var pp models.PublicParams
  12947. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12948. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12949. pp.FixmedinsName = miConfig.OrgName
  12950. pp.FixmedinsCode = miConfig.Code
  12951. pp.RequestUrl = miConfig.Url
  12952. pp.Cainfo = miConfig.Cainfo
  12953. pp.SecretKey = miConfig.SecretKey
  12954. pp.AccessKey = miConfig.AccessKey
  12955. pp.OpterName = curRoles.UserName
  12956. client := &http.Client{}
  12957. var req *http.Request
  12958. data := make(map[string]interface{})
  12959. data["struct4101"] = struct4101
  12960. data["pp"] = pp
  12961. bytesData, _ := json.Marshal(data)
  12962. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12963. resp, _ := client.Do(req)
  12964. defer resp.Body.Close()
  12965. body, ioErr := ioutil.ReadAll(resp.Body)
  12966. if ioErr != nil {
  12967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12969. return
  12970. }
  12971. var respJSON map[string]interface{}
  12972. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12975. return
  12976. }
  12977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12978. userJSONBytes, _ := json.Marshal(respJSON)
  12979. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12980. utils.ErrorLog("解析失败:%v", err)
  12981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12982. return
  12983. }
  12984. res.InfRefmsgid = resOther.InfRefmsgid
  12985. res.Output = resOther.Output
  12986. res.ErrMsg = resOther.ErrMsg
  12987. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12988. res.Infcode = infocode
  12989. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12990. var pp models.PublicParams
  12991. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12992. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12993. pp.FixmedinsName = miConfig.OrgName
  12994. pp.FixmedinsCode = miConfig.Code
  12995. pp.RequestUrl = miConfig.Url
  12996. pp.Cainfo = miConfig.Cainfo
  12997. pp.SecretKey = miConfig.SecretKey
  12998. pp.AccessKey = miConfig.AccessKey
  12999. pp.OpterName = curRoles.UserName
  13000. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13001. fmt.Println(requestLog)
  13002. fmt.Println(errMsgLog)
  13003. saveLog(result, requestLog, "4101a", "上传清单")
  13004. var dat map[string]interface{}
  13005. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13006. fmt.Println(dat)
  13007. } else {
  13008. fmt.Println(err)
  13009. }
  13010. userJSONBytes, _ := json.Marshal(dat)
  13011. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13012. utils.ErrorLog("解析失败:%v", err)
  13013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13014. return
  13015. }
  13016. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13017. var pp models.PublicParams
  13018. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13019. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13020. pp.FixmedinsName = miConfig.OrgName
  13021. pp.FixmedinsCode = miConfig.Code
  13022. pp.RequestUrl = miConfig.Url
  13023. pp.Cainfo = miConfig.Cainfo
  13024. pp.SecretKey = miConfig.SecretKey
  13025. pp.AccessKey = miConfig.AccessKey
  13026. pp.OpterName = curRoles.UserName
  13027. client := &http.Client{}
  13028. var req *http.Request
  13029. data := make(map[string]interface{})
  13030. data["struct4101"] = struct4101
  13031. data["pp"] = pp
  13032. bytesData, _ := json.Marshal(data)
  13033. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13034. resp, _ := client.Do(req)
  13035. defer resp.Body.Close()
  13036. body, ioErr := ioutil.ReadAll(resp.Body)
  13037. if ioErr != nil {
  13038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13040. return
  13041. }
  13042. var respJSON map[string]interface{}
  13043. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13046. return
  13047. }
  13048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13049. userJSONBytes, _ := json.Marshal(respJSON)
  13050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13051. utils.ErrorLog("解析失败:%v", err)
  13052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13053. return
  13054. }
  13055. } else {
  13056. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13057. var dat map[string]interface{}
  13058. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13059. fmt.Println(dat)
  13060. } else {
  13061. fmt.Println(err)
  13062. }
  13063. userJSONBytes, _ := json.Marshal(dat)
  13064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13065. utils.ErrorLog("解析失败:%v", err)
  13066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13067. return
  13068. }
  13069. }
  13070. if res.Infcode != 0 {
  13071. errlog := &models.HisOrderError{
  13072. UserOrgId: order.UserOrgId,
  13073. Ctime: time.Now().Unix(),
  13074. Mtime: time.Now().Unix(),
  13075. ErrMsg: res.ErrMsg + "解析失败",
  13076. Status: 1,
  13077. PatientId: order.ID,
  13078. Stage: 10485,
  13079. }
  13080. service.CreateErrMsgLog(errlog)
  13081. continue
  13082. //c.ServeSuccessJSON(map[string]interface{}{
  13083. // "failed_code": -10,
  13084. // "msg": res.ErrMsg,
  13085. //})
  13086. } else {
  13087. //order.FaPiaoNumber = zero
  13088. //order.FaPiaoCode = last_order.FaPiaoCode
  13089. //service.UpdateOrder(order)
  13090. hisFundSettleListResult := &models.HisFundSettleListResult{
  13091. Number: res.Output.SetlListId,
  13092. Status: 1,
  13093. Ctime: time.Now().Unix(),
  13094. Mtime: time.Now().Unix(),
  13095. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13096. IsUpload: 1,
  13097. OrderId: order.ID,
  13098. }
  13099. service.CreateUploadRecord(hisFundSettleListResult)
  13100. continue
  13101. }
  13102. }
  13103. }
  13104. func (c *HisApiController) GetSettleList() {
  13105. order_id, _ := c.GetInt64("order_id")
  13106. admin_user_id, _ := c.GetInt64("admin_user_id")
  13107. order, _ := service.GetHisOrderByIDTwo(order_id)
  13108. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13109. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13110. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13111. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13112. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13113. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13114. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13115. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13116. if order.ID == 0 {
  13117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13118. return
  13119. }
  13120. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13121. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13122. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13123. //fmt.Println(count)
  13124. //var zero string
  13125. //number := count + 1
  13126. //if number >= 1000 {
  13127. // zero = "0000" + strconv.FormatInt(number, 10)
  13128. //} else if number >= 10000 {
  13129. // zero = "000" + strconv.FormatInt(number, 10)
  13130. //} else if number >= 100000 {
  13131. // zero = "00" + strconv.FormatInt(number, 10)
  13132. //} else if number >= 1000000 {
  13133. // zero = "0" + strconv.FormatInt(number, 10)
  13134. //} else {
  13135. // zero = strconv.FormatInt(number, 10)
  13136. //}
  13137. //fmt.Println(zero)
  13138. struct4101 := service.Struct4101{
  13139. PsnNo: order.PsnNo,
  13140. MdtrtId: order.MdtrtId,
  13141. SetlId: order.SetlId,
  13142. PsnName: order.PsnName,
  13143. Gend: order.Gend,
  13144. Brdy: his.Brdy,
  13145. Age: his.Age,
  13146. Naty: order.Naty,
  13147. PatnCertType: "01",
  13148. Certno: order.Certno,
  13149. Prfs: "90",
  13150. ConerName: roles[0].UserName,
  13151. PatnRlts: "99",
  13152. ConerAddr: miConfig.OrgName,
  13153. ConerTel: admin.Mobile,
  13154. HiType: order.Insutype,
  13155. Insuplc: miConfig.InsuplcAdmdvs,
  13156. MaindiagFlag: "1",
  13157. BillCode: order.SetlId,
  13158. BillNo: order.SetlId,
  13159. BizSn: order.Number,
  13160. PsnSelfPay: order.PsnPartAmt,
  13161. PsnOwnPay: order.PsnPartAmt,
  13162. AcctPay: order.AcctPay,
  13163. PsnCashpay: order.PsnCashPay,
  13164. HiPaymtd: "1",
  13165. Hsorg: miConfig.InsuplcAdmdvs,
  13166. HsorgOpter: miConfig.InsuplcAdmdvs,
  13167. MedinsFillPsn: curRoles.UserName,
  13168. MedinsFillDept: miConfig.OrgName,
  13169. IptMedType: "2",
  13170. }
  13171. struct4101.SetlBegnDate = order.SetlTime
  13172. struct4101.SetlEndDate = order.SetlTime
  13173. time_arr := strings.Split(order.SetlTime, " ")
  13174. struct4101.AdmTime = time_arr[0]
  13175. struct4101.AdmEndTime = time_arr[0]
  13176. //
  13177. //var rf []CustomFundPay
  13178. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13179. //
  13180. //var tempFunPays []service.CustomStruct
  13181. //for _, item := range rf {
  13182. // var tempFunPay service.CustomStruct
  13183. // tempFunPay.FundPayamt = item.FundPayamt
  13184. // tempFunPay.FundPayType = item.FundPayType
  13185. // tempFunPays = append(tempFunPays, tempFunPay)
  13186. //}
  13187. //struct4101.CustomStruct = tempFunPays
  13188. var tempDiaginfos []service.DiaginfoStructTwo
  13189. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13190. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13191. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  13192. var config []*models.HisXtDiagnoseConfig
  13193. for _, item := range diagnosis_ids {
  13194. id, _ := strconv.ParseInt(item, 10, 64)
  13195. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13196. config = append(config, &diagnosisConfig)
  13197. }
  13198. if miConfig.Code == "H15049901371" {
  13199. //for _, item := range config {
  13200. // if item.ID == 138 {
  13201. diagnosisConfig, _ := service.FindDiagnoseById(138)
  13202. var tempDiaginfo service.DiaginfoStructTwo
  13203. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  13204. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  13205. tempDiaginfo.DiagType = "1"
  13206. tempDiaginfo.MaindiagFlag = "1"
  13207. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13208. //}
  13209. //}
  13210. for _, item := range config {
  13211. if item.ID != 138 {
  13212. var tempDiaginfo service.DiaginfoStructTwo
  13213. tempDiaginfo.DiagCode = item.CountryCode
  13214. tempDiaginfo.DiagName = item.CountryContentName
  13215. tempDiaginfo.DiagType = "1"
  13216. tempDiaginfo.MaindiagFlag = "0"
  13217. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13218. }
  13219. }
  13220. } else {
  13221. for index, item := range config {
  13222. if index == 0 {
  13223. var tempDiaginfo service.DiaginfoStructTwo
  13224. tempDiaginfo.DiagCode = item.CountryCode
  13225. tempDiaginfo.DiagName = item.CountryContentName
  13226. tempDiaginfo.DiagType = "1"
  13227. tempDiaginfo.MaindiagFlag = "1"
  13228. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13229. } else {
  13230. var tempDiaginfo service.DiaginfoStructTwo
  13231. tempDiaginfo.DiagCode = item.CountryCode
  13232. tempDiaginfo.DiagName = item.CountryContentName
  13233. tempDiaginfo.DiagType = "1"
  13234. tempDiaginfo.MaindiagFlag = "0"
  13235. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13236. }
  13237. }
  13238. }
  13239. struct4101.Diseinfo = tempDiaginfos
  13240. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13241. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13242. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13243. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  13244. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  13245. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13246. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13247. var iteminfo service.IteminfoStruct
  13248. var bedCostTotal float64 = 0 //床位总费
  13249. var bedCostSelfTotal float64 = 0 //床位自费
  13250. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13251. var operationCostTotal float64 = 0 //手术费
  13252. var operationCostSelfTotal float64 = 0 //手术费
  13253. var operationCostPartSelfTotal float64 = 0 //手术费
  13254. var otherCostTotal float64 = 0 //其他费用
  13255. var otherCostSelfTotal float64 = 0 //其他费用
  13256. var otherCostPartSelfTotal float64 = 0 //其他费用
  13257. var materialCostTotal float64 = 0 //材料费
  13258. var materialCostSelfTotal float64 = 0 //材料费
  13259. var materialCostPartSelfTotal float64 = 0 //材料费
  13260. var westernMedicineCostTotal float64 = 0 //西药费
  13261. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13262. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13263. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13264. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13265. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13266. var checkCostTotal float64 = 0 //检查费
  13267. var checkCostSelfTotal float64 = 0 //检查费
  13268. var checkCostPartSelfTotal float64 = 0 //检查费
  13269. var laboratoryCostTotal float64 = 0 //化验费
  13270. var laboratoryCostSelfTotal float64 = 0 //化验费
  13271. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13272. var treatCostTotal float64 = 0 //治疗费用
  13273. var treatCostSelfTotal float64 = 0 //治疗费用
  13274. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13275. decimal.DivisionPrecision = 2
  13276. var bed_fulamt_ownpay_amt float64 = 0
  13277. var operation_fulamt_ownpay_amt float64 = 0
  13278. var other_fulamt_ownpay_amt float64 = 0
  13279. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13280. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13281. var check_fulamt_ownpay_amt float64 = 0
  13282. var material_fulamt_ownpay_amt float64 = 0
  13283. var laboratory_fulamt_ownpay_amt float64 = 0
  13284. var treat_fulamt_ownpay_amt float64 = 0
  13285. var bed_claa_sunmfee float64 = 0
  13286. var bed_clab_amt float64 = 0
  13287. var bed_other_amt float64 = 0
  13288. var operation_claa_sunmfee float64 = 0
  13289. var operation_clab_amt float64 = 0
  13290. var operation_other_amt float64 = 0
  13291. var other_claa_sunmfee float64 = 0
  13292. var other_clab_amt float64 = 0
  13293. var other_other_amt float64 = 0
  13294. var westernMedicine_claa_sunmfee float64 = 0
  13295. var westernMedicine_clab_amt float64 = 0
  13296. var westernMedicine_other_amt float64 = 0
  13297. var chineseTraditional_claa_sunmfee float64 = 0
  13298. var chineseTraditional_clab_amt float64 = 0
  13299. var chineseTraditional_other_amt float64 = 0
  13300. var check_claa_sunmfee float64 = 0
  13301. var check_clab_amt float64 = 0
  13302. var check_other_amt float64 = 0
  13303. var material_claa_sunmfee float64 = 0
  13304. var material_clab_amt float64 = 0
  13305. var material_other_amt float64 = 0
  13306. var laboratory_claa_sunmfee float64 = 0
  13307. var laboratory_clab_amt float64 = 0
  13308. var laboratory_other_amt float64 = 0
  13309. var treat_claa_sunmfee float64 = 0
  13310. var treat_clab_amt float64 = 0
  13311. var treat_other_amt float64 = 0
  13312. for _, item := range order.HisOrderInfo {
  13313. if item.MedChrgitmType == "01" { //床位费
  13314. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13315. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13316. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13317. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13318. if item.ChrgitmLv == "1" {
  13319. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13320. }
  13321. if item.ChrgitmLv == "2" {
  13322. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13323. }
  13324. if item.ChrgitmLv == "3" {
  13325. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13326. }
  13327. }
  13328. if item.MedChrgitmType == "03" { //检查费
  13329. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13330. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13331. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13332. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13333. if item.ChrgitmLv == "1" {
  13334. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13335. }
  13336. if item.ChrgitmLv == "2" {
  13337. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13338. }
  13339. if item.ChrgitmLv == "3" {
  13340. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13341. }
  13342. }
  13343. if item.MedChrgitmType == "04" { //化验费
  13344. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13345. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13346. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13347. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13348. if item.ChrgitmLv == "1" {
  13349. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13350. }
  13351. if item.ChrgitmLv == "2" {
  13352. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13353. }
  13354. if item.ChrgitmLv == "3" {
  13355. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13356. }
  13357. }
  13358. if item.MedChrgitmType == "05" { //治疗费
  13359. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13360. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13361. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13362. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13363. if item.ChrgitmLv == "1" {
  13364. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13365. }
  13366. if item.ChrgitmLv == "2" {
  13367. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13368. }
  13369. if item.ChrgitmLv == "3" {
  13370. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13371. }
  13372. }
  13373. if item.MedChrgitmType == "06" { //手术费
  13374. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13375. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13376. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13377. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13378. if item.ChrgitmLv == "1" {
  13379. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13380. }
  13381. if item.ChrgitmLv == "2" {
  13382. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13383. }
  13384. if item.ChrgitmLv == "3" {
  13385. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13386. }
  13387. }
  13388. if item.MedChrgitmType == "08" { //材料费
  13389. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13390. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13391. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13392. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13393. if item.ChrgitmLv == "1" {
  13394. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13395. }
  13396. if item.ChrgitmLv == "2" {
  13397. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13398. }
  13399. if item.ChrgitmLv == "3" {
  13400. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13401. }
  13402. }
  13403. if item.MedChrgitmType == "09" { //西药费
  13404. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13405. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13406. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13407. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13408. if item.ChrgitmLv == "1" {
  13409. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13410. }
  13411. if item.ChrgitmLv == "2" {
  13412. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13413. }
  13414. if item.ChrgitmLv == "3" {
  13415. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13416. }
  13417. }
  13418. if item.MedChrgitmType == "11" { //中成费
  13419. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13420. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13421. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13422. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13423. if item.ChrgitmLv == "1" {
  13424. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13425. }
  13426. if item.ChrgitmLv == "2" {
  13427. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13428. }
  13429. if item.ChrgitmLv == "3" {
  13430. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13431. }
  13432. }
  13433. if item.MedChrgitmType == "14" { //其他费
  13434. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13435. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13436. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13437. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13438. if item.ChrgitmLv == "1" {
  13439. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13440. }
  13441. if item.ChrgitmLv == "2" {
  13442. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13443. }
  13444. if item.ChrgitmLv == "3" {
  13445. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13446. }
  13447. }
  13448. }
  13449. var iteminfoStructs []service.IteminfoStruct
  13450. if bedCostTotal != 0 {
  13451. iteminfo.MedChrgitm = "01"
  13452. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13453. iteminfo.Amt = bedCostTotal
  13454. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13455. iteminfo.ClabAmt = bed_clab_amt
  13456. iteminfo.OthAmt = bed_other_amt
  13457. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13458. }
  13459. if checkCostTotal != 0 {
  13460. iteminfo.MedChrgitm = "03"
  13461. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13462. iteminfo.Amt = checkCostTotal
  13463. iteminfo.ClaaSumfee = check_claa_sunmfee
  13464. iteminfo.ClabAmt = check_clab_amt
  13465. iteminfo.OthAmt = check_other_amt
  13466. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13467. }
  13468. if laboratoryCostTotal != 0 {
  13469. iteminfo.MedChrgitm = "04"
  13470. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13471. iteminfo.Amt = laboratoryCostTotal
  13472. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13473. iteminfo.ClabAmt = laboratory_clab_amt
  13474. iteminfo.OthAmt = laboratory_other_amt
  13475. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13476. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13477. }
  13478. if treatCostTotal != 0 {
  13479. iteminfo.MedChrgitm = "05"
  13480. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13481. iteminfo.Amt = treatCostTotal
  13482. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13483. iteminfo.ClabAmt = treat_clab_amt
  13484. iteminfo.OthAmt = treat_other_amt
  13485. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13486. //(struct4101.IteminfoStruct, iteminfo)
  13487. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13488. }
  13489. if operationCostTotal != 0 {
  13490. iteminfo.MedChrgitm = "06"
  13491. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13492. iteminfo.Amt = operationCostTotal
  13493. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13494. iteminfo.ClabAmt = operation_clab_amt
  13495. iteminfo.OthAmt = operation_other_amt
  13496. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13497. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13498. }
  13499. if materialCostTotal != 0 {
  13500. iteminfo.MedChrgitm = "08"
  13501. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13502. iteminfo.Amt = materialCostTotal
  13503. iteminfo.ClaaSumfee = material_claa_sunmfee
  13504. iteminfo.ClabAmt = material_clab_amt
  13505. iteminfo.OthAmt = material_other_amt
  13506. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13507. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13508. }
  13509. if westernMedicineCostTotal != 0 {
  13510. iteminfo.MedChrgitm = "09"
  13511. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13512. iteminfo.Amt = westernMedicineCostTotal
  13513. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13514. iteminfo.ClabAmt = westernMedicine_clab_amt
  13515. iteminfo.OthAmt = westernMedicine_other_amt
  13516. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13517. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13518. }
  13519. if chineseTraditionalMedicineCostTotal != 0 {
  13520. iteminfo.MedChrgitm = "11"
  13521. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13522. iteminfo.Amt = westernMedicineCostTotal
  13523. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13524. iteminfo.ClabAmt = westernMedicine_clab_amt
  13525. iteminfo.OthAmt = westernMedicine_other_amt
  13526. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13527. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13528. }
  13529. if otherCostTotal != 0 {
  13530. iteminfo.MedChrgitm = "14"
  13531. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13532. iteminfo.Amt = otherCostTotal
  13533. iteminfo.ClaaSumfee = other_claa_sunmfee
  13534. iteminfo.ClabAmt = other_clab_amt
  13535. iteminfo.OthAmt = other_other_amt
  13536. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13537. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13538. }
  13539. struct4101.IteminfoStruct = iteminfoStructs
  13540. struct4101.Ntly = "中国"
  13541. struct4101.AdmCaty = "A03.06"
  13542. struct4101.DoctorName = doctor.UserName
  13543. struct4101.DoctorCode = doctor.DoctorNumber
  13544. var res ResultSeventeen
  13545. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13546. struct4101.BillCode = order.Number
  13547. struct4101.BillNo = order.SetlId
  13548. var resOther ResultSeventeenOther
  13549. var pp models.PublicParams
  13550. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13551. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13552. pp.FixmedinsName = miConfig.OrgName
  13553. pp.FixmedinsCode = miConfig.Code
  13554. pp.RequestUrl = miConfig.Url
  13555. pp.Cainfo = miConfig.Cainfo
  13556. pp.SecretKey = miConfig.SecretKey
  13557. pp.AccessKey = miConfig.AccessKey
  13558. pp.OpterName = curRoles.UserName
  13559. client := &http.Client{}
  13560. var req *http.Request
  13561. data := make(map[string]interface{})
  13562. data["struct4101"] = struct4101
  13563. data["pp"] = pp
  13564. bytesData, _ := json.Marshal(data)
  13565. if miConfig.MdtrtareaAdmvs == "320921" {
  13566. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13567. } else {
  13568. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13569. }
  13570. resp, _ := client.Do(req)
  13571. defer resp.Body.Close()
  13572. body, ioErr := ioutil.ReadAll(resp.Body)
  13573. if ioErr != nil {
  13574. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13576. return
  13577. }
  13578. var respJSON map[string]interface{}
  13579. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13580. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13582. return
  13583. }
  13584. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13585. userJSONBytes, _ := json.Marshal(respJSON)
  13586. fmt.Println("log")
  13587. fmt.Println(string(userJSONBytes))
  13588. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13589. utils.ErrorLog("解析失败:%v", err)
  13590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13591. return
  13592. }
  13593. res.InfRefmsgid = resOther.InfRefmsgid
  13594. res.Output = resOther.Output
  13595. res.ErrMsg = resOther.ErrMsg
  13596. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13597. res.Infcode = infocode
  13598. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13599. var pp models.PublicParams
  13600. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13601. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13602. pp.FixmedinsName = miConfig.OrgName
  13603. pp.FixmedinsCode = miConfig.Code
  13604. pp.RequestUrl = miConfig.Url
  13605. pp.Cainfo = miConfig.Cainfo
  13606. pp.SecretKey = miConfig.SecretKey
  13607. pp.AccessKey = miConfig.AccessKey
  13608. pp.OpterName = curRoles.UserName
  13609. result, _ := service.Jxyb4101(struct4101, pp)
  13610. var dat map[string]interface{}
  13611. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13612. fmt.Println(dat)
  13613. } else {
  13614. fmt.Println(err)
  13615. }
  13616. userJSONBytes, _ := json.Marshal(dat)
  13617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13618. utils.ErrorLog("解析失败:%v", err)
  13619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13620. return
  13621. }
  13622. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13623. var pp models.PublicParams
  13624. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13625. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13626. pp.FixmedinsName = miConfig.OrgName
  13627. pp.FixmedinsCode = miConfig.Code
  13628. pp.RequestUrl = miConfig.Url
  13629. pp.Cainfo = miConfig.Cainfo
  13630. pp.SecretKey = miConfig.SecretKey
  13631. pp.AccessKey = miConfig.AccessKey
  13632. pp.OpterName = curRoles.UserName
  13633. result, _ := service.Hnyb4101(struct4101, pp)
  13634. var dat map[string]interface{}
  13635. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13636. fmt.Println(dat)
  13637. } else {
  13638. fmt.Println(err)
  13639. }
  13640. userJSONBytes, _ := json.Marshal(dat)
  13641. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13642. utils.ErrorLog("解析失败:%v", err)
  13643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13644. return
  13645. }
  13646. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13647. var resOther ResultSeventeenOther
  13648. var pp models.PublicParams
  13649. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13650. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13651. pp.FixmedinsName = miConfig.OrgName
  13652. pp.FixmedinsCode = miConfig.Code
  13653. pp.RequestUrl = miConfig.Url
  13654. pp.Cainfo = miConfig.Cainfo
  13655. pp.SecretKey = miConfig.SecretKey
  13656. pp.AccessKey = miConfig.AccessKey
  13657. pp.OpterName = curRoles.UserName
  13658. client := &http.Client{}
  13659. var req *http.Request
  13660. data := make(map[string]interface{})
  13661. data["struct4101"] = struct4101
  13662. data["pp"] = pp
  13663. bytesData, _ := json.Marshal(data)
  13664. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13665. resp, _ := client.Do(req)
  13666. defer resp.Body.Close()
  13667. body, ioErr := ioutil.ReadAll(resp.Body)
  13668. if ioErr != nil {
  13669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13671. return
  13672. }
  13673. var respJSON map[string]interface{}
  13674. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13677. return
  13678. }
  13679. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13680. userJSONBytes, _ := json.Marshal(respJSON)
  13681. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13682. utils.ErrorLog("解析失败:%v", err)
  13683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13684. return
  13685. }
  13686. res.InfRefmsgid = resOther.InfRefmsgid
  13687. res.Output = resOther.Output
  13688. res.ErrMsg = resOther.ErrMsg
  13689. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13690. res.Infcode = infocode
  13691. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13692. var pp models.PublicParams
  13693. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13694. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13695. pp.FixmedinsName = miConfig.OrgName
  13696. pp.FixmedinsCode = miConfig.Code
  13697. pp.RequestUrl = miConfig.Url
  13698. pp.Cainfo = miConfig.Cainfo
  13699. pp.SecretKey = miConfig.SecretKey
  13700. pp.AccessKey = miConfig.AccessKey
  13701. pp.OpterName = curRoles.UserName
  13702. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13703. fmt.Println(requestLog)
  13704. fmt.Println(errMsgLog)
  13705. saveLog(result, requestLog, "4101a", "上传清单")
  13706. var dat map[string]interface{}
  13707. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13708. fmt.Println(dat)
  13709. } else {
  13710. fmt.Println(err)
  13711. }
  13712. userJSONBytes, _ := json.Marshal(dat)
  13713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13714. utils.ErrorLog("解析失败:%v", err)
  13715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13716. return
  13717. }
  13718. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13719. var pp models.PublicParams
  13720. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13721. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13722. pp.FixmedinsName = miConfig.OrgName
  13723. pp.FixmedinsCode = miConfig.Code
  13724. pp.RequestUrl = miConfig.Url
  13725. pp.Cainfo = miConfig.Cainfo
  13726. pp.SecretKey = miConfig.SecretKey
  13727. pp.AccessKey = miConfig.AccessKey
  13728. pp.OpterName = curRoles.UserName
  13729. client := &http.Client{}
  13730. var req *http.Request
  13731. data := make(map[string]interface{})
  13732. data["struct4101"] = struct4101
  13733. data["pp"] = pp
  13734. bytesData, _ := json.Marshal(data)
  13735. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13736. resp, _ := client.Do(req)
  13737. defer resp.Body.Close()
  13738. body, ioErr := ioutil.ReadAll(resp.Body)
  13739. if ioErr != nil {
  13740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13742. return
  13743. }
  13744. var respJSON map[string]interface{}
  13745. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13748. return
  13749. }
  13750. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13751. userJSONBytes, _ := json.Marshal(respJSON)
  13752. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13753. utils.ErrorLog("解析失败:%v", err)
  13754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13755. return
  13756. }
  13757. } else {
  13758. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13759. var dat map[string]interface{}
  13760. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13761. fmt.Println(dat)
  13762. } else {
  13763. fmt.Println(err)
  13764. }
  13765. userJSONBytes, _ := json.Marshal(dat)
  13766. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13767. utils.ErrorLog("解析失败:%v", err)
  13768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13769. return
  13770. }
  13771. }
  13772. if res.Infcode != 0 {
  13773. c.ServeSuccessJSON(map[string]interface{}{
  13774. "failed_code": -10,
  13775. "msg": res.ErrMsg,
  13776. })
  13777. return
  13778. } else {
  13779. //order.FaPiaoNumber = zero
  13780. //order.FaPiaoCode = last_order.FaPiaoCode
  13781. //service.UpdateOrder(order)
  13782. hisFundSettleListResult := &models.HisFundSettleListResult{
  13783. Number: res.Output.SetlListId,
  13784. Status: 1,
  13785. Ctime: time.Now().Unix(),
  13786. Mtime: time.Now().Unix(),
  13787. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13788. IsUpload: 1,
  13789. OrderId: order_id,
  13790. }
  13791. service.CreateUploadRecord(hisFundSettleListResult)
  13792. c.ServeSuccessJSON(map[string]interface{}{
  13793. "msg": "上传成功",
  13794. "result": hisFundSettleListResult,
  13795. })
  13796. return
  13797. }
  13798. }
  13799. func (c *HisApiController) GetSettleListHospital() {
  13800. order_id, _ := c.GetInt64("order_id")
  13801. admin_user_id, _ := c.GetInt64("admin_user_id")
  13802. order, _ := service.GetHisOrderByIDTwo(order_id)
  13803. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13804. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13805. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13806. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13807. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13808. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13809. if order.ID == 0 {
  13810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13811. return
  13812. }
  13813. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13814. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13815. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13816. fmt.Println(count)
  13817. var zero string
  13818. number := count + 1
  13819. if number >= 1000 {
  13820. zero = "0000" + strconv.FormatInt(number, 10)
  13821. } else if number >= 10000 {
  13822. zero = "000" + strconv.FormatInt(number, 10)
  13823. } else if number >= 100000 {
  13824. zero = "00" + strconv.FormatInt(number, 10)
  13825. } else if number >= 1000000 {
  13826. zero = "0" + strconv.FormatInt(number, 10)
  13827. } else {
  13828. zero = strconv.FormatInt(number, 10)
  13829. }
  13830. fmt.Println(zero)
  13831. struct4101 := service.Struct4101{
  13832. PsnNo: order.PsnNo,
  13833. MdtrtId: order.MdtrtId,
  13834. SetlId: order.SetlId,
  13835. PsnName: order.PsnName,
  13836. Gend: order.Gend,
  13837. Brdy: his.Brdy,
  13838. Age: int64(order.Age),
  13839. Naty: order.Naty,
  13840. PatnCertType: "01",
  13841. Certno: order.Certno,
  13842. Prfs: "90",
  13843. ConerName: roles[0].UserName,
  13844. PatnRlts: "99",
  13845. ConerAddr: miConfig.OrgName,
  13846. ConerTel: admin.Mobile,
  13847. HiType: order.Insutype,
  13848. Insuplc: miConfig.InsuplcAdmdvs,
  13849. MaindiagFlag: "1",
  13850. BillCode: order.SetlId,
  13851. BillNo: order.SetlId,
  13852. BizSn: order.Number,
  13853. PsnSelfPay: order.PsnPartAmt,
  13854. PsnOwnPay: order.PsnPartAmt,
  13855. AcctPay: order.AcctPay,
  13856. PsnCashpay: order.PsnCashPay,
  13857. HiPaymtd: "1",
  13858. Hsorg: miConfig.InsuplcAdmdvs,
  13859. HsorgOpter: miConfig.InsuplcAdmdvs,
  13860. MedinsFillPsn: curRoles.UserName,
  13861. MedinsFillDept: depart.Name,
  13862. IptMedType: "2",
  13863. AdmTime: his.InHosptialTime,
  13864. AdmEndTime: his.OutHosptialTime,
  13865. }
  13866. struct4101.SetlBegnDate = order.SetlTime
  13867. struct4101.SetlEndDate = order.SetlTime
  13868. //var rf []CustomFundPay
  13869. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13870. //
  13871. //var tempFunPays []service.CustomStruct
  13872. //for _, item := range rf {
  13873. // var tempFunPay service.CustomStruct
  13874. // tempFunPay.FundPayamt = item.FundPayamt
  13875. // tempFunPay.FundPayType = item.FundPayType
  13876. // tempFunPays = append(tempFunPays, tempFunPay)
  13877. //}
  13878. //struct4101.CustomStruct = tempFunPays
  13879. var tempDiaginfos []service.DiaginfoStructTwo
  13880. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13881. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13882. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  13883. //for _, item := range infos {
  13884. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  13885. //}
  13886. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  13887. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  13888. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13889. fmt.Println(diagnosis_ids_arr)
  13890. if order.UserOrgId == 10210 {
  13891. var diagnosis_ids_arr_two []int64
  13892. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  13893. var config []*models.HisXtDiagnoseConfig
  13894. for _, id := range diagnosis_ids_arr_two {
  13895. //id, _ := strconv.ParseInt(item, 10, 64)
  13896. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13897. if diagnosisConfig.ID > 0 {
  13898. config = append(config, &diagnosisConfig)
  13899. }
  13900. }
  13901. for index, item := range config {
  13902. if item.ID > 0 {
  13903. if index == 0 {
  13904. var tempDiaginfo service.DiaginfoStructTwo
  13905. tempDiaginfo.DiagCode = item.CountryCode
  13906. tempDiaginfo.DiagName = item.CountryContentName
  13907. tempDiaginfo.DiagType = "1"
  13908. tempDiaginfo.MaindiagFlag = "1"
  13909. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13910. } else {
  13911. var tempDiaginfo service.DiaginfoStructTwo
  13912. tempDiaginfo.DiagCode = item.CountryCode
  13913. tempDiaginfo.DiagName = item.CountryContentName
  13914. tempDiaginfo.DiagType = "1"
  13915. tempDiaginfo.MaindiagFlag = "0"
  13916. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13917. }
  13918. }
  13919. }
  13920. struct4101.Diseinfo = tempDiaginfos
  13921. } else {
  13922. var config []*models.HisXtDiagnoseConfig
  13923. for _, item := range diagnosis_ids_arr {
  13924. id, _ := strconv.ParseInt(item, 10, 64)
  13925. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13926. if diagnosisConfig.ID > 0 {
  13927. config = append(config, &diagnosisConfig)
  13928. }
  13929. }
  13930. for index, item := range config {
  13931. if item.ID > 0 {
  13932. if index == 0 {
  13933. var tempDiaginfo service.DiaginfoStructTwo
  13934. tempDiaginfo.DiagCode = item.CountryCode
  13935. tempDiaginfo.DiagName = item.CountryContentName
  13936. tempDiaginfo.DiagType = "1"
  13937. tempDiaginfo.MaindiagFlag = "1"
  13938. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13939. } else {
  13940. var tempDiaginfo service.DiaginfoStructTwo
  13941. tempDiaginfo.DiagCode = item.CountryCode
  13942. tempDiaginfo.DiagName = item.CountryContentName
  13943. tempDiaginfo.DiagType = "1"
  13944. tempDiaginfo.MaindiagFlag = "0"
  13945. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13946. }
  13947. }
  13948. }
  13949. struct4101.Diseinfo = tempDiaginfos
  13950. }
  13951. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13952. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13953. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13954. tempOpspdiseinfo2.OprnOprtCode = ""
  13955. tempOpspdiseinfo2.OprnOprtName = ""
  13956. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13957. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13958. var iteminfo service.IteminfoStruct
  13959. var bedCostTotal float64 = 0 //床位总费
  13960. var bedCostSelfTotal float64 = 0 //床位自费
  13961. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13962. var operationCostTotal float64 = 0 //手术费
  13963. var operationCostSelfTotal float64 = 0 //手术费
  13964. var operationCostPartSelfTotal float64 = 0 //手术费
  13965. var otherCostTotal float64 = 0 //其他费用
  13966. var otherCostSelfTotal float64 = 0 //其他费用
  13967. var otherCostPartSelfTotal float64 = 0 //其他费用
  13968. var materialCostTotal float64 = 0 //材料费
  13969. var materialCostSelfTotal float64 = 0 //材料费
  13970. var materialCostPartSelfTotal float64 = 0 //材料费
  13971. var westernMedicineCostTotal float64 = 0 //西药费
  13972. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13973. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13974. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13975. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13976. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13977. var checkCostTotal float64 = 0 //检查费
  13978. var checkCostSelfTotal float64 = 0 //检查费
  13979. var checkCostPartSelfTotal float64 = 0 //检查费
  13980. var laboratoryCostTotal float64 = 0 //化验费
  13981. var laboratoryCostSelfTotal float64 = 0 //化验费
  13982. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13983. var treatCostTotal float64 = 0 //治疗费用
  13984. var treatCostSelfTotal float64 = 0 //治疗费用
  13985. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13986. decimal.DivisionPrecision = 2
  13987. var bed_fulamt_ownpay_amt float64 = 0
  13988. var operation_fulamt_ownpay_amt float64 = 0
  13989. var other_fulamt_ownpay_amt float64 = 0
  13990. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13991. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13992. var check_fulamt_ownpay_amt float64 = 0
  13993. var material_fulamt_ownpay_amt float64 = 0
  13994. var laboratory_fulamt_ownpay_amt float64 = 0
  13995. var treat_fulamt_ownpay_amt float64 = 0
  13996. var bed_claa_sunmfee float64 = 0
  13997. var bed_clab_amt float64 = 0
  13998. var bed_other_amt float64 = 0
  13999. var operation_claa_sunmfee float64 = 0
  14000. var operation_clab_amt float64 = 0
  14001. var operation_other_amt float64 = 0
  14002. var other_claa_sunmfee float64 = 0
  14003. var other_clab_amt float64 = 0
  14004. var other_other_amt float64 = 0
  14005. var westernMedicine_claa_sunmfee float64 = 0
  14006. var westernMedicine_clab_amt float64 = 0
  14007. var westernMedicine_other_amt float64 = 0
  14008. var chineseTraditional_claa_sunmfee float64 = 0
  14009. var chineseTraditional_clab_amt float64 = 0
  14010. var chineseTraditional_other_amt float64 = 0
  14011. var check_claa_sunmfee float64 = 0
  14012. var check_clab_amt float64 = 0
  14013. var check_other_amt float64 = 0
  14014. var material_claa_sunmfee float64 = 0
  14015. var material_clab_amt float64 = 0
  14016. var material_other_amt float64 = 0
  14017. var laboratory_claa_sunmfee float64 = 0
  14018. var laboratory_clab_amt float64 = 0
  14019. var laboratory_other_amt float64 = 0
  14020. var treat_claa_sunmfee float64 = 0
  14021. var treat_clab_amt float64 = 0
  14022. var treat_other_amt float64 = 0
  14023. for _, item := range order.HisOrderInfo {
  14024. if item.MedChrgitmType == "01" { //床位费
  14025. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14026. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14027. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14028. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14029. if item.ChrgitmLv == "1" {
  14030. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14031. }
  14032. if item.ChrgitmLv == "2" {
  14033. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14034. }
  14035. if item.ChrgitmLv == "3" {
  14036. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14037. }
  14038. }
  14039. if item.MedChrgitmType == "03" { //检查费
  14040. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14041. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14042. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14043. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14044. if item.ChrgitmLv == "1" {
  14045. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14046. }
  14047. if item.ChrgitmLv == "2" {
  14048. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14049. }
  14050. if item.ChrgitmLv == "3" {
  14051. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14052. }
  14053. }
  14054. if item.MedChrgitmType == "04" { //化验费
  14055. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14056. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14057. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14058. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14059. if item.ChrgitmLv == "1" {
  14060. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14061. }
  14062. if item.ChrgitmLv == "2" {
  14063. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14064. }
  14065. if item.ChrgitmLv == "3" {
  14066. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14067. }
  14068. }
  14069. if item.MedChrgitmType == "05" { //治疗费
  14070. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14071. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14072. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14073. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14074. if item.ChrgitmLv == "1" {
  14075. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14076. }
  14077. if item.ChrgitmLv == "2" {
  14078. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14079. }
  14080. if item.ChrgitmLv == "3" {
  14081. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14082. }
  14083. }
  14084. if item.MedChrgitmType == "06" { //手术费
  14085. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14086. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14087. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14088. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14089. if item.ChrgitmLv == "1" {
  14090. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14091. }
  14092. if item.ChrgitmLv == "2" {
  14093. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14094. }
  14095. if item.ChrgitmLv == "3" {
  14096. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14097. }
  14098. }
  14099. if item.MedChrgitmType == "08" { //材料费
  14100. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14101. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14102. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14103. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14104. if item.ChrgitmLv == "1" {
  14105. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14106. }
  14107. if item.ChrgitmLv == "2" {
  14108. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14109. }
  14110. if item.ChrgitmLv == "3" {
  14111. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14112. }
  14113. }
  14114. if item.MedChrgitmType == "09" { //西药费
  14115. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14116. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14117. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14118. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14119. if item.ChrgitmLv == "1" {
  14120. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14121. }
  14122. if item.ChrgitmLv == "2" {
  14123. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14124. }
  14125. if item.ChrgitmLv == "3" {
  14126. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14127. }
  14128. }
  14129. if item.MedChrgitmType == "11" { //中成费
  14130. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14131. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14132. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14133. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14134. if item.ChrgitmLv == "1" {
  14135. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14136. }
  14137. if item.ChrgitmLv == "2" {
  14138. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14139. }
  14140. if item.ChrgitmLv == "3" {
  14141. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14142. }
  14143. }
  14144. if item.MedChrgitmType == "14" { //其他费
  14145. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14146. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14147. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14148. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14149. if item.ChrgitmLv == "1" {
  14150. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14151. }
  14152. if item.ChrgitmLv == "2" {
  14153. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14154. }
  14155. if item.ChrgitmLv == "3" {
  14156. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14157. }
  14158. }
  14159. }
  14160. var iteminfoStructs []service.IteminfoStruct
  14161. if bedCostTotal != 0 {
  14162. iteminfo.MedChrgitm = "01"
  14163. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14164. iteminfo.Amt = bedCostTotal
  14165. iteminfo.ClaaSumfee = bed_claa_sunmfee
  14166. iteminfo.ClabAmt = bed_clab_amt
  14167. iteminfo.OthAmt = bed_other_amt
  14168. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14169. }
  14170. if checkCostTotal != 0 {
  14171. iteminfo.MedChrgitm = "03"
  14172. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14173. iteminfo.Amt = checkCostTotal
  14174. iteminfo.ClaaSumfee = check_claa_sunmfee
  14175. iteminfo.ClabAmt = check_clab_amt
  14176. iteminfo.OthAmt = check_other_amt
  14177. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14178. }
  14179. if laboratoryCostTotal != 0 {
  14180. iteminfo.MedChrgitm = "04"
  14181. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14182. iteminfo.Amt = laboratoryCostTotal
  14183. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14184. iteminfo.ClabAmt = laboratory_clab_amt
  14185. iteminfo.OthAmt = laboratory_other_amt
  14186. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14187. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14188. }
  14189. if treatCostTotal != 0 {
  14190. iteminfo.MedChrgitm = "05"
  14191. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14192. iteminfo.Amt = treatCostTotal
  14193. iteminfo.ClaaSumfee = treat_claa_sunmfee
  14194. iteminfo.ClabAmt = treat_clab_amt
  14195. iteminfo.OthAmt = treat_other_amt
  14196. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14197. //(struct4101.IteminfoStruct, iteminfo)
  14198. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14199. }
  14200. if operationCostTotal != 0 {
  14201. iteminfo.MedChrgitm = "06"
  14202. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14203. iteminfo.Amt = operationCostTotal
  14204. iteminfo.ClaaSumfee = operation_claa_sunmfee
  14205. iteminfo.ClabAmt = operation_clab_amt
  14206. iteminfo.OthAmt = operation_other_amt
  14207. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14208. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14209. }
  14210. if materialCostTotal != 0 {
  14211. iteminfo.MedChrgitm = "08"
  14212. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14213. iteminfo.Amt = materialCostTotal
  14214. iteminfo.ClaaSumfee = material_claa_sunmfee
  14215. iteminfo.ClabAmt = material_clab_amt
  14216. iteminfo.OthAmt = material_other_amt
  14217. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14218. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14219. }
  14220. if westernMedicineCostTotal != 0 {
  14221. iteminfo.MedChrgitm = "09"
  14222. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14223. iteminfo.Amt = westernMedicineCostTotal
  14224. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14225. iteminfo.ClabAmt = westernMedicine_clab_amt
  14226. iteminfo.OthAmt = westernMedicine_other_amt
  14227. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14228. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14229. }
  14230. if chineseTraditionalMedicineCostTotal != 0 {
  14231. iteminfo.MedChrgitm = "11"
  14232. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14233. iteminfo.Amt = westernMedicineCostTotal
  14234. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14235. iteminfo.ClabAmt = westernMedicine_clab_amt
  14236. iteminfo.OthAmt = westernMedicine_other_amt
  14237. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14238. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14239. }
  14240. if otherCostTotal != 0 {
  14241. iteminfo.MedChrgitm = "14"
  14242. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14243. iteminfo.Amt = otherCostTotal
  14244. iteminfo.ClaaSumfee = other_claa_sunmfee
  14245. iteminfo.ClabAmt = other_clab_amt
  14246. iteminfo.OthAmt = other_other_amt
  14247. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14248. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14249. }
  14250. struct4101.IteminfoStruct = iteminfoStructs
  14251. struct4101.Ntly = "中国"
  14252. struct4101.AdmCaty = "A03.06"
  14253. var resOther ResultSeventeenOther
  14254. var res ResultSeventeen
  14255. if miConfig.MdtrtareaAdmvs == "150499" {
  14256. var pp models.PublicParams
  14257. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14258. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14259. pp.FixmedinsName = miConfig.OrgName
  14260. pp.FixmedinsCode = miConfig.Code
  14261. pp.RequestUrl = miConfig.Url
  14262. pp.Cainfo = miConfig.Cainfo
  14263. pp.SecretKey = miConfig.SecretKey
  14264. pp.AccessKey = miConfig.AccessKey
  14265. pp.OpterName = curRoles.UserName
  14266. client := &http.Client{}
  14267. var req *http.Request
  14268. data := make(map[string]interface{})
  14269. data["struct4101"] = struct4101
  14270. data["pp"] = pp
  14271. bytesData, _ := json.Marshal(data)
  14272. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  14273. resp, _ := client.Do(req)
  14274. defer resp.Body.Close()
  14275. body, ioErr := ioutil.ReadAll(resp.Body)
  14276. if ioErr != nil {
  14277. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14279. return
  14280. }
  14281. var respJSON map[string]interface{}
  14282. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14285. return
  14286. }
  14287. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14288. userJSONBytes, _ := json.Marshal(respJSON)
  14289. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14290. utils.ErrorLog("解析失败:%v", err)
  14291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14292. return
  14293. }
  14294. res.InfRefmsgid = resOther.InfRefmsgid
  14295. res.Output = resOther.Output
  14296. res.ErrMsg = resOther.ErrMsg
  14297. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14298. res.Infcode = infocode
  14299. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14300. var pp models.PublicParams
  14301. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14302. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14303. pp.FixmedinsName = miConfig.OrgName
  14304. pp.FixmedinsCode = miConfig.Code
  14305. pp.RequestUrl = miConfig.Url
  14306. pp.Cainfo = miConfig.Cainfo
  14307. pp.SecretKey = miConfig.SecretKey
  14308. pp.AccessKey = miConfig.AccessKey
  14309. pp.OpterName = curRoles.UserName
  14310. result, _ := service.Jxyb4101(struct4101, pp)
  14311. var dat map[string]interface{}
  14312. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14313. fmt.Println(dat)
  14314. } else {
  14315. fmt.Println(err)
  14316. }
  14317. userJSONBytes, _ := json.Marshal(dat)
  14318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14319. utils.ErrorLog("解析失败:%v", err)
  14320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14321. return
  14322. }
  14323. } else {
  14324. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  14325. var dat map[string]interface{}
  14326. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14327. fmt.Println(dat)
  14328. } else {
  14329. fmt.Println(err)
  14330. }
  14331. userJSONBytes, _ := json.Marshal(dat)
  14332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14333. utils.ErrorLog("解析失败:%v", err)
  14334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14335. return
  14336. }
  14337. }
  14338. if res.Infcode != 0 {
  14339. c.ServeSuccessJSON(map[string]interface{}{
  14340. "failed_code": -10,
  14341. "msg": res.ErrMsg,
  14342. })
  14343. return
  14344. } else {
  14345. if miConfig.MdtrtareaAdmvs != "150499" {
  14346. order.FaPiaoNumber = zero
  14347. order.FaPiaoCode = last_order.FaPiaoCode
  14348. service.UpdateOrder(order)
  14349. }
  14350. hisFundSettleListResult := &models.HisFundSettleListResult{
  14351. Number: res.Output.SetlListId,
  14352. Status: 1,
  14353. Ctime: time.Now().Unix(),
  14354. Mtime: time.Now().Unix(),
  14355. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14356. IsUpload: 1,
  14357. OrderId: order_id,
  14358. }
  14359. service.CreateUploadRecord(hisFundSettleListResult)
  14360. c.ServeSuccessJSON(map[string]interface{}{
  14361. "msg": "上传成功",
  14362. "result": hisFundSettleListResult,
  14363. })
  14364. return
  14365. }
  14366. }
  14367. //func (c *HisApiController) GetBatchSettleList() {
  14368. // orders, _ := service.GetAllHisOrder(10106)
  14369. // for _, item := range orders {
  14370. // order_id := item.ID
  14371. // order, _ := service.GetHisOrderByIDTwo(order_id)
  14372. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  14373. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14374. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  14375. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  14376. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  14377. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14378. //
  14379. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  14380. //
  14381. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  14382. //
  14383. // if order.ID == 0 {
  14384. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14385. // return
  14386. // }
  14387. // if his.BalanceAccountsType == 2 {
  14388. // continue
  14389. // }
  14390. // struct4101 := service.Struct4101{
  14391. // PsnNo: order.PsnNo,
  14392. // MdtrtId: order.MdtrtId,
  14393. // SetlId: order.SetlId,
  14394. // PsnName: order.PsnName,
  14395. // Gend: order.Gend,
  14396. // Brdy: his.Brdy,
  14397. // Age: his.Age,
  14398. // Naty: order.Naty,
  14399. // PatnCertType: "01",
  14400. // Certno: order.Certno,
  14401. // Prfs: "90",
  14402. // ConerName: roles[0].UserName,
  14403. // PatnRlts: "99",
  14404. // ConerAddr: miConfig.OrgName,
  14405. // ConerTel: admin.Mobile,
  14406. // HiType: order.Insutype,
  14407. // Insuplc: his.InsuplcAdmdvs,
  14408. // MaindiagFlag: "1",
  14409. // BillCode: order.SetlId,
  14410. // BillNo: order.SetlId,
  14411. // BizSn: order.Number,
  14412. // PsnSelfPay: order.PsnPartAmt,
  14413. // PsnOwnPay: order.PsnPartAmt,
  14414. // AcctPay: order.AcctPay,
  14415. // PsnCashpay: order.PsnCashPay,
  14416. // HiPaymtd: "1",
  14417. // Hsorg: his.InsuplcAdmdvs,
  14418. // HsorgOpter: his.InsuplcAdmdvs,
  14419. // MedinsFillPsn: curRoles.UserName,
  14420. // MedinsFillDept: depart.Name,
  14421. // IptMedType: "2",
  14422. // }
  14423. // struct4101.SetlBegnDate = order.SetlTime
  14424. // struct4101.SetlEndDate = order.SetlTime
  14425. // //if order.SettleType == 1 {
  14426. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  14427. // // dateStr := t.Format("2006-01-02")
  14428. // // struct4101.SetlBegnDate = dateStr
  14429. // // struct4101.SetlEndDate = dateStr
  14430. // //} else {
  14431. // // t := time.Unix(int64(order.SettleStartTime), 0)
  14432. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  14433. // // dateStartStr := t.Format("2006-01-02")
  14434. // // dateEndStr := t2.Format("2006-01-02")
  14435. // // struct4101.SetlBegnDate = dateStartStr
  14436. // // struct4101.SetlEndDate = dateEndStr
  14437. // //}
  14438. //
  14439. // var rf []CustomFundPay
  14440. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  14441. //
  14442. // var tempFunPays []service.CustomStruct
  14443. // var tempFunPay610100 service.CustomStruct
  14444. //
  14445. // for _, item := range rf {
  14446. // if item.FundPayType == "610100" {
  14447. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  14448. // tempFunPay610100.FundPayType = item.FundPayType
  14449. // } else {
  14450. // var tempFunPay service.CustomStruct
  14451. // tempFunPay.FundPayamt = item.FundPayamt
  14452. // tempFunPay.FundPayType = item.FundPayType
  14453. // tempFunPays = append(tempFunPays, tempFunPay)
  14454. // }
  14455. // }
  14456. // tempFunPays = append(tempFunPays, tempFunPay610100)
  14457. // struct4101.CustomStruct = tempFunPays
  14458. //
  14459. // var tempDiaginfos []service.DiaginfoStructTwo
  14460. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14461. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14462. //
  14463. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14464. // var config []*models.HisXtDiagnoseConfig
  14465. // for _, item := range diagnosis_ids {
  14466. // id, _ := strconv.ParseInt(item, 10, 64)
  14467. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  14468. // config = append(config, &diagnosisConfig)
  14469. // }
  14470. //
  14471. // for index, item := range config {
  14472. // if index == 0 {
  14473. // var tempDiaginfo service.DiaginfoStructTwo
  14474. // tempDiaginfo.DiagCode = item.CountryCode
  14475. // tempDiaginfo.DiagName = item.CountryContentName
  14476. // tempDiaginfo.DiagType = "1"
  14477. // tempDiaginfo.MaindiagFlag = "1"
  14478. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14479. // } else {
  14480. //
  14481. // var tempDiaginfo service.DiaginfoStructTwo
  14482. // tempDiaginfo.DiagCode = item.CountryCode
  14483. // tempDiaginfo.DiagName = item.CountryContentName
  14484. // tempDiaginfo.DiagType = "2"
  14485. // tempDiaginfo.MaindiagFlag = "0"
  14486. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14487. // }
  14488. // }
  14489. // struct4101.Diseinfo = tempDiaginfos
  14490. //
  14491. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  14492. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14493. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14494. // tempOpspdiseinfo2.OprnOprtCode = ""
  14495. // tempOpspdiseinfo2.OprnOprtName = ""
  14496. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14497. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14498. //
  14499. // var iteminfo service.IteminfoStruct
  14500. //
  14501. // var bedCostTotal float64 = 0 //床位总费
  14502. // var bedCostSelfTotal float64 = 0 //床位自费
  14503. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14504. //
  14505. // var examineCostTotal float64 = 0 //诊查总费
  14506. // var examineCostSelfTotal float64 = 0 //诊查自费
  14507. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  14508. //
  14509. // var nursingCostTotal float64 = 0 //护理总费
  14510. // var nursingCostSelfTotal float64 = 0 //护理自费
  14511. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  14512. //
  14513. // var chineseMedicineCostTotal float64 = 0 //中成药
  14514. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  14515. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  14516. //
  14517. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  14518. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  14519. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  14520. //
  14521. // var registerCostTotal float64 = 0 //一般诊疗费
  14522. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  14523. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  14524. //
  14525. // var operationCostTotal float64 = 0 //手术费
  14526. // var operationCostSelfTotal float64 = 0 //手术费
  14527. // var operationCostPartSelfTotal float64 = 0 //手术费
  14528. //
  14529. // var otherCostTotal float64 = 0 //其他费用
  14530. // var otherCostSelfTotal float64 = 0 //其他费用
  14531. // var otherCostPartSelfTotal float64 = 0 //其他费用
  14532. //
  14533. // var materialCostTotal float64 = 0 //材料费
  14534. // var materialCostSelfTotal float64 = 0 //材料费
  14535. // var materialCostPartSelfTotal float64 = 0 //材料费
  14536. //
  14537. // var westernMedicineCostTotal float64 = 0 //西药费
  14538. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  14539. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14540. //
  14541. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14542. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14543. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14544. //
  14545. // var checkCostTotal float64 = 0 //检查费
  14546. // var checkCostSelfTotal float64 = 0 //检查费
  14547. // var checkCostPartSelfTotal float64 = 0 //检查费
  14548. //
  14549. // var laboratoryCostTotal float64 = 0 //化验费
  14550. // var laboratoryCostSelfTotal float64 = 0 //化验费
  14551. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14552. //
  14553. // var treatCostTotal float64 = 0 //治疗费用
  14554. // var treatCostSelfTotal float64 = 0 //治疗费用
  14555. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  14556. //
  14557. // decimal.DivisionPrecision = 2
  14558. //
  14559. // var bed_fulamt_ownpay_amt float64 = 0
  14560. //
  14561. // var examine_fulamt_ownpay_amt float64 = 0
  14562. //
  14563. // var nursing_fulamt_ownpay_amt float64 = 0
  14564. //
  14565. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  14566. //
  14567. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  14568. //
  14569. // var register_fulamt_ownpay_amt float64 = 0
  14570. //
  14571. // var operation_fulamt_ownpay_amt float64 = 0
  14572. // var other_fulamt_ownpay_amt float64 = 0
  14573. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  14574. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14575. // var check_fulamt_ownpay_amt float64 = 0
  14576. // var material_fulamt_ownpay_amt float64 = 0
  14577. // var laboratory_fulamt_ownpay_amt float64 = 0
  14578. // var treat_fulamt_ownpay_amt float64 = 0
  14579. //
  14580. // var bed_claa_sunmfee float64 = 0
  14581. // var bed_clab_amt float64 = 0
  14582. // var bed_other_amt float64 = 0
  14583. //
  14584. // var examine_claa_sunmfee float64 = 0
  14585. // var examine_clab_amt float64 = 0
  14586. // var examine_other_amt float64 = 0
  14587. //
  14588. // var nursing_claa_sunmfee float64 = 0
  14589. // var nursing_clab_amt float64 = 0
  14590. // var nursing_other_amt float64 = 0
  14591. //
  14592. // var chinese_medicine_claa_sunmfee float64 = 0
  14593. // var chinese_medicine_clab_amt float64 = 0
  14594. // var chinese_medicine_other_amt float64 = 0
  14595. //
  14596. // var commonly_treatment_claa_sunmfee float64 = 0
  14597. // var commonly_treatment_clab_amt float64 = 0
  14598. // var commonly_treatment_other_amt float64 = 0
  14599. //
  14600. // var operation_claa_sunmfee float64 = 0
  14601. // var operation_clab_amt float64 = 0
  14602. // var operation_other_amt float64 = 0
  14603. //
  14604. // var other_claa_sunmfee float64 = 0
  14605. // var other_clab_amt float64 = 0
  14606. // var other_other_amt float64 = 0
  14607. //
  14608. // var westernMedicine_claa_sunmfee float64 = 0
  14609. // var westernMedicine_clab_amt float64 = 0
  14610. // var westernMedicine_other_amt float64 = 0
  14611. //
  14612. // var chineseTraditional_claa_sunmfee float64 = 0
  14613. // var chineseTraditional_clab_amt float64 = 0
  14614. // var chineseTraditional_other_amt float64 = 0
  14615. //
  14616. // var check_claa_sunmfee float64 = 0
  14617. // var check_clab_amt float64 = 0
  14618. // var check_other_amt float64 = 0
  14619. //
  14620. // var material_claa_sunmfee float64 = 0
  14621. // var material_clab_amt float64 = 0
  14622. // var material_other_amt float64 = 0
  14623. //
  14624. // var laboratory_claa_sunmfee float64 = 0
  14625. // var laboratory_clab_amt float64 = 0
  14626. // var laboratory_other_amt float64 = 0
  14627. //
  14628. // var treat_claa_sunmfee float64 = 0
  14629. // var treat_clab_amt float64 = 0
  14630. // var treat_other_amt float64 = 0
  14631. //
  14632. // var register_claa_sunmfee float64 = 0
  14633. // var register_clab_amt float64 = 0
  14634. // var register_other_amt float64 = 0
  14635. //
  14636. // for _, item := range order.HisOrderInfo {
  14637. // if item.MedChrgitmType == "01" { //床位费
  14638. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14639. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14640. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14641. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14642. // if item.ChrgitmLv == "1" {
  14643. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14644. // }
  14645. // if item.ChrgitmLv == "2" {
  14646. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14647. //
  14648. // }
  14649. // if item.ChrgitmLv == "3" {
  14650. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14651. // }
  14652. //
  14653. // }
  14654. //
  14655. // if item.MedChrgitmType == "02" { //诊查
  14656. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14657. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14658. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14659. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14660. // if item.ChrgitmLv == "1" {
  14661. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14662. // }
  14663. // if item.ChrgitmLv == "2" {
  14664. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14665. //
  14666. // }
  14667. // if item.ChrgitmLv == "3" {
  14668. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14669. // }
  14670. //
  14671. // }
  14672. //
  14673. // if item.MedChrgitmType == "03" { //检查费
  14674. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14675. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14676. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14677. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14678. // if item.ChrgitmLv == "1" {
  14679. //
  14680. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14681. //
  14682. // }
  14683. // if item.ChrgitmLv == "2" {
  14684. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14685. //
  14686. // }
  14687. // if item.ChrgitmLv == "3" {
  14688. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14689. // }
  14690. // }
  14691. //
  14692. // if item.MedChrgitmType == "04" { //化验费
  14693. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14694. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14695. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14696. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14697. // if item.ChrgitmLv == "1" {
  14698. //
  14699. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14700. //
  14701. // }
  14702. // if item.ChrgitmLv == "2" {
  14703. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14704. //
  14705. // }
  14706. // if item.ChrgitmLv == "3" {
  14707. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14708. // }
  14709. // }
  14710. //
  14711. // if item.MedChrgitmType == "05" { //治疗费
  14712. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14713. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14714. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14715. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14716. // if item.ChrgitmLv == "1" {
  14717. //
  14718. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14719. //
  14720. // }
  14721. // if item.ChrgitmLv == "2" {
  14722. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14723. //
  14724. // }
  14725. // if item.ChrgitmLv == "3" {
  14726. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14727. // }
  14728. // }
  14729. //
  14730. // if item.MedChrgitmType == "06" { //手术费
  14731. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14732. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14733. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14734. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14735. //
  14736. // if item.ChrgitmLv == "1" {
  14737. //
  14738. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14739. //
  14740. // }
  14741. // if item.ChrgitmLv == "2" {
  14742. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14743. //
  14744. // }
  14745. // if item.ChrgitmLv == "3" {
  14746. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14747. // }
  14748. // }
  14749. //
  14750. // if item.MedChrgitmType == "07" { //手术费
  14751. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14752. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14753. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14754. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14755. //
  14756. // if item.ChrgitmLv == "1" {
  14757. //
  14758. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14759. //
  14760. // }
  14761. // if item.ChrgitmLv == "2" {
  14762. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14763. //
  14764. // }
  14765. // if item.ChrgitmLv == "3" {
  14766. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14767. // }
  14768. // }
  14769. //
  14770. // if item.MedChrgitmType == "08" { //材料费
  14771. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14772. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14773. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14774. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14775. // if item.ChrgitmLv == "1" {
  14776. //
  14777. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14778. //
  14779. // }
  14780. // if item.ChrgitmLv == "2" {
  14781. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14782. //
  14783. // }
  14784. // if item.ChrgitmLv == "3" {
  14785. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14786. // }
  14787. // }
  14788. // if item.MedChrgitmType == "09" { //西药费
  14789. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14790. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14791. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14792. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14793. // if item.ChrgitmLv == "1" {
  14794. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14795. // }
  14796. // if item.ChrgitmLv == "2" {
  14797. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14798. // }
  14799. // if item.ChrgitmLv == "3" {
  14800. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14801. // }
  14802. // }
  14803. // if item.MedChrgitmType == "10" { //中药饮片
  14804. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14805. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14806. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14807. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14808. // if item.ChrgitmLv == "1" {
  14809. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14810. // }
  14811. // if item.ChrgitmLv == "2" {
  14812. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14813. // }
  14814. // if item.ChrgitmLv == "3" {
  14815. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14816. // }
  14817. // }
  14818. //
  14819. // if item.MedChrgitmType == "11" { //中成费
  14820. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14821. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14822. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14823. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14824. // if item.ChrgitmLv == "1" {
  14825. //
  14826. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14827. //
  14828. // }
  14829. // if item.ChrgitmLv == "2" {
  14830. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14831. //
  14832. // }
  14833. // if item.ChrgitmLv == "3" {
  14834. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14835. // }
  14836. // }
  14837. //
  14838. // if item.MedChrgitmType == "12" { //中成费
  14839. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14840. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14841. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14842. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14843. // if item.ChrgitmLv == "1" {
  14844. //
  14845. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14846. //
  14847. // }
  14848. // if item.ChrgitmLv == "2" {
  14849. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14850. //
  14851. // }
  14852. // if item.ChrgitmLv == "3" {
  14853. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14854. // }
  14855. // }
  14856. //
  14857. // if item.MedChrgitmType == "13" { //中成费
  14858. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14859. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14860. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14861. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14862. // if item.ChrgitmLv == "1" {
  14863. //
  14864. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14865. //
  14866. // }
  14867. // if item.ChrgitmLv == "2" {
  14868. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14869. //
  14870. // }
  14871. // if item.ChrgitmLv == "3" {
  14872. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14873. // }
  14874. // }
  14875. //
  14876. // if item.MedChrgitmType == "14" { //其他费
  14877. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14878. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14879. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14880. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14881. // if item.ChrgitmLv == "1" {
  14882. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14883. //
  14884. // }
  14885. // if item.ChrgitmLv == "2" {
  14886. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14887. //
  14888. // }
  14889. // if item.ChrgitmLv == "3" {
  14890. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14891. // }
  14892. // }
  14893. //
  14894. // }
  14895. //
  14896. // var iteminfoStructs []service.IteminfoStruct
  14897. //
  14898. // if bedCostTotal != 0 {
  14899. // iteminfo.MedChrgitm = "01"
  14900. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14901. // iteminfo.Amt = bedCostTotal
  14902. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  14903. // iteminfo.ClabAmt = bed_clab_amt
  14904. // iteminfo.OthAmt = bed_other_amt
  14905. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14906. // }
  14907. //
  14908. // if examineCostTotal != 0 {
  14909. // iteminfo.MedChrgitm = "02"
  14910. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  14911. // iteminfo.Amt = examineCostTotal
  14912. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  14913. // iteminfo.ClabAmt = examine_clab_amt
  14914. // iteminfo.OthAmt = examine_other_amt
  14915. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14916. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14917. // }
  14918. //
  14919. // if checkCostTotal != 0 {
  14920. // iteminfo.MedChrgitm = "03"
  14921. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14922. // iteminfo.Amt = checkCostTotal
  14923. // iteminfo.ClaaSumfee = check_claa_sunmfee
  14924. // iteminfo.ClabAmt = check_clab_amt
  14925. // iteminfo.OthAmt = check_other_amt
  14926. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14927. //
  14928. // }
  14929. //
  14930. // if laboratoryCostTotal != 0 {
  14931. // iteminfo.MedChrgitm = "04"
  14932. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14933. // iteminfo.Amt = laboratoryCostTotal
  14934. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14935. // iteminfo.ClabAmt = laboratory_clab_amt
  14936. // iteminfo.OthAmt = laboratory_other_amt
  14937. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14938. //
  14939. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14940. //
  14941. // }
  14942. //
  14943. // if treatCostTotal != 0 {
  14944. // iteminfo.MedChrgitm = "05"
  14945. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14946. // iteminfo.Amt = treatCostTotal
  14947. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  14948. // iteminfo.ClabAmt = treat_clab_amt
  14949. // iteminfo.OthAmt = treat_other_amt
  14950. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14951. // //(struct4101.IteminfoStruct, iteminfo)
  14952. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14953. // }
  14954. //
  14955. // if operationCostTotal != 0 {
  14956. // iteminfo.MedChrgitm = "06"
  14957. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14958. // iteminfo.Amt = operationCostTotal
  14959. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  14960. // iteminfo.ClabAmt = operation_clab_amt
  14961. // iteminfo.OthAmt = operation_other_amt
  14962. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14963. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14964. // }
  14965. //
  14966. // if nursingCostTotal != 0 {
  14967. // iteminfo.MedChrgitm = "07"
  14968. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  14969. // iteminfo.Amt = nursingCostTotal
  14970. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  14971. // iteminfo.ClabAmt = nursing_clab_amt
  14972. // iteminfo.OthAmt = nursing_other_amt
  14973. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14974. // }
  14975. //
  14976. // if materialCostTotal != 0 {
  14977. // iteminfo.MedChrgitm = "08"
  14978. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14979. // iteminfo.Amt = materialCostTotal
  14980. // iteminfo.ClaaSumfee = material_claa_sunmfee
  14981. // iteminfo.ClabAmt = material_clab_amt
  14982. // iteminfo.OthAmt = material_other_amt
  14983. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14984. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14985. // }
  14986. //
  14987. // if westernMedicineCostTotal != 0 {
  14988. // iteminfo.MedChrgitm = "09"
  14989. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14990. // iteminfo.Amt = westernMedicineCostTotal
  14991. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14992. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14993. // iteminfo.OthAmt = westernMedicine_other_amt
  14994. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14995. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14996. //
  14997. // }
  14998. //
  14999. // if chineseMedicineCostTotal != 0 {
  15000. // iteminfo.MedChrgitm = "10"
  15001. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  15002. // iteminfo.Amt = chineseMedicineCostTotal
  15003. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  15004. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  15005. // iteminfo.OthAmt = chinese_medicine_other_amt
  15006. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15007. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15008. //
  15009. // }
  15010. //
  15011. // if chineseTraditionalMedicineCostTotal != 0 {
  15012. // iteminfo.MedChrgitm = "11"
  15013. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15014. // iteminfo.Amt = westernMedicineCostTotal
  15015. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15016. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15017. // iteminfo.OthAmt = westernMedicine_other_amt
  15018. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15019. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15020. //
  15021. // }
  15022. //
  15023. // if commonlyTreatmentCostTotal != 0 {
  15024. // iteminfo.MedChrgitm = "12"
  15025. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  15026. // iteminfo.Amt = commonlyTreatmentCostTotal
  15027. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  15028. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  15029. // iteminfo.OthAmt = commonly_treatment_other_amt
  15030. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15031. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15032. //
  15033. // }
  15034. //
  15035. // if registerCostTotal != 0 {
  15036. // iteminfo.MedChrgitm = "13"
  15037. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  15038. // iteminfo.Amt = registerCostTotal
  15039. // iteminfo.ClaaSumfee = register_claa_sunmfee
  15040. // iteminfo.ClabAmt = register_clab_amt
  15041. // iteminfo.OthAmt = register_other_amt
  15042. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15043. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15044. //
  15045. // }
  15046. //
  15047. // if otherCostTotal != 0 {
  15048. // iteminfo.MedChrgitm = "14"
  15049. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  15050. // iteminfo.Amt = otherCostTotal
  15051. // iteminfo.ClaaSumfee = other_claa_sunmfee
  15052. // iteminfo.ClabAmt = other_clab_amt
  15053. // iteminfo.OthAmt = other_other_amt
  15054. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15055. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15056. //
  15057. // }
  15058. // struct4101.IteminfoStruct = iteminfoStructs
  15059. // time_arr := strings.Split(order.SetlTime, " ")
  15060. // struct4101.AdmTime = time_arr[0]
  15061. // struct4101.AdmEndTime = time_arr[0]
  15062. //
  15063. // struct4101.DoctorName = doctor.UserName
  15064. // struct4101.DoctorCode = doctor.DoctorNumber
  15065. //
  15066. // struct4101.Ntly = "中国"
  15067. // struct4101.AdmCaty = "A03.06"
  15068. // var res ResultSeventeen
  15069. // if miConfig.MdtrtareaAdmvs == "421300" {
  15070. // data := make(map[string]interface{})
  15071. // data["struct4101"] = struct4101
  15072. // data["secret_key"] = miConfig.SecretKey
  15073. // data["org_name"] = miConfig.OrgName
  15074. // data["opera"] = curRoles.UserName
  15075. // data["code"] = miConfig.Code
  15076. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15077. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15078. //
  15079. // client := &http.Client{}
  15080. // bytesData, _ := json.Marshal(data)
  15081. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15082. // resp, _ := client.Do(req)
  15083. // defer resp.Body.Close()
  15084. // body, ioErr := ioutil.ReadAll(resp.Body)
  15085. // if ioErr != nil {
  15086. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15087. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15088. // return
  15089. // }
  15090. // var respJSON map[string]interface{}
  15091. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15092. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15094. // return
  15095. // }
  15096. //
  15097. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15098. // userJSONBytes, _ := json.Marshal(respJSON)
  15099. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15100. // utils.ErrorLog("解析失败:%v", err)
  15101. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15102. // adminUser := c.GetAdminUserInfo()
  15103. // errlog := &models.HisOrderError{
  15104. // UserOrgId: adminUser.CurrentOrgId,
  15105. // Ctime: time.Now().Unix(),
  15106. // Mtime: time.Now().Unix(),
  15107. // ErrMsg: res.ErrMsg + "解析失败",
  15108. // Status: 1,
  15109. // PatientId: order_id,
  15110. // Stage: 10088,
  15111. // }
  15112. // service.CreateErrMsgLog(errlog)
  15113. // continue
  15114. // }
  15115. //
  15116. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  15117. // data := make(map[string]interface{})
  15118. // data["struct4101"] = struct4101
  15119. // data["secret_key"] = miConfig.SecretKey
  15120. // data["org_name"] = miConfig.OrgName
  15121. // data["opera"] = curRoles.UserName
  15122. // data["code"] = miConfig.Code
  15123. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15124. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15125. //
  15126. // client := &http.Client{}
  15127. // bytesData, _ := json.Marshal(data)
  15128. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15129. // resp, _ := client.Do(req)
  15130. // defer resp.Body.Close()
  15131. // body, ioErr := ioutil.ReadAll(resp.Body)
  15132. // if ioErr != nil {
  15133. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15134. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15135. // return
  15136. // }
  15137. // var respJSON map[string]interface{}
  15138. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15139. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15141. // return
  15142. // }
  15143. //
  15144. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15145. // userJSONBytes, _ := json.Marshal(respJSON)
  15146. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15147. // utils.ErrorLog("解析失败:%v", err)
  15148. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15149. // adminUser := c.GetAdminUserInfo()
  15150. // errlog := &models.HisOrderError{
  15151. // UserOrgId: adminUser.CurrentOrgId,
  15152. // Ctime: time.Now().Unix(),
  15153. // Mtime: time.Now().Unix(),
  15154. // ErrMsg: res.ErrMsg + "解析失败",
  15155. // Status: 1,
  15156. // PatientId: order_id,
  15157. // Stage: 10088,
  15158. // }
  15159. // service.CreateErrMsgLog(errlog)
  15160. // continue
  15161. // }
  15162. //
  15163. // } else {
  15164. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  15165. // fmt.Println(result)
  15166. //
  15167. // var dat map[string]interface{}
  15168. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15169. // fmt.Println(dat)
  15170. // } else {
  15171. // fmt.Println(err)
  15172. // }
  15173. // userJSONBytes, _ := json.Marshal(dat)
  15174. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15175. // utils.ErrorLog("解析失败:%v", err)
  15176. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15177. // adminUser := c.GetAdminUserInfo()
  15178. // errlog := &models.HisOrderError{
  15179. // UserOrgId: adminUser.CurrentOrgId,
  15180. // Ctime: time.Now().Unix(),
  15181. // Mtime: time.Now().Unix(),
  15182. // ErrMsg: res.ErrMsg + "解析失败",
  15183. // Status: 1,
  15184. // PatientId: order_id,
  15185. // Stage: 10106,
  15186. // }
  15187. // service.CreateErrMsgLog(errlog)
  15188. // continue
  15189. // }
  15190. // }
  15191. //
  15192. // if res.Infcode != 0 {
  15193. // adminUser := c.GetAdminUserInfo()
  15194. // errlog := &models.HisOrderError{
  15195. // UserOrgId: adminUser.CurrentOrgId,
  15196. // Ctime: time.Now().Unix(),
  15197. // Mtime: time.Now().Unix(),
  15198. // ErrMsg: res.ErrMsg,
  15199. // Status: 1,
  15200. // PatientId: order_id,
  15201. // Stage: 10106,
  15202. // }
  15203. // service.CreateErrMsgLog(errlog)
  15204. // continue
  15205. // } else {
  15206. // hisFundSettleListResult := &models.HisFundSettleListResult{
  15207. // Number: res.Output.SetlListId,
  15208. // Status: 1,
  15209. // Ctime: time.Now().Unix(),
  15210. // Mtime: time.Now().Unix(),
  15211. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15212. // IsUpload: 1,
  15213. // OrderId: order_id,
  15214. // }
  15215. // service.CreateUploadRecord(hisFundSettleListResult)
  15216. // continue
  15217. // }
  15218. // }
  15219. //}
  15220. func (c *HisApiController) GetOrgInfo() {
  15221. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  15222. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  15223. }
  15224. func (c *HisApiController) GetHisPatientInfo() {
  15225. medical_insurance_card := c.GetString("medical_insurance_card")
  15226. id_card_type, _ := c.GetInt64("id_card_type")
  15227. id_card := c.GetString("id_card")
  15228. adminInfo := c.GetAdminUserInfo()
  15229. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  15230. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15231. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  15232. IdCardNo := ""
  15233. if id_card_type == 1 {
  15234. IdCardNo = medical_insurance_card
  15235. } else if id_card_type == 2 {
  15236. IdCardNo = id_card
  15237. }
  15238. if config.IsOpen == 1 {
  15239. 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
  15240. resp, requestErr := http.Get(api)
  15241. if requestErr != nil {
  15242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15243. return
  15244. }
  15245. defer resp.Body.Close()
  15246. body, ioErr := ioutil.ReadAll(resp.Body)
  15247. if ioErr != nil {
  15248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15250. return
  15251. }
  15252. var respJSON map[string]interface{}
  15253. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15256. return
  15257. }
  15258. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15259. userJSONBytes, _ := json.Marshal(userJSON)
  15260. var res ResultTwo
  15261. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15262. utils.ErrorLog("解析失败:%v", err)
  15263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15264. return
  15265. }
  15266. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15267. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15268. infoStr := string(Iinfos)
  15269. idetinfoStr := string(Idetinfos)
  15270. if res.Infcode == 0 {
  15271. his := models.VMHisPatient{
  15272. Status: 1,
  15273. Ctime: time.Now().Unix(),
  15274. Mtime: time.Now().Unix(),
  15275. PsnNo: res.Output.Baseinfo.PsnNo,
  15276. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15277. Certno: res.Output.Baseinfo.Certno,
  15278. PsnName: res.Output.Baseinfo.PsnName,
  15279. Gend: res.Output.Baseinfo.Gend,
  15280. Naty: res.Output.Baseinfo.Naty,
  15281. Iinfo: infoStr,
  15282. Idetinfo: idetinfoStr,
  15283. UserOrgId: adminInfo.CurrentOrgId,
  15284. IsReturn: 1,
  15285. IdCardType: id_card_type,
  15286. }
  15287. c.ServeSuccessJSON(map[string]interface{}{
  15288. "info": his,
  15289. })
  15290. } else {
  15291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15292. return
  15293. }
  15294. }
  15295. }
  15296. //func GetBasBaseInfo() (jsonStr string, err error) {
  15297. //
  15298. // handle := syscall.NewLazyDLL("SSCard.dll")
  15299. // add := handle.NewProc("ReadCardBas")
  15300. // str := make([]byte, 1024)
  15301. // str1 := make([]byte, 1024)
  15302. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15303. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  15304. //
  15305. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  15306. //
  15307. // fmt.Println("> Add(4,5)的结果为:", ret)
  15308. // handle.Release()
  15309. //
  15310. // return "", nil
  15311. //
  15312. //}
  15313. //func GetQRBaseInfo() (jsonStr string, err error) {
  15314. // handle := syscall.LoadDLL("SSCard.dll")
  15315. // ReadCardBas := handle.FindProc("GetQRBase")
  15316. //
  15317. // str := make([]byte, 256)
  15318. // str1 := make([]byte, 256)
  15319. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15320. //
  15321. // fmt.Println(string(str))
  15322. // fmt.Println(r)
  15323. // return string(str), nil
  15324. //}
  15325. //func CardInit() int {
  15326. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  15327. // add := DllTestDef.MustFindProc("Init")
  15328. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15329. // if err != nil {
  15330. // fmt.Println("SSCard的运算结果为:", ret)
  15331. // }
  15332. // result := int(ret)
  15333. // return result
  15334. //}
  15335. //func CardInit() int {
  15336. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15337. // if err != nil {
  15338. // fmt.Println("SSCard的运算结果为:", ret)
  15339. // }
  15340. // fmt.Println(err)
  15341. // result := int(ret)
  15342. // return result
  15343. //}
  15344. func IntPtr(n int) uintptr {
  15345. return uintptr(n)
  15346. }
  15347. func StrPtr(s string) uintptr {
  15348. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  15349. }
  15350. type Result2001 struct {
  15351. Cainfo interface{} `json:"cainfo"`
  15352. ErrMsg string `json:"err_msg"`
  15353. InfRefmsgid string `json:"inf_refmsgid"`
  15354. Infcode int64 `json:"infcode"`
  15355. Output struct {
  15356. Trtinfo struct {
  15357. PsnNo string `json:"psn_no"`
  15358. TrtChkType string `json:"trt_chk_type"`
  15359. FundPayType string `json:"fund_pay_type"`
  15360. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15361. Begndate string `json:"begndate"`
  15362. Enddate string `json:"enddate"`
  15363. TrtChkRslt string `json:"trt_chk_rslt"`
  15364. } `json:"trtinfo"`
  15365. } `json:"output"`
  15366. RefmsgTime string `json:"refmsg_time"`
  15367. RespondTime string `json:"respond_time"`
  15368. Signtype interface{} `json:"signtype"`
  15369. WarnMsg interface{} `json:"warn_msg"`
  15370. }
  15371. type Result2001Org10265 struct {
  15372. Cainfo interface{} `json:"cainfo"`
  15373. ErrMsg string `json:"err_msg"`
  15374. InfRefmsgid string `json:"inf_refmsgid"`
  15375. Infcode string `json:"infcode"`
  15376. Output struct {
  15377. Trtinfo struct {
  15378. PsnNo string `json:"psn_no"`
  15379. TrtChkType string `json:"trt_chk_type"`
  15380. FundPayType string `json:"fund_pay_type"`
  15381. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15382. Begndate string `json:"begndate"`
  15383. Enddate string `json:"enddate"`
  15384. TrtChkRslt string `json:"trt_chk_rslt"`
  15385. } `json:"trtinfo"`
  15386. } `json:"output"`
  15387. RefmsgTime string `json:"refmsg_time"`
  15388. RespondTime string `json:"respond_time"`
  15389. Signtype interface{} `json:"signtype"`
  15390. WarnMsg interface{} `json:"warn_msg"`
  15391. }
  15392. type ResultTwo struct {
  15393. ErrMsg string `json:"err_msg"`
  15394. InfRefmsgid string `json:"inf_refmsgid"`
  15395. Infcode int64 `json:"infcode"`
  15396. Output struct {
  15397. Baseinfo struct {
  15398. //Brdy string `json:"brdy"`
  15399. Certno string `json:"certno"`
  15400. Gend string `json:"gend"`
  15401. Naty string `json:"naty"`
  15402. PsnCertType string `json:"psn_cert_type"`
  15403. PsnName string `json:"psn_name"`
  15404. PsnNo string `json:"psn_no"`
  15405. } `json:"baseinfo"`
  15406. Idetinfo []interface{} `json:"idetinfo"`
  15407. Iinfo []struct {
  15408. Balc float64 `json:"balc"`
  15409. CvlservFlag string `json:"cvlserv_flag"`
  15410. EmpName string `json:"emp_name"`
  15411. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15412. Insutype string `json:"insutype"`
  15413. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15414. //PausInsuDate string `json:"paus_insu_date"`
  15415. //PsnInsuDate string `json:"psn_insu_date"`
  15416. PsnInsuStas string `json:"psn_insu_stas"`
  15417. PsnType string `json:"psn_type"`
  15418. } `json:"insuinfo"`
  15419. } `json:"output"`
  15420. RefmsgTime string `json:"refmsg_time"`
  15421. RespondTime string `json:"respond_time"`
  15422. Signtype interface{} `json:"signtype"`
  15423. WarnInfo interface{} `json:"warn_info"`
  15424. }
  15425. type ResultTwo10265 struct {
  15426. ErrMsg string `json:"err_msg"`
  15427. InfRefmsgid string `json:"inf_refmsgid"`
  15428. Infcode string `json:"infcode"`
  15429. Output struct {
  15430. Baseinfo struct {
  15431. //Brdy string `json:"brdy"`
  15432. Certno string `json:"certno"`
  15433. Gend string `json:"gend"`
  15434. Naty string `json:"naty"`
  15435. PsnCertType string `json:"psn_cert_type"`
  15436. PsnName string `json:"psn_name"`
  15437. PsnNo string `json:"psn_no"`
  15438. } `json:"baseinfo"`
  15439. Idetinfo []interface{} `json:"idetinfo"`
  15440. Iinfo []struct {
  15441. Balc float64 `json:"balc"`
  15442. CvlservFlag string `json:"cvlserv_flag"`
  15443. EmpName string `json:"emp_name"`
  15444. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15445. Insutype string `json:"insutype"`
  15446. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15447. PsnInsuStas string `json:"psn_insu_stas"`
  15448. PsnType string `json:"psn_type"`
  15449. } `json:"insuinfo"`
  15450. } `json:"output"`
  15451. RefmsgTime string `json:"refmsg_time"`
  15452. RespondTime string `json:"respond_time"`
  15453. Signtype interface{} `json:"signtype"`
  15454. WarnInfo interface{} `json:"warn_info"`
  15455. }
  15456. type ResultThree struct {
  15457. Cainfo interface{} `json:"cainfo"`
  15458. ErrMsg string `json:"err_msg"`
  15459. InfRefmsgid string `json:"inf_refmsgid"`
  15460. Infcode int64 `json:"infcode"`
  15461. Output struct {
  15462. Data struct {
  15463. IptOtpNo string `json:"ipt_otp_no"`
  15464. MdtrtID string `json:"mdtrt_id"`
  15465. PsnNo string `json:"psn_no"`
  15466. } `json:"data"`
  15467. } `json:"output"`
  15468. RefmsgTime string `json:"refmsg_time"`
  15469. RespondTime string `json:"respond_time"`
  15470. Signtype interface{} `json:"signtype"`
  15471. WarnMsg interface{} `json:"warn_msg"`
  15472. }
  15473. type ResultThree10265 struct {
  15474. Cainfo interface{} `json:"cainfo"`
  15475. ErrMsg string `json:"err_msg"`
  15476. InfRefmsgid string `json:"inf_refmsgid"`
  15477. Infcode string `json:"infcode"`
  15478. Output struct {
  15479. Data struct {
  15480. IptOtpNo string `json:"ipt_otp_no"`
  15481. MdtrtID string `json:"mdtrt_id"`
  15482. PsnNo string `json:"psn_no"`
  15483. } `json:"data"`
  15484. } `json:"output"`
  15485. RefmsgTime string `json:"refmsg_time"`
  15486. RespondTime string `json:"respond_time"`
  15487. Signtype interface{} `json:"signtype"`
  15488. WarnMsg interface{} `json:"warn_msg"`
  15489. }
  15490. type ResultFour struct {
  15491. Cainfo string `json:"cainfo"`
  15492. ErrMsg string `json:"err_msg"`
  15493. InfRefmsgid string `json:"inf_refmsgid"`
  15494. Infcode int64 `json:"infcode"`
  15495. Output struct {
  15496. Result []struct {
  15497. BasMednFlag string `json:"bas_medn_flag"`
  15498. ChldMedcFlag string `json:"chld_medc_flag"`
  15499. ChrgitmLv string `json:"chrgitm_lv"`
  15500. Cnt float64 `json:"cnt"`
  15501. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15502. DrtReimFlag string `json:"drt_reim_flag"`
  15503. FeedetlSn string `json:"feedetl_sn"`
  15504. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15505. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15506. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15507. ListSpItemFlag string `json:"list_sp_item_flag"`
  15508. LmtUsedFlag string `json:"lmt_used_flag"`
  15509. MedChrgitmType string `json:"med_chrgitm_type"`
  15510. Memo string `json:"memo"`
  15511. OverlmtAmt float64 `json:"overlmt_amt"`
  15512. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15513. Pric float64 `json:"pric"`
  15514. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15515. SelfpayProp float64 `json:"selfpay_prop"`
  15516. } `json:"result"`
  15517. } `json:"output"`
  15518. RefmsgTime string `json:"refmsg_time"`
  15519. RespondTime string `json:"respond_time"`
  15520. Signtype string `json:"signtype"`
  15521. WarnMsg string `json:"warn_msg"`
  15522. }
  15523. type ResultFour10265 struct {
  15524. Cainfo string `json:"cainfo"`
  15525. ErrMsg string `json:"err_msg"`
  15526. InfRefmsgid string `json:"inf_refmsgid"`
  15527. Infcode string `json:"infcode"`
  15528. Output struct {
  15529. Result []struct {
  15530. BasMednFlag string `json:"bas_medn_flag"`
  15531. ChldMedcFlag string `json:"chld_medc_flag"`
  15532. ChrgitmLv string `json:"chrgitm_lv"`
  15533. Cnt float64 `json:"cnt"`
  15534. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15535. DrtReimFlag string `json:"drt_reim_flag"`
  15536. FeedetlSn string `json:"feedetl_sn"`
  15537. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15538. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15539. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15540. ListSpItemFlag string `json:"list_sp_item_flag"`
  15541. LmtUsedFlag string `json:"lmt_used_flag"`
  15542. MedChrgitmType string `json:"med_chrgitm_type"`
  15543. Memo string `json:"memo"`
  15544. OverlmtAmt float64 `json:"overlmt_amt"`
  15545. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15546. Pric float64 `json:"pric"`
  15547. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15548. SelfpayProp float64 `json:"selfpay_prop"`
  15549. } `json:"result"`
  15550. } `json:"output"`
  15551. RefmsgTime string `json:"refmsg_time"`
  15552. RespondTime string `json:"respond_time"`
  15553. Signtype string `json:"signtype"`
  15554. WarnMsg string `json:"warn_msg"`
  15555. }
  15556. type ResultMemo struct {
  15557. InsuAdmdvs string `json:"insuAdmdvs"`
  15558. }
  15559. // [{"begntime":"2022-01-01 00:00:00","endtime":"2022-12-31 00:00:00","memo":"{\"matIdetCode\":\"20\",\"insuAdmdvs\":\"350481\"}","psn_idet_type":"23","psn_type_lv":null}]
  15560. type ResultIDInfo struct {
  15561. Begntime string `json:"begntime"`
  15562. Endtime string `json:"endtime"`
  15563. Memo string `json:"memo"`
  15564. }
  15565. type ResultFive struct {
  15566. Balc float64 `json:"balc"`
  15567. CvlservFlag string `json:"cvlserv_flag"`
  15568. EmpName string `json:"emp_name"`
  15569. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15570. Insutype string `json:"insutype"`
  15571. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15572. PausInsuDate string `json:"paus_insu_date"`
  15573. PsnInsuDate string `json:"psn_insu_date"`
  15574. PsnInsuStas string `json:"psn_insu_stas"`
  15575. PsnType string `json:"psn_type"`
  15576. }
  15577. type ResultSix struct {
  15578. Cainfo interface{} `json:"cainfo"`
  15579. ErrMsg string `json:"err_msg"`
  15580. InfRefmsgid string `json:"inf_refmsgid"`
  15581. Infcode int64 `json:"infcode"`
  15582. Output struct {
  15583. } `json:"output"`
  15584. RefmsgTime string `json:"refmsg_time"`
  15585. RespondTime string `json:"respond_time"`
  15586. Signtype interface{} `json:"signtype"`
  15587. WarnMsg interface{} `json:"warn_msg"`
  15588. }
  15589. type FJ3507Result struct {
  15590. Cainfo interface{} `json:"cainfo"`
  15591. ErrMsg string `json:"err_msg"`
  15592. InfRefmsgid string `json:"inf_refmsgid"`
  15593. Infcode int64 `json:"infcode"`
  15594. Output struct {
  15595. retRslt string `json:"retRslt"`
  15596. msgRslt string `json:"msgRslt"`
  15597. } `json:"output"`
  15598. RefmsgTime string `json:"refmsg_time"`
  15599. RespondTime string `json:"respond_time"`
  15600. Signtype interface{} `json:"signtype"`
  15601. WarnMsg interface{} `json:"warn_msg"`
  15602. }
  15603. type Result2406 struct {
  15604. Cainfo interface{} `json:"cainfo"`
  15605. ErrMsg string `json:"err_msg"`
  15606. InfRefmsgid string `json:"inf_refmsgid"`
  15607. Infcode int64 `json:"infcode"`
  15608. Output struct {
  15609. Result struct {
  15610. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  15611. } `json:"result"`
  15612. } `json:"output"`
  15613. RefmsgTime string `json:"refmsg_time"`
  15614. RespondTime string `json:"respond_time"`
  15615. Signtype interface{} `json:"signtype"`
  15616. WarnMsg interface{} `json:"warn_msg"`
  15617. }
  15618. type GZResultSix struct {
  15619. Cainfo interface{} `json:"cainfo"`
  15620. ErrMsg string `json:"err_msg"`
  15621. InfRefmsgid string `json:"inf_refmsgid"`
  15622. Infcode int64 `json:"infcode"`
  15623. Output string `json:"output"`
  15624. RefmsgTime string `json:"refmsg_time"`
  15625. RespondTime string `json:"respond_time"`
  15626. Signtype interface{} `json:"signtype"`
  15627. WarnMsg interface{} `json:"warn_msg"`
  15628. }
  15629. type ResultSix10265 struct {
  15630. Cainfo interface{} `json:"cainfo"`
  15631. ErrMsg string `json:"err_msg"`
  15632. InfRefmsgid string `json:"inf_refmsgid"`
  15633. Infcode string `json:"infcode"`
  15634. Output struct {
  15635. } `json:"output"`
  15636. RefmsgTime string `json:"refmsg_time"`
  15637. RespondTime string `json:"respond_time"`
  15638. Signtype interface{} `json:"signtype"`
  15639. WarnMsg interface{} `json:"warn_msg"`
  15640. }
  15641. type ResultSeven struct {
  15642. Cainfo string `json:"cainfo"`
  15643. ErrMsg string `json:"err_msg"`
  15644. InfRefmsgid string `json:"inf_refmsgid"`
  15645. Infcode int64 `json:"infcode"`
  15646. Output struct {
  15647. Setlinfo struct {
  15648. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15649. AcctPay float64 `json:"acct_pay"`
  15650. ActPayDedc float64 `json:"act_pay_dedc"`
  15651. Age float64 `json:"age"`
  15652. Balc float64 `json:"balc"`
  15653. Certno string `json:"certno"`
  15654. ClrOptins string `json:"clr_optins"`
  15655. ClrType string `json:"clr_type"`
  15656. ClrWay string `json:"clr_way"`
  15657. CvlservFlag string `json:"cvlserv_flag"`
  15658. CvlservPay float64 `json:"cvlserv_pay"`
  15659. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15660. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15661. Gend string `json:"gend"`
  15662. HifesPay float64 `json:"hifes_pay"`
  15663. HifmiPay float64 `json:"hifmi_pay"`
  15664. HifpPay float64 `json:"hifp_pay"`
  15665. HospPartAmt float64 `json:"hosp_part_amt"`
  15666. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15667. Insutype string `json:"insutype"`
  15668. MafPay float64 `json:"maf_pay"`
  15669. MdtrtCertType string `json:"mdtrt_cert_type"`
  15670. HifobPay float64 `json:"hifob_pay"`
  15671. MdtrtID string `json:"mdtrt_id"`
  15672. MedType string `json:"med_type"`
  15673. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15674. MedinsSetlID string `json:"medins_setl_id"`
  15675. Naty string `json:"naty"`
  15676. OthPay float64 `json:"oth_pay"`
  15677. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15678. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15679. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15680. PsnCashPay float64 `json:"psn_cash_pay"`
  15681. PsnCertType string `json:"psn_cert_type"`
  15682. PsnName string `json:"psn_name"`
  15683. PsnNo string `json:"psn_no"`
  15684. PsnPartAmt float64 `json:"psn_part_amt"`
  15685. PsnType string `json:"psn_type"`
  15686. SetlID string `json:"setl_id"`
  15687. SetlTime string `json:"setl_time"`
  15688. } `json:"setlinfo"`
  15689. Setldetail interface{} `json:"setldetail"`
  15690. } `json:"output"`
  15691. RefmsgTime string `json:"refmsg_time"`
  15692. RespondTime string `json:"respond_time"`
  15693. Signtype interface{} `json:"signtype"`
  15694. WarnMsg interface{} `json:"warn_msg"`
  15695. }
  15696. type ResultSevenAH struct {
  15697. Cainfo string `json:"cainfo"`
  15698. ErrMsg string `json:"err_msg"`
  15699. InfRefmsgid string `json:"inf_refmsgid"`
  15700. Infcode int64 `json:"infcode"`
  15701. Output struct {
  15702. Setlinfo struct {
  15703. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15704. AcctPay float64 `json:"acct_pay"`
  15705. ActPayDedc float64 `json:"act_pay_dedc"`
  15706. Age float64 `json:"age"`
  15707. Balc float64 `json:"balc"`
  15708. Certno string `json:"certno"`
  15709. ClrOptins string `json:"clr_optins"`
  15710. ClrType string `json:"clr_type"`
  15711. ClrWay string `json:"clr_way"`
  15712. CvlservFlag string `json:"cvlserv_flag"`
  15713. CvlservPay float64 `json:"cvlserv_pay"`
  15714. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15715. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15716. Gend string `json:"gend"`
  15717. HifesPay float64 `json:"hifes_pay"`
  15718. HifmiPay float64 `json:"hifmi_pay"`
  15719. HifpPay float64 `json:"hifp_pay"`
  15720. HospPartAmt float64 `json:"hosp_part_amt"`
  15721. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15722. Insutype string `json:"insutype"`
  15723. MafPay float64 `json:"maf_pay"`
  15724. MdtrtCertType string `json:"mdtrt_cert_type"`
  15725. HifobPay float64 `json:"hifob_pay"`
  15726. MdtrtID string `json:"mdtrt_id"`
  15727. MedType string `json:"med_type"`
  15728. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15729. MedinsSetlID string `json:"medins_setl_id"`
  15730. Naty string `json:"naty"`
  15731. OthPay float64 `json:"oth_pay"`
  15732. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15733. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15734. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15735. PsnCashPay float64 `json:"psn_cash_pay"`
  15736. PsnCertType string `json:"psn_cert_type"`
  15737. PsnName string `json:"psn_name"`
  15738. PsnNo string `json:"psn_no"`
  15739. PsnPartAmt float64 `json:"psn_part_amt"`
  15740. PsnType string `json:"psn_type"`
  15741. SetlID string `json:"setl_id"`
  15742. SetlTime int64 `json:"setl_time"`
  15743. } `json:"setlinfo"`
  15744. Setldetail interface{} `json:"setldetail"`
  15745. } `json:"output"`
  15746. RefmsgTime string `json:"refmsg_time"`
  15747. RespondTime string `json:"respond_time"`
  15748. Signtype interface{} `json:"signtype"`
  15749. WarnMsg interface{} `json:"warn_msg"`
  15750. }
  15751. type ResultSeven10265 struct {
  15752. Cainfo string `json:"cainfo"`
  15753. ErrMsg string `json:"err_msg"`
  15754. InfRefmsgid string `json:"inf_refmsgid"`
  15755. Infcode string `json:"infcode"`
  15756. Output struct {
  15757. Setlinfo struct {
  15758. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15759. AcctPay float64 `json:"acct_pay"`
  15760. ActPayDedc float64 `json:"act_pay_dedc"`
  15761. Age float64 `json:"age"`
  15762. Balc float64 `json:"balc"`
  15763. Certno string `json:"certno"`
  15764. ClrOptins string `json:"clr_optins"`
  15765. ClrType string `json:"clr_type"`
  15766. ClrWay string `json:"clr_way"`
  15767. CvlservFlag string `json:"cvlserv_flag"`
  15768. CvlservPay float64 `json:"cvlserv_pay"`
  15769. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15770. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15771. Gend string `json:"gend"`
  15772. HifesPay float64 `json:"hifes_pay"`
  15773. HifmiPay float64 `json:"hifmi_pay"`
  15774. HifpPay float64 `json:"hifp_pay"`
  15775. HospPartAmt float64 `json:"hosp_part_amt"`
  15776. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15777. Insutype string `json:"insutype"`
  15778. MafPay float64 `json:"maf_pay"`
  15779. MdtrtCertType string `json:"mdtrt_cert_type"`
  15780. HifobPay float64 `json:"hifob_pay"`
  15781. MdtrtID string `json:"mdtrt_id"`
  15782. MedType string `json:"med_type"`
  15783. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15784. MedinsSetlID string `json:"medins_setl_id"`
  15785. Naty string `json:"naty"`
  15786. OthPay float64 `json:"oth_pay"`
  15787. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15788. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15789. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15790. PsnCashPay float64 `json:"psn_cash_pay"`
  15791. PsnCertType string `json:"psn_cert_type"`
  15792. PsnName string `json:"psn_name"`
  15793. PsnNo string `json:"psn_no"`
  15794. PsnPartAmt float64 `json:"psn_part_amt"`
  15795. PsnType string `json:"psn_type"`
  15796. SetlID string `json:"setl_id"`
  15797. SetlTime string `json:"setl_time"`
  15798. } `json:"setlinfo"`
  15799. Setldetail interface{} `json:"setldetail"`
  15800. } `json:"output"`
  15801. RefmsgTime string `json:"refmsg_time"`
  15802. RespondTime string `json:"respond_time"`
  15803. Signtype interface{} `json:"signtype"`
  15804. WarnMsg interface{} `json:"warn_msg"`
  15805. }
  15806. type ResultSeven10265Two struct {
  15807. Cainfo string `json:"cainfo"`
  15808. ErrMsg string `json:"err_msg"`
  15809. InfRefmsgid string `json:"inf_refmsgid"`
  15810. Infcode string `json:"infcode"`
  15811. Output struct {
  15812. Setlinfo struct {
  15813. AcctMulaidPay string `json:"acct_mulaid_pay"`
  15814. AcctPay float64 `json:"acct_pay"`
  15815. ActPayDedc float64 `json:"act_pay_dedc"`
  15816. Age float64 `json:"age"`
  15817. Balc float64 `json:"balc"`
  15818. Certno string `json:"certno"`
  15819. ClrOptins string `json:"clr_optins"`
  15820. ClrType string `json:"clr_type"`
  15821. ClrWay string `json:"clr_way"`
  15822. CvlservFlag string `json:"cvlserv_flag"`
  15823. CvlservPay float64 `json:"cvlserv_pay"`
  15824. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15825. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15826. Gend string `json:"gend"`
  15827. HifesPay float64 `json:"hifes_pay"`
  15828. HifmiPay float64 `json:"hifmi_pay"`
  15829. HifpPay float64 `json:"hifp_pay"`
  15830. HospPartAmt string `json:"hosp_part_amt"`
  15831. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15832. Insutype string `json:"insutype"`
  15833. MafPay float64 `json:"maf_pay"`
  15834. MdtrtCertType string `json:"mdtrt_cert_type"`
  15835. HifobPay float64 `json:"hifob_pay"`
  15836. MdtrtID string `json:"mdtrt_id"`
  15837. MedType string `json:"med_type"`
  15838. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15839. MedinsSetlID string `json:"medins_setl_id"`
  15840. Naty string `json:"naty"`
  15841. OthPay float64 `json:"oth_pay"`
  15842. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15843. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15844. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15845. PsnCashPay float64 `json:"psn_cash_pay"`
  15846. PsnCertType string `json:"psn_cert_type"`
  15847. PsnName string `json:"psn_name"`
  15848. PsnNo string `json:"psn_no"`
  15849. PsnPartAmt float64 `json:"psn_part_amt"`
  15850. PsnType string `json:"psn_type"`
  15851. SetlID string `json:"setl_id"`
  15852. SetlTime string `json:"setl_time"`
  15853. } `json:"setlinfo"`
  15854. Setldetail interface{} `json:"setldetail"`
  15855. } `json:"output"`
  15856. RefmsgTime string `json:"refmsg_time"`
  15857. RespondTime string `json:"respond_time"`
  15858. Signtype interface{} `json:"signtype"`
  15859. WarnMsg interface{} `json:"warn_msg"`
  15860. }
  15861. type GZResultSeven10265Two struct {
  15862. Cainfo string `json:"cainfo"`
  15863. ErrMsg string `json:"err_msg"`
  15864. InfRefmsgid string `json:"inf_refmsgid"`
  15865. Infcode int64 `json:"infcode"`
  15866. Output struct {
  15867. Setlinfo struct {
  15868. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15869. AcctPay float64 `json:"acct_pay"`
  15870. ActPayDedc float64 `json:"act_pay_dedc"`
  15871. Age float64 `json:"age"`
  15872. Balc float64 `json:"balc"`
  15873. Certno string `json:"certno"`
  15874. ClrOptins string `json:"clr_optins"`
  15875. ClrType string `json:"clr_type"`
  15876. ClrWay string `json:"clr_way"`
  15877. CvlservFlag string `json:"cvlserv_flag"`
  15878. CvlservPay float64 `json:"cvlserv_pay"`
  15879. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15880. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15881. Gend string `json:"gend"`
  15882. HifesPay float64 `json:"hifes_pay"`
  15883. HifmiPay float64 `json:"hifmi_pay"`
  15884. HifpPay float64 `json:"hifp_pay"`
  15885. HospPartAmt float64 `json:"hosp_part_amt"`
  15886. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15887. Insutype string `json:"insutype"`
  15888. MafPay float64 `json:"maf_pay"`
  15889. MdtrtCertType string `json:"mdtrt_cert_type"`
  15890. HifobPay float64 `json:"hifob_pay"`
  15891. MdtrtID string `json:"mdtrt_id"`
  15892. MedType string `json:"med_type"`
  15893. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15894. MedinsSetlID string `json:"medins_setl_id"`
  15895. Naty string `json:"naty"`
  15896. OthPay float64 `json:"oth_pay"`
  15897. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15898. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15899. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15900. PsnCashPay float64 `json:"psn_cash_pay"`
  15901. PsnCertType string `json:"psn_cert_type"`
  15902. PsnName string `json:"psn_name"`
  15903. PsnNo string `json:"psn_no"`
  15904. PsnPartAmt float64 `json:"psn_part_amt"`
  15905. PsnType string `json:"psn_type"`
  15906. SetlID string `json:"setl_id"`
  15907. SetlTime string `json:"setl_time"`
  15908. } `json:"setlinfo"`
  15909. Setldetail interface{} `json:"setldetail"`
  15910. } `json:"output"`
  15911. RefmsgTime string `json:"refmsg_time"`
  15912. RespondTime string `json:"respond_time"`
  15913. Signtype interface{} `json:"signtype"`
  15914. WarnMsg interface{} `json:"warn_msg"`
  15915. }
  15916. type ResultEight struct {
  15917. Cainfo string `json:"cainfo"`
  15918. ErrMsg string `json:"err_msg"`
  15919. InfRefmsgid string `json:"inf_refmsgid"`
  15920. Infcode int64 `json:"infcode"`
  15921. Output struct {
  15922. Stmtinfo struct {
  15923. SetlOptins string `json:"setl_optins"`
  15924. StmtRslt string `json:"stmt_rslt"`
  15925. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15926. } `json:"stmtinfo"`
  15927. } `json:"output"`
  15928. RefmsgTime string `json:"refmsg_time"`
  15929. RespondTime string `json:"respond_time"`
  15930. Signtype interface{} `json:"signtype"`
  15931. WarnMsg interface{} `json:"warn_msg"`
  15932. }
  15933. type ResultEightFor10188 struct {
  15934. Cainfo string `json:"cainfo"`
  15935. ErrMsg string `json:"err_msg"`
  15936. InfRefmsgid string `json:"inf_refmsgid"`
  15937. Infcode string `json:"infcode"`
  15938. Output struct {
  15939. Stmtinfo struct {
  15940. SetlOptins string `json:"setl_optins"`
  15941. StmtRslt string `json:"stmt_rslt"`
  15942. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15943. } `json:"stmtinfo"`
  15944. } `json:"output"`
  15945. RefmsgTime string `json:"refmsg_time"`
  15946. RespondTime string `json:"respond_time"`
  15947. Signtype interface{} `json:"signtype"`
  15948. WarnMsg interface{} `json:"warn_msg"`
  15949. }
  15950. type ResultNine struct {
  15951. Cainfo string `json:"cainfo"`
  15952. ErrMsg string `json:"err_msg"`
  15953. InfRefmsgid string `json:"inf_refmsgid"`
  15954. Infcode int64 `json:"infcode"`
  15955. Output struct {
  15956. FileQuryNo string `json:"file_qury_no"`
  15957. } `json:"output"`
  15958. RefmsgTime string `json:"refmsg_time"`
  15959. RespondTime string `json:"respond_time"`
  15960. Signtype interface{} `json:"signtype"`
  15961. WarnMsg interface{} `json:"warn_msg"`
  15962. }
  15963. type ResultTen struct {
  15964. Cainfo string `json:"cainfo"`
  15965. ErrMsg string `json:"err_msg"`
  15966. InfRefmsgid string `json:"inf_refmsgid"`
  15967. Infcode int64 `json:"infcode"`
  15968. Output struct {
  15969. Fileinfo struct {
  15970. DldEndtime string `json:"dld_endtime"`
  15971. FileQuryNo string `json:"file_qury_no"`
  15972. Filename string `json:"filename"`
  15973. } `json:"fileinfo"`
  15974. } `json:"output"`
  15975. RefmsgTime string `json:"refmsg_time"`
  15976. RespondTime string `json:"respond_time"`
  15977. Signtype interface{} `json:"signtype"`
  15978. WarnMsg interface{} `json:"warn_msg"`
  15979. }
  15980. type Result5262 struct {
  15981. ErrMsg string `json:"err_msg"`
  15982. InfRefmsgid string `json:"inf_refmsgid"`
  15983. Infcode int64 `json:"infcode"`
  15984. Output struct {
  15985. PageInfo struct {
  15986. Size int `json:"size"`
  15987. RecordCounts int `json:"record_counts"`
  15988. } `json:"page_info"`
  15989. Idetinfo []interface{} `json:"idetinfo"`
  15990. Result []struct {
  15991. SetlID string `json:"setl_id"`
  15992. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15993. MdtrtID string `json:"mdtrt_id"`
  15994. InitSetlID string `json:"init_setl_id,omitempty"`
  15995. PsnNo string `json:"psn_no"`
  15996. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15997. PsnName string `json:"psn_name"`
  15998. PsnCertType string `json:"psn_cert_type"`
  15999. Certno string `json:"certno"`
  16000. Gend string `json:"gend,omitempty"`
  16001. Naty string `json:"naty,omitempty"`
  16002. Brdy string `json:"brdy,omitempty"`
  16003. Age float64 `json:"age,omitempty"`
  16004. Insutype string `json:"insutype,omitempty"`
  16005. PsnType string `json:"psn_type"`
  16006. CvlservFlag string `json:"cvlserv_flag"`
  16007. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16008. SpPsnType string `json:"sp_psn_type,omitempty"`
  16009. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16010. ClctGrde string `json:"clct_grde,omitempty"`
  16011. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16012. NwbFlag string `json:"nwb_flag,omitempty"`
  16013. InsuAdmdvs string `json:"insu_admdvs"`
  16014. EmpNo string `json:"emp_no,omitempty"`
  16015. EmpName string `json:"emp_name,omitempty"`
  16016. EmpType string `json:"emp_type,omitempty"`
  16017. EconType string `json:"econ_type,omitempty"`
  16018. AfilIndu string `json:"afil_indu,omitempty"`
  16019. AfilRlts string `json:"afil_rlts,omitempty"`
  16020. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16021. PayLoc string `json:"pay_loc,omitempty"`
  16022. FixmedinsCode string `json:"fixmedins_code"`
  16023. FixmedinsName string `json:"fixmedins_name"`
  16024. HospLv string `json:"hosp_lv,omitempty"`
  16025. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16026. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16027. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16028. Begndate string `json:"begndate"`
  16029. Enddate string `json:"enddate"`
  16030. SetlTime string `json:"setl_time"`
  16031. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16032. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16033. MedType string `json:"med_type"`
  16034. SetlType string `json:"setl_type,omitempty"`
  16035. ClrType string `json:"clr_type,omitempty"`
  16036. ClrWay string `json:"clr_way,omitempty"`
  16037. PsnSetlway string `json:"psn_setlway,omitempty"`
  16038. ClrOptins string `json:"clr_optins,omitempty"`
  16039. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  16040. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  16041. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  16042. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  16043. InscpAmt float64 `json:"inscp_amt,omitempty"`
  16044. DedcStd float64 `json:"dedc_std,omitempty"`
  16045. CrtDedc float64 `json:"crt_dedc,omitempty"`
  16046. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  16047. HifpPay float64 `json:"hifp_pay,omitempty"`
  16048. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  16049. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  16050. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  16051. HifesPay float64 `json:"hifes_pay,omitempty"`
  16052. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  16053. HifobPay float64 `json:"hifob_pay,omitempty"`
  16054. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16055. MafPay float64 `json:"maf_pay,omitempty"`
  16056. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16057. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16058. PsnPay float64 `json:"psn_pay,omitempty"`
  16059. AcctPay float64 `json:"acct_pay,omitempty"`
  16060. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16061. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16062. Balc float64 `json:"balc,omitempty"`
  16063. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16064. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16065. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16066. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16067. Year string `json:"year,omitempty"`
  16068. DiseNo string `json:"dise_no,omitempty"`
  16069. DiseName string `json:"dise_name,omitempty"`
  16070. Invono string `json:"invono,omitempty"`
  16071. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16072. ValiFlag string `json:"vali_flag,omitempty"`
  16073. Memo string `json:"memo,omitempty"`
  16074. Rid string `json:"rid"`
  16075. UpdtTime string `json:"updt_time,omitempty"`
  16076. CrterID string `json:"crter_id,omitempty"`
  16077. CrterName string `json:"crter_name,omitempty"`
  16078. CrteTime string `json:"crte_time,omitempty"`
  16079. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  16080. OpterID string `json:"opter_id,omitempty"`
  16081. OpterName string `json:"opter_name,omitempty"`
  16082. OptTime string `json:"opt_time,omitempty"`
  16083. OptinsNo string `json:"optins_no,omitempty"`
  16084. PoolareaNo string `json:"poolarea_no,omitempty"`
  16085. } `json:"result"`
  16086. } `json:"output"`
  16087. RefmsgTime string `json:"refmsg_time"`
  16088. RespondTime string `json:"respond_time"`
  16089. Signtype interface{} `json:"signtype"`
  16090. WarnInfo interface{} `json:"warn_info"`
  16091. }
  16092. type Result5267 struct {
  16093. ErrMsg string `json:"err_msg"`
  16094. InfRefmsgid string `json:"inf_refmsgid"`
  16095. Infcode int64 `json:"infcode"`
  16096. Output struct {
  16097. PageInfo struct {
  16098. Size int `json:"size"`
  16099. RecordCounts int `json:"record_counts"`
  16100. } `json:"pageinfo"`
  16101. Result []struct {
  16102. SetlID string `json:"setl_id"`
  16103. ClrOptins string `json:"clr_optins"`
  16104. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  16105. MdtrtID string `json:"mdtrt_id"`
  16106. InitSetlID string `json:"init_setl_id,omitempty"`
  16107. PsnNo string `json:"psn_no"`
  16108. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  16109. PsnName string `json:"psn_name"`
  16110. PsnCertType string `json:"psn_cert_type"`
  16111. Certno string `json:"certno"`
  16112. Gend string `json:"gend,omitempty"`
  16113. Naty string `json:"naty,omitempty"`
  16114. Brdy string `json:"brdy,omitempty"`
  16115. Age float64 `json:"age,omitempty"`
  16116. Insutype string `json:"insutype,omitempty"`
  16117. PsnType string `json:"psn_type"`
  16118. CvlservFlag string `json:"cvlserv_flag"`
  16119. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16120. SpPsnType string `json:"sp_psn_type,omitempty"`
  16121. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16122. ClctGrde string `json:"clct_grde,omitempty"`
  16123. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16124. NwbFlag string `json:"nwb_flag,omitempty"`
  16125. InsuAdmdvs string `json:"insu_admdvs"`
  16126. EmpNo string `json:"emp_no,omitempty"`
  16127. EmpName string `json:"emp_name,omitempty"`
  16128. EmpType string `json:"emp_type,omitempty"`
  16129. EconType string `json:"econ_type,omitempty"`
  16130. AfilIndu string `json:"afil_indu,omitempty"`
  16131. AfilRlts string `json:"afil_rlts,omitempty"`
  16132. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16133. PayLoc string `json:"pay_loc,omitempty"`
  16134. FixmedinsCode string `json:"fixmedins_code"`
  16135. FixmedinsName string `json:"fixmedins_name"`
  16136. HospLv string `json:"hosp_lv,omitempty"`
  16137. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16138. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16139. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16140. Begndate string `json:"begndate,omitempty"`
  16141. Enddate string `json:"enddate,omitempty"`
  16142. SetlTime string `json:"setl_time,omitempty"`
  16143. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16144. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16145. MedType string `json:"med_type"`
  16146. SetlType string `json:"setl_type,omitempty"`
  16147. ClrType string `json:"clr_type,omitempty"`
  16148. ClrWay string `json:"clr_way,omitempty"`
  16149. PsnSetlway string `json:"psn_setlway,omitempty"`
  16150. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  16151. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  16152. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  16153. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  16154. InscpAmt float64 `json:"inscp_amt,omitempty"`
  16155. DedcStd float64 `json:"dedc_std,omitempty"`
  16156. CrtDedc float64 `json:"crt_dedc,omitempty"`
  16157. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  16158. HifpPay float64 `json:"hifp_pay,omitempty"`
  16159. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  16160. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  16161. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  16162. HifesPay float64 `json:"hifes_pay,omitempty"`
  16163. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  16164. HifobPay float64 `json:"hifob_pay,omitempty"`
  16165. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16166. MafPay float64 `json:"maf_pay,omitempty"`
  16167. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16168. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16169. PsnPay float64 `json:"psn_pay,omitempty"`
  16170. AcctPay float64 `json:"acct_pay,omitempty"`
  16171. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16172. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16173. Balc float64 `json:"balc,omitempty"`
  16174. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16175. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16176. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16177. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16178. Year string `json:"year,omitempty"`
  16179. DiseNo string `json:"dise_no,omitempty"`
  16180. DiseName string `json:"dise_name,omitempty"`
  16181. Invono string `json:"invono,omitempty"`
  16182. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16183. Memo string `json:"memo,omitempty"`
  16184. UpdtTime string `json:"updt_time,omitempty"`
  16185. OpterID string `json:"opter_id,omitempty"`
  16186. OpterName string `json:"opter_name,omitempty"`
  16187. OptTime string `json:"opt_time,omitempty"`
  16188. OptinsNo string `json:"optins_no,omitempty"`
  16189. PoolareaNo string `json:"poolarea_no,omitempty"`
  16190. } `json:"result"`
  16191. } `json:"output"`
  16192. RefmsgTime string `json:"refmsg_time"`
  16193. RespondTime string `json:"respond_time"`
  16194. Signtype interface{} `json:"signtype"`
  16195. WarnInfo interface{} `json:"warn_info"`
  16196. }
  16197. // type Autogenerated struct {
  16198. // Output struct {
  16199. // Setlinfo struct {
  16200. // SetlTime string `json:"setl_time"`
  16201. // CvlservPay float64 `json:"cvlserv_pay"`
  16202. // Year string `json:"year"`
  16203. // MedType string `json:"med_type"`
  16204. // PsnPay float64 `json:"psn_pay"`
  16205. // OpterID string `json:"opter_id"`
  16206. // Begndate string `json:"begndate"`
  16207. // FlxempeFlag string `json:"flxempe_flag"`
  16208. // HifmiPay float64 `json:"hifmi_pay"`
  16209. // PsnNo string `json:"psn_no"`
  16210. // ActPayDedc float64 `json:"act_pay_dedc"`
  16211. // MedinsSetlID interface{} `json:"medins_setl_id"`
  16212. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16213. // ClrWay string `json:"clr_way"`
  16214. // OthPay float64 `json:"oth_pay"`
  16215. // Gend string `json:"gend"`
  16216. // MdtrtID string `json:"mdtrt_id"`
  16217. // AcctPay float64 `json:"acct_pay"`
  16218. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  16219. // Insutype string `json:"insutype"`
  16220. // Invono interface{} `json:"invono"`
  16221. // Enddate string `json:"enddate"`
  16222. // CashPayamt float64 `json:"cash_payamt"`
  16223. // PsnType string `json:"psn_type"`
  16224. // FixmedinsName string `json:"fixmedins_name"`
  16225. // HifpPay float64 `json:"hifp_pay"`
  16226. // NewFlag interface{} `json:"new_flag"`
  16227. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16228. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  16229. // PayLoc string `json:"pay_loc"`
  16230. // ClrType string `json:"clr_type"`
  16231. // RefdSetlFlag string `json:"refd_setl_flag"`
  16232. // CvlservFlag string `json:"cvlserv_flag"`
  16233. // EmpName string `json:"emp_name"`
  16234. // Brdy string `json:"brdy"`
  16235. // Naty string `json:"naty"`
  16236. // Certno string `json:"certno"`
  16237. // DiseCode string `json:"dise_code"`
  16238. // FixmedinsCode string `json:"fixmedins_code"`
  16239. // DedcHospLv string `json:"dedc_hosp_lv"`
  16240. // OpterName string `json:"opter_name"`
  16241. // Balc float64 `json:"balc"`
  16242. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16243. // PsnCertType string `json:"psn_cert_type"`
  16244. // HifobPay float64 `json:"hifob_pay"`
  16245. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  16246. // HifesPay float64 `json:"hifes_pay"`
  16247. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16248. // OptTime string `json:"opt_time"`
  16249. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16250. // SetlID string `json:"setl_id"`
  16251. // MafPay float64 `json:"maf_pay"`
  16252. // PsnName string `json:"psn_name"`
  16253. // InsuOptins interface{} `json:"insu_optins"`
  16254. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16255. // ClrOptins string `json:"clr_optins"`
  16256. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16257. // DiseName string `json:"dise_name"`
  16258. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16259. // Age float64 `json:"age"`
  16260. // DtrtCertType string `json:"dtrt_cert_type"`
  16261. // HospLv string `json:"hosp_lv"`
  16262. // } `json:"setlinfo"`
  16263. // Setldetail []struct {
  16264. // FundPayType string `json:"fund_pay_type"`
  16265. // FundPayamt float64 `json:"fund_payamt"`
  16266. // SetlProcInfo interface{} `json:"setl_proc_info"`
  16267. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  16268. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  16269. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  16270. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16271. // } `json:"setldetail"`
  16272. // } `json:"output"`
  16273. // Infcode int `json:"infcode"`
  16274. // WarnMsg interface{} `json:"warn_msg"`
  16275. // Cainfo interface{} `json:"cainfo"`
  16276. // ErrMsg interface{} `json:"err_msg"`
  16277. // RefmsgTime string `json:"refmsg_time"`
  16278. // Signtype interface{} `json:"signtype"`
  16279. // RespondTime string `json:"respond_time"`
  16280. // InfRefmsgid string `json:"inf_refmsgid"`
  16281. // }
  16282. type Result002 struct {
  16283. Cainfo interface{} `json:"cainfo"`
  16284. ErrMsg string `json:"err_msg"`
  16285. InfRefmsgid string `json:"inf_refmsgid"`
  16286. Infcode int64 `json:"infcode"`
  16287. Output struct {
  16288. RxFile string `json:"rx_file"`
  16289. SignDigest string `json:"sign_digest"`
  16290. SignCertSn string `json:"sign_cert_sn"`
  16291. SignCertDn string `json:"sign_cert_dn"`
  16292. } `json:"output"`
  16293. RefmsgTime string `json:"refmsg_time"`
  16294. RespondTime string `json:"respond_time"`
  16295. Signtype interface{} `json:"signtype"`
  16296. WarnMsg interface{} `json:"warn_msg"`
  16297. }
  16298. type Result003 struct {
  16299. Cainfo interface{} `json:"cainfo"`
  16300. ErrMsg string `json:"err_msg"`
  16301. InfRefmsgid string `json:"inf_refmsgid"`
  16302. Infcode int64 `json:"infcode"`
  16303. Output struct {
  16304. HiRxno string `json:"hi_rxno"`
  16305. RxStasCodg string `json:"rx_stas_codg"`
  16306. RxStasName string `json:"rx_stas_name"`
  16307. } `json:"output"`
  16308. RefmsgTime string `json:"refmsg_time"`
  16309. RespondTime string `json:"respond_time"`
  16310. Signtype interface{} `json:"signtype"`
  16311. WarnMsg interface{} `json:"warn_msg"`
  16312. }
  16313. type ResultEleven struct {
  16314. Cainfo string `json:"cainfo"`
  16315. ErrMsg string `json:"err_msg"`
  16316. InfRefmsgid string `json:"inf_refmsgid"`
  16317. Infcode int64 `json:"infcode"`
  16318. Output struct {
  16319. Setlinfo struct {
  16320. SetlTime string `json:"setl_time"`
  16321. CvlservPay float64 `json:"cvlserv_pay"`
  16322. Year string `json:"year"`
  16323. MedType string `json:"med_type"`
  16324. PsnPay float64 `json:"psn_pay"`
  16325. OpterID string `json:"opter_id"`
  16326. Begndate string `json:"begndate"`
  16327. FlxempeFlag string `json:"flxempe_flag"`
  16328. HifmiPay float64 `json:"hifmi_pay"`
  16329. PsnNo string `json:"psn_no"`
  16330. ActPayDedc float64 `json:"act_pay_dedc"`
  16331. MedinsSetlID interface{} `json:"medins_setl_id"`
  16332. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16333. ClrWay string `json:"clr_way"`
  16334. OthPay float64 `json:"oth_pay"`
  16335. Gend string `json:"gend"`
  16336. MdtrtID string `json:"mdtrt_id"`
  16337. AcctPay float64 `json:"acct_pay"`
  16338. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16339. Insutype string `json:"insutype"`
  16340. Invono interface{} `json:"invono"`
  16341. Enddate string `json:"enddate"`
  16342. CashPayamt float64 `json:"cash_payamt"`
  16343. PsnType string `json:"psn_type"`
  16344. FixmedinsName string `json:"fixmedins_name"`
  16345. HifpPay float64 `json:"hifp_pay"`
  16346. NewFlag interface{} `json:"new_flag"`
  16347. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16348. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16349. PayLoc string `json:"pay_loc"`
  16350. ClrType string `json:"clr_type"`
  16351. RefdSetlFlag string `json:"refd_setl_flag"`
  16352. CvlservFlag string `json:"cvlserv_flag"`
  16353. EmpName string `json:"emp_name"`
  16354. Brdy string `json:"brdy"`
  16355. Naty string `json:"naty"`
  16356. Certno string `json:"certno"`
  16357. DiseCode string `json:"dise_code"`
  16358. FixmedinsCode string `json:"fixmedins_code"`
  16359. DedcHospLv string `json:"dedc_hosp_lv"`
  16360. OpterName string `json:"opter_name"`
  16361. Balc float64 `json:"balc"`
  16362. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16363. PsnCertType string `json:"psn_cert_type"`
  16364. HifobPay float64 `json:"hifob_pay"`
  16365. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16366. HifesPay float64 `json:"hifes_pay"`
  16367. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16368. OptTime string `json:"opt_time"`
  16369. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16370. SetlID string `json:"setl_id"`
  16371. MafPay float64 `json:"maf_pay"`
  16372. PsnName string `json:"psn_name"`
  16373. InsuOptins interface{} `json:"insu_optins"`
  16374. PrefFundPay interface{} `json:"pref_fund_pay"`
  16375. ClrOptins string `json:"clr_optins"`
  16376. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16377. DiseName string `json:"dise_name"`
  16378. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16379. Age float64 `json:"age"`
  16380. DtrtCertType string `json:"dtrt_cert_type"`
  16381. HospLv string `json:"hosp_lv"`
  16382. PsnCashPay float64 `json:"psn_cash_pay"`
  16383. } `json:"setlinfo"`
  16384. } `json:"output"`
  16385. RefmsgTime string `json:"refmsg_time"`
  16386. RespondTime string `json:"respond_time"`
  16387. Signtype interface{} `json:"signtype"`
  16388. WarnMsg interface{} `json:"warn_msg"`
  16389. }
  16390. type ResultElevenah struct {
  16391. Cainfo string `json:"cainfo"`
  16392. ErrMsg string `json:"err_msg"`
  16393. InfRefmsgid string `json:"inf_refmsgid"`
  16394. Infcode int64 `json:"infcode"`
  16395. Output struct {
  16396. Setlinfo struct {
  16397. SetlTime int64 `json:"setl_time"`
  16398. CvlservPay float64 `json:"cvlserv_pay"`
  16399. Year string `json:"year"`
  16400. MedType string `json:"med_type"`
  16401. PsnPay float64 `json:"psn_pay"`
  16402. OpterID string `json:"opter_id"`
  16403. Begndate int64 `json:"begndate"`
  16404. FlxempeFlag string `json:"flxempe_flag"`
  16405. HifmiPay float64 `json:"hifmi_pay"`
  16406. PsnNo string `json:"psn_no"`
  16407. ActPayDedc float64 `json:"act_pay_dedc"`
  16408. MedinsSetlID interface{} `json:"medins_setl_id"`
  16409. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16410. ClrWay string `json:"clr_way"`
  16411. OthPay float64 `json:"oth_pay"`
  16412. Gend string `json:"gend"`
  16413. MdtrtID string `json:"mdtrt_id"`
  16414. AcctPay float64 `json:"acct_pay"`
  16415. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16416. Insutype string `json:"insutype"`
  16417. Invono interface{} `json:"invono"`
  16418. Enddate int64 `json:"enddate"`
  16419. CashPayamt float64 `json:"cash_payamt"`
  16420. PsnType string `json:"psn_type"`
  16421. FixmedinsName string `json:"fixmedins_name"`
  16422. HifpPay float64 `json:"hifp_pay"`
  16423. NewFlag interface{} `json:"new_flag"`
  16424. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16425. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16426. PayLoc string `json:"pay_loc"`
  16427. ClrType string `json:"clr_type"`
  16428. RefdSetlFlag string `json:"refd_setl_flag"`
  16429. CvlservFlag string `json:"cvlserv_flag"`
  16430. EmpName string `json:"emp_name"`
  16431. Brdy int64 `json:"brdy"`
  16432. Naty string `json:"naty"`
  16433. Certno string `json:"certno"`
  16434. DiseCode string `json:"dise_code"`
  16435. FixmedinsCode string `json:"fixmedins_code"`
  16436. DedcHospLv string `json:"dedc_hosp_lv"`
  16437. OpterName string `json:"opter_name"`
  16438. Balc float64 `json:"balc"`
  16439. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16440. PsnCertType string `json:"psn_cert_type"`
  16441. HifobPay float64 `json:"hifob_pay"`
  16442. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16443. HifesPay float64 `json:"hifes_pay"`
  16444. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16445. OptTime int64 `json:"opt_time"`
  16446. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16447. SetlID string `json:"setl_id"`
  16448. MafPay float64 `json:"maf_pay"`
  16449. PsnName string `json:"psn_name"`
  16450. InsuOptins interface{} `json:"insu_optins"`
  16451. PrefFundPay interface{} `json:"pref_fund_pay"`
  16452. ClrOptins string `json:"clr_optins"`
  16453. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16454. DiseName string `json:"dise_name"`
  16455. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16456. Age float64 `json:"age"`
  16457. DtrtCertType string `json:"dtrt_cert_type"`
  16458. HospLv string `json:"hosp_lv"`
  16459. PsnCashPay float64 `json:"psn_cash_pay"`
  16460. } `json:"setlinfo"`
  16461. } `json:"output"`
  16462. RefmsgTime string `json:"refmsg_time"`
  16463. RespondTime string `json:"respond_time"`
  16464. Signtype interface{} `json:"signtype"`
  16465. WarnMsg interface{} `json:"warn_msg"`
  16466. }
  16467. type ResultEleven10265 struct {
  16468. Cainfo string `json:"cainfo"`
  16469. ErrMsg string `json:"err_msg"`
  16470. InfRefmsgid string `json:"inf_refmsgid"`
  16471. Infcode string `json:"infcode"`
  16472. Output struct {
  16473. Setlinfo struct {
  16474. SetlTime string `json:"setl_time"`
  16475. CvlservPay float64 `json:"cvlserv_pay"`
  16476. Year string `json:"year"`
  16477. MedType string `json:"med_type"`
  16478. PsnPay float64 `json:"psn_pay"`
  16479. OpterID string `json:"opter_id"`
  16480. Begndate string `json:"begndate"`
  16481. FlxempeFlag string `json:"flxempe_flag"`
  16482. HifmiPay float64 `json:"hifmi_pay"`
  16483. PsnNo string `json:"psn_no"`
  16484. ActPayDedc float64 `json:"act_pay_dedc"`
  16485. MedinsSetlID interface{} `json:"medins_setl_id"`
  16486. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16487. ClrWay string `json:"clr_way"`
  16488. OthPay float64 `json:"oth_pay"`
  16489. Gend string `json:"gend"`
  16490. MdtrtID string `json:"mdtrt_id"`
  16491. AcctPay float64 `json:"acct_pay"`
  16492. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16493. Insutype string `json:"insutype"`
  16494. Invono interface{} `json:"invono"`
  16495. Enddate string `json:"enddate"`
  16496. CashPayamt float64 `json:"cash_payamt"`
  16497. PsnType string `json:"psn_type"`
  16498. FixmedinsName string `json:"fixmedins_name"`
  16499. HifpPay float64 `json:"hifp_pay"`
  16500. NewFlag interface{} `json:"new_flag"`
  16501. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16502. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16503. PayLoc string `json:"pay_loc"`
  16504. ClrType string `json:"clr_type"`
  16505. RefdSetlFlag string `json:"refd_setl_flag"`
  16506. CvlservFlag string `json:"cvlserv_flag"`
  16507. EmpName string `json:"emp_name"`
  16508. Brdy string `json:"brdy"`
  16509. Naty string `json:"naty"`
  16510. Certno string `json:"certno"`
  16511. DiseCode string `json:"dise_code"`
  16512. FixmedinsCode string `json:"fixmedins_code"`
  16513. DedcHospLv string `json:"dedc_hosp_lv"`
  16514. OpterName string `json:"opter_name"`
  16515. Balc float64 `json:"balc"`
  16516. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16517. PsnCertType string `json:"psn_cert_type"`
  16518. HifobPay float64 `json:"hifob_pay"`
  16519. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16520. HifesPay float64 `json:"hifes_pay"`
  16521. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16522. OptTime string `json:"opt_time"`
  16523. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16524. SetlID string `json:"setl_id"`
  16525. MafPay float64 `json:"maf_pay"`
  16526. PsnName string `json:"psn_name"`
  16527. InsuOptins interface{} `json:"insu_optins"`
  16528. PrefFundPay interface{} `json:"pref_fund_pay"`
  16529. ClrOptins string `json:"clr_optins"`
  16530. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16531. DiseName string `json:"dise_name"`
  16532. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16533. Age float64 `json:"age"`
  16534. DtrtCertType string `json:"dtrt_cert_type"`
  16535. HospLv string `json:"hosp_lv"`
  16536. PsnCashPay float64 `json:"psn_cash_pay"`
  16537. } `json:"setlinfo"`
  16538. } `json:"output"`
  16539. RefmsgTime string `json:"refmsg_time"`
  16540. RespondTime string `json:"respond_time"`
  16541. Signtype interface{} `json:"signtype"`
  16542. WarnMsg interface{} `json:"warn_msg"`
  16543. }
  16544. type ResultTwelve struct {
  16545. Cainfo string `json:"cainfo"`
  16546. ErrMsg string `json:"err_msg"`
  16547. InfRefmsgid string `json:"inf_refmsgid"`
  16548. Infcode int64 `json:"infcode"`
  16549. Output struct {
  16550. MdtrtId string `json:"mdtrt_id"`
  16551. ChrgBchno string `json:"chrg_bchno"`
  16552. PsnNo string `json:"psn_no"`
  16553. } `json:"output"`
  16554. RefmsgTime string `json:"refmsg_time"`
  16555. RespondTime string `json:"respond_time"`
  16556. Signtype interface{} `json:"signtype"`
  16557. WarnMsg interface{} `json:"warn_msg"`
  16558. }
  16559. type ResultThirteen struct {
  16560. ErrMsg string `json:"err_msg"`
  16561. InfRefmsgid string `json:"inf_refmsgid"`
  16562. Infcode int64 `json:"infcode"`
  16563. Output struct {
  16564. Result struct {
  16565. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16566. } `json:"result"`
  16567. } `json:"output"`
  16568. RefmsgTime string `json:"refmsg_time"`
  16569. RespondTime string `json:"respond_time"`
  16570. Signtype interface{} `json:"signtype"`
  16571. WarnInfo interface{} `json:"warn_info"`
  16572. }
  16573. type ResultThirteen10265 struct {
  16574. ErrMsg string `json:"err_msg"`
  16575. InfRefmsgid string `json:"inf_refmsgid"`
  16576. Infcode string `json:"infcode"`
  16577. Output struct {
  16578. Result struct {
  16579. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16580. } `json:"result"`
  16581. } `json:"output"`
  16582. RefmsgTime string `json:"refmsg_time"`
  16583. RespondTime string `json:"respond_time"`
  16584. Signtype interface{} `json:"signtype"`
  16585. WarnInfo interface{} `json:"warn_info"`
  16586. }
  16587. type ResultFourteen struct {
  16588. ErrMsg string `json:"err_msg"`
  16589. InfRefmsgid string `json:"inf_refmsgid"`
  16590. Infcode int64 `json:"infcode"`
  16591. Output struct {
  16592. } `json:"output"`
  16593. RefmsgTime string `json:"refmsg_time"`
  16594. RespondTime string `json:"respond_time"`
  16595. Signtype interface{} `json:"signtype"`
  16596. WarnInfo interface{} `json:"warn_info"`
  16597. }
  16598. type ResultCFYLJG001 struct {
  16599. ErrMsg string `json:"err_msg"`
  16600. InfRefmsgid string `json:"inf_refmsgid"`
  16601. Infcode int64 `json:"infcode"`
  16602. Output struct {
  16603. RxTraceCode string `json:"rx_trace_code"`
  16604. HiRxno string `json:"hi_rxno"`
  16605. } `json:"output"`
  16606. RefmsgTime string `json:"refmsg_time"`
  16607. RespondTime string `json:"respond_time"`
  16608. Signtype interface{} `json:"signtype"`
  16609. WarnInfo interface{} `json:"warn_info"`
  16610. }
  16611. type ResultCFYLJG007 struct {
  16612. ErrMsg string `json:"err_msg"`
  16613. InfRefmsgid string `json:"inf_refmsgid"`
  16614. Infcode int64 `json:"infcode"`
  16615. Output struct {
  16616. HiRxno string `json:"hi_rxno"`
  16617. RxStasName string `json:"rx_stas_name"`
  16618. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  16619. Seltdelts []interface{} `json:"seltdelts"`
  16620. RxUsedStasName string `json:"rx_used_stas_name"`
  16621. RxStasCodg string `json:"rx_stas_codg"`
  16622. } `json:"output"`
  16623. RefmsgTime string `json:"refmsg_time"`
  16624. RespondTime string `json:"respond_time"`
  16625. Signtype interface{} `json:"signtype"`
  16626. WarnInfo interface{} `json:"warn_info"`
  16627. }
  16628. type ResultCFYLJG002 struct {
  16629. ErrMsg string `json:"err_msg"`
  16630. InfRefmsgid string `json:"inf_refmsgid"`
  16631. Infcode int64 `json:"infcode"`
  16632. Output struct {
  16633. RxFile string `json:"rx_file"`
  16634. SignDigest string `json:"sign_digest"`
  16635. SignCertSn string `json:"sign_cert_sn"`
  16636. SignCertDn string `json:"sign_cert_dn"`
  16637. } `json:"output"`
  16638. RefmsgTime string `json:"refmsg_time"`
  16639. RespondTime string `json:"respond_time"`
  16640. Signtype interface{} `json:"signtype"`
  16641. WarnInfo interface{} `json:"warn_info"`
  16642. }
  16643. type ResultCFYLJG003 struct {
  16644. ErrMsg string `json:"err_msg"`
  16645. InfRefmsgid string `json:"inf_refmsgid"`
  16646. Infcode int64 `json:"infcode"`
  16647. Output struct {
  16648. HiRxno string `json:"hi_rxno"`
  16649. RxStasCodg string `json:"rx_stas_codg"`
  16650. RxStasName string `json:"rx_stas_name"`
  16651. } `json:"output"`
  16652. RefmsgTime string `json:"refmsg_time"`
  16653. RespondTime string `json:"respond_time"`
  16654. Signtype interface{} `json:"signtype"`
  16655. WarnInfo interface{} `json:"warn_info"`
  16656. }
  16657. type ResultCFYLJG004 struct {
  16658. ErrMsg string `json:"err_msg"`
  16659. InfRefmsgid string `json:"inf_refmsgid"`
  16660. Infcode int64 `json:"infcode"`
  16661. Output struct {
  16662. HiRxno string `json:"hi_rxno"`
  16663. RxStasCodg string `json:"rx_stas_codg"`
  16664. RxStasName string `json:"rx_stas_name"`
  16665. } `json:"output"`
  16666. RefmsgTime string `json:"refmsg_time"`
  16667. RespondTime string `json:"respond_time"`
  16668. Signtype interface{} `json:"signtype"`
  16669. WarnInfo interface{} `json:"warn_info"`
  16670. }
  16671. type ResultCFYLJG008 struct {
  16672. ErrMsg string `json:"err_msg"`
  16673. InfRefmsgid string `json:"inf_refmsgid"`
  16674. Infcode int64 `json:"infcode"`
  16675. Output struct {
  16676. PoolareaNo string `json:"poolareaNo"`
  16677. AdmdvsName string `json:"admdvsName"`
  16678. Count string `json:"count"`
  16679. } `json:"output"`
  16680. RefmsgTime string `json:"refmsg_time"`
  16681. RespondTime string `json:"respond_time"`
  16682. Signtype interface{} `json:"signtype"`
  16683. WarnInfo interface{} `json:"warn_info"`
  16684. }
  16685. type ResultCFYLJG005 struct {
  16686. ErrMsg string `json:"err_msg"`
  16687. InfRefmsgid string `json:"inf_refmsgid"`
  16688. Infcode int64 `json:"infcode"`
  16689. Output struct {
  16690. HiRxNo string `json:"hi_rxno"`
  16691. FixMedinsCode string `json:"fixmedins_code"`
  16692. FixMedinsName string `json:"fixmedins_name"`
  16693. RxStasCodg string `json:"rx_stas_codg"`
  16694. RxStasName string `json:"rx_stas_name"`
  16695. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  16696. RxUserdStasName string `json:"rx_userd_stas_name"`
  16697. PrscTime string `json:"prsc_time"`
  16698. RxDrugCnt float64 `json:"rx_drug_cnt"`
  16699. RxUsedWayCodg string `json:"rx_used_way_codg"`
  16700. RxUsedWayName string `json:"rx_used_way_name"`
  16701. RxFrquCodg string `json:"rx_frqu_codg"`
  16702. RxFrquName string `json:"rx_frqu_name"`
  16703. RxDosunt string `json:"rx_dosunt"`
  16704. RxDoscnt float64 `json:"rx_doscnt"`
  16705. RxDrordDscr string `json:"rx_drord_dscr"`
  16706. ValiDays int64 `json:"vali_days"`
  16707. ValiEndTime string `json:"vali_end_time"`
  16708. ReptFlag string `json:"rept_flag"`
  16709. MaxReptCnt int64 `json:"max_rept_cnt"`
  16710. ReptdCnt int64 `json:"reptd_cnt"`
  16711. MinInrvDays int64 `json:"min_inrv_days"`
  16712. RxTypeCode string `json:"rx_type_code"`
  16713. RxTypeName string `json:"rx_type_name"`
  16714. LongRxFlag string `json:"long_rx_flag"`
  16715. RxDetlList []struct {
  16716. MedListCodg string `json:"med_list_codg"`
  16717. MedinsListCodg string `json:"medins_list_codg"`
  16718. HospPrepFlag string `json:"hosp_prep_flag"`
  16719. RxItemTypeCode string `json:"rx_item_type_code"`
  16720. RxItemTypeName string `json:"rx_item_type_name"`
  16721. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  16722. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  16723. TcmHerbFoote string `json:"tcmherb_foote"`
  16724. MednTypeCode string `json:"medn_type_code"`
  16725. MednTypeName string `json:"medn_type_name"`
  16726. MainMedcFlag string `json:"main_medc_flag"`
  16727. UrgtFlag string `json:"urgt_flag"`
  16728. BasMednFlag string `json:"bas_medn_flag"`
  16729. ImpDrugFlag string `json:"imp_drug_flag"`
  16730. ProdBarc string `json:"prod_barc"`
  16731. DrugProdname string `json:"drug_prodname"`
  16732. GennameCodg string `json:"genname_codg"`
  16733. DrugGenname string `json:"drug_genname"`
  16734. DrugDosform string `json:"drug_dosform"`
  16735. DrugSpec string `json:"drug_spec"`
  16736. PrdrName string `json:"prdr_name"`
  16737. MedcWayCodg string `json:"medc_way_codg"`
  16738. MedcWayDscr string `json:"medc_way_dscr"`
  16739. MedcBegntime string `json:"medc_begntime"`
  16740. MedcEndtime string `json:"medc_endtime"`
  16741. MedcDays float64 `json:"medc_days"`
  16742. DrugPric float64 `json:"drug_pric"`
  16743. DrugSumamt float64 `json:"drug_sumamt"`
  16744. DrugCnt float64 `json:"drug_cnt"`
  16745. DrugDosunt string `json:"drug_dosunt"`
  16746. SinDoscnt float64 `json:"sin_doscnt"`
  16747. SinDosunt string `json:"sin_dosunt"`
  16748. UsedFrquCodg string `json:"used_frqu_codg"`
  16749. UsedFrquName string `json:"used_frqu_name"`
  16750. DrugTotlcnt string `json:"drug_totlcnt"`
  16751. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  16752. DiseCodg string `json:"dise_codg"`
  16753. HospApprFlag string `json:"hosp_appr_flag"`
  16754. } `json:"rx_detl_list"`
  16755. RxOtpinfo struct {
  16756. MedType string `json:"med_type"`
  16757. IptOtpNo string `json:"ipt_otp_no"`
  16758. OtpIptFlag string `json:"otp_ipt_flag"`
  16759. PatnName string `json:"patn_name"`
  16760. PatnAge float64 `json:"patn_age"`
  16761. PatnHgt float64 `json:"patn_hgt"`
  16762. PatnWt float64 `json:"patn_wt"`
  16763. Gend string `json:"gend"`
  16764. GesoVal float64 `json:"geso_val"`
  16765. NwbFlag string `json:"nwb_flag"`
  16766. NwbAge string `json:"nwb_age"`
  16767. SuckPrdFlag string `json:"suck_prd_flag"`
  16768. AlgsHis string `json:"algs_his"`
  16769. Insutype string `json:"insutype"`
  16770. PrscDeptName string `json:"prsc_dept_name"`
  16771. PrscDrName string `json:"prsc_dr_name"`
  16772. PharName string `json:"phar_name"`
  16773. PharChkTime string `json:"phar_chk_time"`
  16774. MdtrtTime string `json:"mdtrt_time"`
  16775. DiseCodg string `json:"dise_codg"`
  16776. DiseName string `json:"dise_name"`
  16777. SpDiseFlag string `json:"sp_dise_flag"`
  16778. MaindiagCode string `json:"maindiag_code"`
  16779. MaindiagName string `json:"maindiag_name"`
  16780. DiseCondDscr string `json:"dise_cond_dscr"`
  16781. FstdiagFlag string `json:"fstdiag_flag"`
  16782. } `json:"rx_otpinfo"`
  16783. RxDiseList []struct {
  16784. DiagType string `json:"diag_type"`
  16785. MaindiagFlag string `json:"maindiag_flag"`
  16786. DiagSrtNo string `json:"diag_srt_no"`
  16787. DiagCode string `json:"diag_code"`
  16788. DiagName string `json:"diag_name"`
  16789. DiagDept string `json:"diag_dept"`
  16790. DiagDrNo string `json:"diag_dr_no"`
  16791. DiagDrName string `json:"diag_dr_name"`
  16792. DiagTime string `json:"diag_time"`
  16793. TcmDiseCode string `json:"tcm_dise_code"`
  16794. TcmDiseName string `json:"tcm_dise_name"`
  16795. TcmSympCode string `json:"tcmsymp_code"`
  16796. TcmSymp string `json:"tcmsymp"`
  16797. } `json:"rx_dise_list"`
  16798. } `json:"output"`
  16799. RefmsgTime string `json:"refmsg_time"`
  16800. RespondTime string `json:"respond_time"`
  16801. Signtype interface{} `json:"signtype"`
  16802. WarnInfo interface{} `json:"warn_info"`
  16803. }
  16804. type ResultCFYLJG006 struct {
  16805. ErrMsg string `json:"err_msg"`
  16806. InfRefmsgid string `json:"inf_refmsgid"`
  16807. Infcode int64 `json:"infcode"`
  16808. Output struct {
  16809. HiRxNo string `json:"hi_rxno"`
  16810. PharCode string `json:"phar_code"`
  16811. PharName string `json:"phar_name"`
  16812. RxChkOpnn string `json:"rx_chk_opnn"`
  16813. RxChkTime string `json:"rx_chk_time"`
  16814. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  16815. RxChkStasName string `json:"rx_chk_stas_name"`
  16816. RxStasCodg string `json:"rx_stas_codg"`
  16817. RxStasName string `json:"rx_stas_name"`
  16818. } `json:"output"`
  16819. RefmsgTime string `json:"refmsg_time"`
  16820. RespondTime string `json:"respond_time"`
  16821. Signtype interface{} `json:"signtype"`
  16822. WarnInfo interface{} `json:"warn_info"`
  16823. }
  16824. type ResultFourteen10265 struct {
  16825. ErrMsg string `json:"err_msg"`
  16826. InfRefmsgid string `json:"inf_refmsgid"`
  16827. Infcode string `json:"infcode"`
  16828. Output struct {
  16829. } `json:"output"`
  16830. RefmsgTime string `json:"refmsg_time"`
  16831. RespondTime string `json:"respond_time"`
  16832. Signtype interface{} `json:"signtype"`
  16833. WarnInfo interface{} `json:"warn_info"`
  16834. }
  16835. type ResultSixteen struct {
  16836. Cainfo string `json:"cainfo"`
  16837. ErrMsg string `json:"err_msg"`
  16838. InfRefmsgid string `json:"inf_refmsgid"`
  16839. Infcode int64 `json:"infcode"`
  16840. Output struct {
  16841. Setlinfo struct {
  16842. MdtrtID string `json:"mdtrt_id"`
  16843. SetlID string `json:"setl_id"`
  16844. ClrOptins string `json:"clr_optins"`
  16845. SetlTime string `json:"setl_time"`
  16846. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16847. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16848. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16849. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16850. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16851. ActPayDedc float64 `json:"act_pay_dedc"`
  16852. HifpPay float64 `json:"hifp_pay"`
  16853. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16854. Lfpay float64 `json:"selfpay"`
  16855. CvlservPay float64 `json:"cvlserv_pay"`
  16856. HifesPay float64 `json:"hifes_pay"`
  16857. HifmiPay float64 `json:"hifmi_pay"`
  16858. HifobPay float64 `json:"hifob_pay"`
  16859. MafPay float64 `json:"maf_pay"`
  16860. OthPay float64 `json:"oth_pay"`
  16861. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16862. PsnPartAmt float64 `json:"psn_part_amt"`
  16863. AcctPay float64 `json:"acct_pay"`
  16864. Balc float64 `json:"balc"`
  16865. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16866. HospPartAmt float64 `json:"hosp_part_amt"`
  16867. MedinsSetlID string `json:"medins_setl_id"`
  16868. PdnCashPay string `json:"pdn_cash_pay"`
  16869. } `json:"setlinfo"`
  16870. } `json:"output"`
  16871. RefmsgTime string `json:"refmsg_time"`
  16872. RespondTime string `json:"respond_time"`
  16873. Signtype interface{} `json:"signtype"`
  16874. WarnMsg interface{} `json:"warn_msg"`
  16875. }
  16876. type ResultSixteen10265 struct {
  16877. Cainfo string `json:"cainfo"`
  16878. ErrMsg string `json:"err_msg"`
  16879. InfRefmsgid string `json:"inf_refmsgid"`
  16880. Infcode string `json:"infcode"`
  16881. Output struct {
  16882. Setlinfo struct {
  16883. MdtrtID string `json:"mdtrt_id"`
  16884. SetlID string `json:"setl_id"`
  16885. ClrOptins string `json:"clr_optins"`
  16886. SetlTime string `json:"setl_time"`
  16887. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16888. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16889. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16890. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16891. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16892. ActPayDedc float64 `json:"act_pay_dedc"`
  16893. HifpPay float64 `json:"hifp_pay"`
  16894. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16895. Lfpay float64 `json:"selfpay"`
  16896. CvlservPay float64 `json:"cvlserv_pay"`
  16897. HifesPay float64 `json:"hifes_pay"`
  16898. HifmiPay float64 `json:"hifmi_pay"`
  16899. HifobPay float64 `json:"hifob_pay"`
  16900. MafPay float64 `json:"maf_pay"`
  16901. OthPay float64 `json:"oth_pay"`
  16902. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16903. PsnPartAmt float64 `json:"psn_part_amt"`
  16904. AcctPay float64 `json:"acct_pay"`
  16905. Balc float64 `json:"balc"`
  16906. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16907. HospPartAmt float64 `json:"hosp_part_amt"`
  16908. MedinsSetlID string `json:"medins_setl_id"`
  16909. PdnCashPay string `json:"pdn_cash_pay"`
  16910. } `json:"setlinfo"`
  16911. } `json:"output"`
  16912. RefmsgTime string `json:"refmsg_time"`
  16913. RespondTime string `json:"respond_time"`
  16914. Signtype interface{} `json:"signtype"`
  16915. WarnMsg interface{} `json:"warn_msg"`
  16916. }
  16917. type ResultSixteen10265Two struct {
  16918. Cainfo string `json:"cainfo"`
  16919. ErrMsg string `json:"err_msg"`
  16920. InfRefmsgid string `json:"inf_refmsgid"`
  16921. Infcode string `json:"infcode"`
  16922. Output struct {
  16923. Setlinfo interface{} `json:"setlinfo"`
  16924. } `json:"output"`
  16925. RefmsgTime string `json:"refmsg_time"`
  16926. RespondTime string `json:"respond_time"`
  16927. Signtype interface{} `json:"signtype"`
  16928. WarnMsg interface{} `json:"warn_msg"`
  16929. }
  16930. type ResultgzSixteen10265Two struct {
  16931. Cainfo string `json:"cainfo"`
  16932. ErrMsg string `json:"err_msg"`
  16933. InfRefmsgid string `json:"inf_refmsgid"`
  16934. Infcode int64 `json:"infcode"`
  16935. Output struct {
  16936. Setlinfo interface{} `json:"setlinfo"`
  16937. } `json:"output"`
  16938. RefmsgTime string `json:"refmsg_time"`
  16939. RespondTime string `json:"respond_time"`
  16940. Signtype interface{} `json:"signtype"`
  16941. WarnMsg interface{} `json:"warn_msg"`
  16942. }
  16943. type ResultSeventeen struct {
  16944. ErrMsg string `json:"err_msg"`
  16945. InfRefmsgid string `json:"inf_refmsgid"`
  16946. Infcode int64 `json:"infcode"`
  16947. Output struct {
  16948. SetlListId string `json:"setl_list_id"`
  16949. } `json:"output"`
  16950. RefmsgTime string `json:"refmsg_time"`
  16951. RespondTime string `json:"respond_time"`
  16952. Signtype string `json:"signtype"`
  16953. WarnInfo string `json:"warn_info"`
  16954. }
  16955. type ResultSeventeenOther struct {
  16956. ErrMsg string `json:"err_msg"`
  16957. InfRefmsgid string `json:"inf_refmsgid"`
  16958. Infcode string `json:"infcode"`
  16959. Output struct {
  16960. SetlListId string `json:"setl_list_id"`
  16961. } `json:"output"`
  16962. RefmsgTime string `json:"refmsg_time"`
  16963. RespondTime string `json:"respond_time"`
  16964. Signtype string `json:"signtype"`
  16965. WarnInfo string `json:"warn_info"`
  16966. }
  16967. type Result90991 struct {
  16968. ErrMsg string `json:"err_msg"`
  16969. InfRefmsgid string `json:"inf_refmsgid"`
  16970. Infcode int64 `json:"infcode"`
  16971. Output struct {
  16972. Result struct {
  16973. PsnNo string `json:"psn_no"`
  16974. CardStat string `json:"card_stat"`
  16975. Certno string `json:"certno"`
  16976. PsnName string `json:"psn_name"`
  16977. CheckStat string `json:"check_stat"`
  16978. SscnoCheckStat string `json:"sscno_check_stat"`
  16979. } `json:"result"`
  16980. } `json:"output"`
  16981. RefmsgTime string `json:"refmsg_time"`
  16982. RespondTime string `json:"respond_time"`
  16983. Signtype interface{} `json:"signtype"`
  16984. WarnInfo interface{} `json:"warn_info"`
  16985. }
  16986. type Result90100 struct {
  16987. ErrMsg string `json:"err_msg"`
  16988. InfRefmsgid string `json:"inf_refmsgid"`
  16989. Infcode int64 `json:"infcode"`
  16990. Output struct {
  16991. PoolareaNo string `json:"poolarea_no"`
  16992. PoolareaNoName string `json:"poolarea_no_name"`
  16993. Insutype string `json:"insutype"`
  16994. InsutypeName string `json:"insutype_name"`
  16995. ClctType string `json:"clct_type"`
  16996. ClctTypeName string `json:"clct_type_name"`
  16997. ClctFlag string `json:"clct_flag"`
  16998. ClctFlagName string `json:"clct_flag_name"`
  16999. AccrymBegn string `json:"accrym_begn"`
  17000. AccrymEnd string `json:"accrym_end"`
  17001. ClctTime string `json:"clct_time"`
  17002. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  17003. } `json:"output"`
  17004. RefmsgTime string `json:"refmsg_time"`
  17005. RespondTime string `json:"respond_time"`
  17006. Signtype interface{} `json:"signtype"`
  17007. WarnInfo interface{} `json:"warn_info"`
  17008. }
  17009. type Custom struct {
  17010. DetItemFeeSumamt string
  17011. Cut string
  17012. FeedetlSn string
  17013. Price string
  17014. MedListCodg string
  17015. Type int64
  17016. AdviceId int64
  17017. ProjectId int64
  17018. ItemId int64
  17019. }
  17020. type Result5301 struct {
  17021. ErrMsg string `json:"err_msg"`
  17022. InfRefmsgid string `json:"inf_refmsgid"`
  17023. Infcode int64 `json:"infcode"`
  17024. Output struct {
  17025. Result []struct {
  17026. OpspDiseCode string `json:"opsp_dise_code"`
  17027. OpspDiseName string `json:"opsp_dise_name"`
  17028. Begndate string `json:"begndate"`
  17029. Enddate string `json:"enddate"`
  17030. } `json:"feedetail"`
  17031. } `json:"output"`
  17032. RefmsgTime string `json:"refmsg_time"`
  17033. RespondTime string `json:"respond_time"`
  17034. Signtype interface{} `json:"signtype"`
  17035. WarnInfo interface{} `json:"warn_info"`
  17036. }
  17037. type Result5301For10265 struct {
  17038. ErrMsg string `json:"err_msg"`
  17039. InfRefmsgid string `json:"inf_refmsgid"`
  17040. Infcode string `json:"infcode"`
  17041. Output struct {
  17042. Result []struct {
  17043. OpspDiseCode string `json:"opsp_dise_code"`
  17044. OpspDiseName string `json:"opsp_dise_name"`
  17045. Begndate string `json:"begndate"`
  17046. Enddate string `json:"enddate"`
  17047. } `json:"feedetail"`
  17048. } `json:"output"`
  17049. RefmsgTime string `json:"refmsg_time"`
  17050. RespondTime string `json:"respond_time"`
  17051. Signtype interface{} `json:"signtype"`
  17052. WarnInfo interface{} `json:"warn_info"`
  17053. }
  17054. //获取个人信息----挂号-----上传就诊信息
  17055. func (c *HisApiController) GetRegisterInfo() {
  17056. id, _ := c.GetInt64("id")
  17057. record_time := c.GetString("record_time")
  17058. settlementValue, _ := c.GetInt64("settlement_value")
  17059. medical_insurance_card := c.GetString("medical_insurance_card")
  17060. name := c.GetString("name")
  17061. id_card_type, _ := c.GetInt64("id_card_type")
  17062. certificates, _ := c.GetInt64("certificates")
  17063. medical_care, _ := c.GetInt64("medical_care")
  17064. birthday := c.GetString("birthday")
  17065. id_card := c.GetString("id_card")
  17066. register_type, _ := c.GetInt64("register")
  17067. doctor, _ := c.GetInt64("doctor")
  17068. department, _ := c.GetInt64("department")
  17069. gender, _ := c.GetInt64("sex")
  17070. registration_fee, _ := c.GetFloat("registration_fee")
  17071. medical_expenses, _ := c.GetFloat("medical_expenses")
  17072. social_type, _ := c.GetInt64("social_type")
  17073. admin_user_id, _ := c.GetInt64("admin_user_id")
  17074. insuplc_admdvs := c.GetString("insuplc_admdvs")
  17075. mdtrt_type := c.GetString("mdtrt_type")
  17076. if id_card_type == 5 {
  17077. id_card_type = 4
  17078. }
  17079. timeLayout := "2006-01-02"
  17080. loc, _ := time.LoadLocation("Local")
  17081. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  17082. birthUnix := birthdays.Unix()
  17083. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17084. if err != nil {
  17085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17086. return
  17087. }
  17088. recordDateTime := theTime.Unix()
  17089. adminInfo := c.GetAdminUserInfo()
  17090. var patient service.Patients
  17091. if id == 0 {
  17092. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  17093. } else {
  17094. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  17095. }
  17096. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17097. if patientPrescription.ID == 0 {
  17098. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17099. }
  17100. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  17101. if patient.ID == 0 {
  17102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  17103. return
  17104. }
  17105. if len(patient.IdCardNo) == 0 {
  17106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  17107. return
  17108. }
  17109. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  17110. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  17111. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  17112. //就诊结算未完成,不能进行二次挂号
  17113. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  17114. //if len(his) >= 1 {
  17115. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  17116. // if len(his) >= 1 && order.ID == 0 {
  17117. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  17118. // return
  17119. // }
  17120. //}
  17121. //var register_log string
  17122. if config.IsOpen == 1 {
  17123. var res ResultTwo
  17124. var res10265 ResultTwo10265
  17125. var PsnNo string
  17126. var PsnCertType string
  17127. var Certno string
  17128. var PsnName string
  17129. var Gend string
  17130. var Naty string
  17131. var Brdy string
  17132. var Age float64
  17133. var infoStr string
  17134. var idetinfoStr string
  17135. var infocode int64
  17136. var verify_number string
  17137. fmt.Println(verify_number)
  17138. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  17139. psn_info, _ := service.GetPsnByPatientId(id)
  17140. PsnNo = psn_info.PsnNo
  17141. PsnCertType = psn_info.PsnCertType
  17142. Certno = psn_info.Certno
  17143. PsnName = psn_info.PsnName
  17144. Gend = psn_info.Gend
  17145. Naty = psn_info.Naty
  17146. Brdy = psn_info.Brdy
  17147. Age = psn_info.Age
  17148. infoStr = psn_info.Insuinfo
  17149. idetinfoStr = psn_info.Idetinfo
  17150. infocode = 0
  17151. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17152. psn_info, _ := service.GetPsnByPatientId(id)
  17153. PsnNo = psn_info.PsnNo
  17154. PsnCertType = psn_info.PsnCertType
  17155. Certno = psn_info.Certno
  17156. PsnName = psn_info.PsnName
  17157. Gend = psn_info.Gend
  17158. Naty = psn_info.Naty
  17159. Brdy = psn_info.Brdy
  17160. Age = psn_info.Age
  17161. infoStr = psn_info.Insuinfo
  17162. idetinfoStr = psn_info.Idetinfo
  17163. infocode = 0
  17164. verify_number = psn_info.VerifyNumber
  17165. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17166. if id_card_type == 2 {
  17167. //请求内网数据
  17168. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  17169. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17170. "&insuplc_admdvs=" + insuplc_admdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name
  17171. resp, requestErr := http.Get(api)
  17172. if requestErr != nil {
  17173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17174. return
  17175. }
  17176. body, ioErr := ioutil.ReadAll(resp.Body)
  17177. if ioErr != nil {
  17178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17180. return
  17181. }
  17182. var respJSON map[string]interface{}
  17183. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17186. return
  17187. }
  17188. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17189. result_byte, _ := json.Marshal(respJSON)
  17190. result := string(result_byte)
  17191. var dat map[string]interface{}
  17192. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17193. fmt.Println(dat)
  17194. } else {
  17195. fmt.Println(err)
  17196. }
  17197. userJSONBytes, _ := json.Marshal(dat)
  17198. var res ResultTwo
  17199. var resTwo10265 ResultTwo10265
  17200. if miConfig.Code == "H15049901371" {
  17201. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  17202. utils.ErrorLog("解析失败:%v", err)
  17203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17204. return
  17205. }
  17206. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  17207. res.Infcode = Infcode
  17208. res.ErrMsg = resTwo10265.ErrMsg
  17209. res.Output = resTwo10265.Output
  17210. res.InfRefmsgid = resTwo10265.InfRefmsgid
  17211. res.RespondTime = resTwo10265.RespondTime
  17212. res.WarnInfo = resTwo10265.WarnInfo
  17213. } else {
  17214. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17215. utils.ErrorLog("解析失败:%v", err)
  17216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17217. return
  17218. }
  17219. }
  17220. //var insutypes []string
  17221. //var insutype string
  17222. //var is390 int = 0
  17223. //var is310 int = 0
  17224. //for _, item := range res.Output.Iinfo {
  17225. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17226. // insutypes = append(insutypes, item.Insutype)
  17227. // }
  17228. //}
  17229. //if len(insutypes) == 1 {
  17230. // insutype = insutypes[0]
  17231. //} else {
  17232. // for _, i := range insutypes {
  17233. // if i == "390" {
  17234. // is390 = 1
  17235. // }
  17236. //
  17237. // if i == "310" {
  17238. // is310 = 1
  17239. // }
  17240. // }
  17241. //}
  17242. //if is390 == 1 {
  17243. // insutype = "390"
  17244. //}
  17245. //if is310 == 1 {
  17246. // insutype = "310"
  17247. //}
  17248. //if len(insutypes) == 0 {
  17249. // insutype = "310"
  17250. //}
  17251. PsnNo = res.Output.Baseinfo.PsnNo
  17252. PsnCertType = res.Output.Baseinfo.PsnCertType
  17253. Certno = res.Output.Baseinfo.Certno
  17254. PsnName = res.Output.Baseinfo.PsnName
  17255. Gend = res.Output.Baseinfo.Gend
  17256. Naty = res.Output.Baseinfo.Naty
  17257. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17258. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17259. infoStr = string(Iinfos)
  17260. idetinfoStr = string(Idetinfos)
  17261. infocode = res.Infcode
  17262. //infocode = 0
  17263. //verify_number = psn_info.VerifyNumber
  17264. } else {
  17265. psn_info, _ := service.GetPsnByPatientId(id)
  17266. PsnNo = psn_info.PsnNo
  17267. PsnCertType = psn_info.PsnCertType
  17268. Certno = psn_info.Certno
  17269. PsnName = psn_info.PsnName
  17270. Gend = psn_info.Gend
  17271. Naty = psn_info.Naty
  17272. Brdy = psn_info.Brdy
  17273. Age = psn_info.Age
  17274. infoStr = psn_info.Insuinfo
  17275. idetinfoStr = psn_info.Idetinfo
  17276. infocode = 0
  17277. verify_number = psn_info.VerifyNumber
  17278. }
  17279. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17280. if id_card_type == 1 {
  17281. psn_info, _ := service.GetPsnByPatientId(id)
  17282. PsnNo = psn_info.PsnNo
  17283. PsnCertType = psn_info.PsnCertType
  17284. Certno = psn_info.Certno
  17285. PsnName = psn_info.PsnName
  17286. Gend = psn_info.Gend
  17287. Naty = psn_info.Naty
  17288. Brdy = psn_info.Brdy
  17289. Age = psn_info.Age
  17290. infoStr = psn_info.Insuinfo
  17291. idetinfoStr = psn_info.Idetinfo
  17292. infocode = 0
  17293. verify_number = psn_info.VerifyNumber
  17294. } else if id_card_type == 2 {
  17295. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, "", id_card)
  17296. fmt.Println(errMsgLog)
  17297. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17298. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17299. utils.ErrorLog("解析失败:%v", err)
  17300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17301. return
  17302. }
  17303. PsnNo = res.Output.Baseinfo.PsnNo
  17304. PsnCertType = res.Output.Baseinfo.PsnCertType
  17305. Certno = res.Output.Baseinfo.Certno
  17306. PsnName = res.Output.Baseinfo.PsnName
  17307. Gend = res.Output.Baseinfo.Gend
  17308. Naty = res.Output.Baseinfo.Naty
  17309. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17310. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17311. infoStr = string(Iinfos)
  17312. idetinfoStr = string(Idetinfos)
  17313. infocode = res.Infcode
  17314. }
  17315. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17316. if id_card_type == 1 {
  17317. psn_info, _ := service.GetPsnByPatientId(id)
  17318. PsnNo = psn_info.PsnNo
  17319. PsnCertType = psn_info.PsnCertType
  17320. Certno = psn_info.Certno
  17321. PsnName = psn_info.PsnName
  17322. Gend = psn_info.Gend
  17323. Naty = psn_info.Naty
  17324. Brdy = psn_info.Brdy
  17325. Age = psn_info.Age
  17326. infoStr = psn_info.Insuinfo
  17327. idetinfoStr = psn_info.Idetinfo
  17328. infocode = 0
  17329. verify_number = psn_info.VerifyNumber
  17330. } else if id_card_type == 2 {
  17331. result, requestLog := service.Jxyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "")
  17332. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17333. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17334. utils.ErrorLog("解析失败:%v", err)
  17335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17336. return
  17337. }
  17338. PsnNo = res.Output.Baseinfo.PsnNo
  17339. PsnCertType = res.Output.Baseinfo.PsnCertType
  17340. Certno = res.Output.Baseinfo.Certno
  17341. PsnName = res.Output.Baseinfo.PsnName
  17342. Gend = res.Output.Baseinfo.Gend
  17343. Naty = res.Output.Baseinfo.Naty
  17344. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17345. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17346. infoStr = string(Iinfos)
  17347. idetinfoStr = string(Idetinfos)
  17348. infocode = res.Infcode
  17349. } else {
  17350. psn_info, _ := service.GetPsnByPatientId(id)
  17351. PsnNo = psn_info.PsnNo
  17352. PsnCertType = psn_info.PsnCertType
  17353. Certno = psn_info.Certno
  17354. PsnName = psn_info.PsnName
  17355. Gend = psn_info.Gend
  17356. Naty = psn_info.Naty
  17357. Brdy = psn_info.Brdy
  17358. Age = psn_info.Age
  17359. infoStr = psn_info.Insuinfo
  17360. idetinfoStr = psn_info.Idetinfo
  17361. infocode = 0
  17362. verify_number = psn_info.VerifyNumber
  17363. }
  17364. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17365. psn_info, _ := service.GetPsnByPatientId(id)
  17366. PsnNo = psn_info.PsnNo
  17367. PsnCertType = psn_info.PsnCertType
  17368. Certno = psn_info.Certno
  17369. PsnName = psn_info.PsnName
  17370. Gend = psn_info.Gend
  17371. Naty = psn_info.Naty
  17372. Brdy = psn_info.Brdy
  17373. Age = psn_info.Age
  17374. infoStr = psn_info.Insuinfo
  17375. idetinfoStr = psn_info.Idetinfo
  17376. infocode = 0
  17377. verify_number = psn_info.VerifyNumber
  17378. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17379. if id_card_type == 1 {
  17380. psn_info, _ := service.GetPsnByPatientId(id)
  17381. PsnNo = psn_info.PsnNo
  17382. PsnCertType = psn_info.PsnCertType
  17383. Certno = psn_info.Certno
  17384. PsnName = psn_info.PsnName
  17385. Gend = psn_info.Gend
  17386. Naty = psn_info.Naty
  17387. Brdy = psn_info.Brdy
  17388. Age = psn_info.Age
  17389. infoStr = psn_info.Insuinfo
  17390. idetinfoStr = psn_info.Idetinfo
  17391. infocode = 0
  17392. verify_number = psn_info.VerifyNumber
  17393. } else if id_card_type == 2 {
  17394. result, requestLog := service.Hnyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", "", Certno)
  17395. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17396. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17397. utils.ErrorLog("解析失败:%v", err)
  17398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17399. return
  17400. }
  17401. PsnNo = res.Output.Baseinfo.PsnNo
  17402. PsnCertType = res.Output.Baseinfo.PsnCertType
  17403. Certno = res.Output.Baseinfo.Certno
  17404. PsnName = res.Output.Baseinfo.PsnName
  17405. Gend = res.Output.Baseinfo.Gend
  17406. Naty = res.Output.Baseinfo.Naty
  17407. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17408. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17409. infoStr = string(Iinfos)
  17410. idetinfoStr = string(Idetinfos)
  17411. infocode = res.Infcode
  17412. } else if id_card_type == 4 {
  17413. psn_info, _ := service.GetPsnByPatientId(id)
  17414. PsnNo = psn_info.PsnNo
  17415. PsnCertType = psn_info.PsnCertType
  17416. Certno = psn_info.Certno
  17417. PsnName = psn_info.PsnName
  17418. Gend = psn_info.Gend
  17419. Naty = psn_info.Naty
  17420. Brdy = psn_info.Brdy
  17421. Age = psn_info.Age
  17422. infoStr = psn_info.Insuinfo
  17423. idetinfoStr = psn_info.Idetinfo
  17424. infocode = 0
  17425. verify_number = psn_info.VerifyNumber
  17426. }
  17427. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17428. var result string
  17429. var requestLog string
  17430. result, requestLog = service.HeBeiyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), "")
  17431. if id_card_type == 4 {
  17432. psn_info, _ := service.GetPsnByPatientId(id)
  17433. PsnNo = psn_info.PsnNo
  17434. PsnCertType = psn_info.PsnCertType
  17435. Certno = psn_info.Certno
  17436. PsnName = psn_info.PsnName
  17437. Gend = psn_info.Gend
  17438. Naty = psn_info.Naty
  17439. Brdy = psn_info.Brdy
  17440. Age = psn_info.Age
  17441. infoStr = psn_info.Insuinfo
  17442. idetinfoStr = psn_info.Idetinfo
  17443. infocode = 0
  17444. verify_number = psn_info.VerifyNumber
  17445. } else {
  17446. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17447. if miConfig.Code == "H15049901371" {
  17448. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17449. utils.ErrorLog("解析失败:%v", err)
  17450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17451. return
  17452. }
  17453. res.ErrMsg = res10265.ErrMsg
  17454. res.Output = res10265.Output
  17455. res.InfRefmsgid = res10265.InfRefmsgid
  17456. } else {
  17457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17458. utils.ErrorLog("解析失败:%v", err)
  17459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17460. return
  17461. }
  17462. }
  17463. PsnNo = res.Output.Baseinfo.PsnNo
  17464. PsnCertType = res.Output.Baseinfo.PsnCertType
  17465. Certno = res.Output.Baseinfo.Certno
  17466. PsnName = res.Output.Baseinfo.PsnName
  17467. Gend = res.Output.Baseinfo.Gend
  17468. Naty = res.Output.Baseinfo.Naty
  17469. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17470. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17471. infoStr = string(Iinfos)
  17472. idetinfoStr = string(Idetinfos)
  17473. if miConfig.Code == "H15049901371" {
  17474. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17475. } else {
  17476. infocode = res.Infcode
  17477. }
  17478. }
  17479. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17480. psn_info, _ := service.GetPsnByPatientId(id)
  17481. PsnNo = psn_info.PsnNo
  17482. PsnCertType = psn_info.PsnCertType
  17483. Certno = psn_info.Certno
  17484. PsnName = psn_info.PsnName
  17485. Gend = psn_info.Gend
  17486. Naty = psn_info.Naty
  17487. Brdy = psn_info.Brdy
  17488. Age = psn_info.Age
  17489. infoStr = psn_info.Insuinfo
  17490. idetinfoStr = psn_info.Idetinfo
  17491. infocode = 0
  17492. verify_number = psn_info.VerifyNumber
  17493. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17494. psn_info, _ := service.GetPsnByPatientId(id)
  17495. PsnNo = psn_info.PsnNo
  17496. PsnCertType = psn_info.PsnCertType
  17497. Certno = psn_info.Certno
  17498. PsnName = psn_info.PsnName
  17499. Gend = psn_info.Gend
  17500. Naty = psn_info.Naty
  17501. Brdy = psn_info.Brdy
  17502. Age = psn_info.Age
  17503. infoStr = psn_info.Insuinfo
  17504. idetinfoStr = psn_info.Idetinfo
  17505. infocode = 0
  17506. verify_number = psn_info.VerifyNumber
  17507. } else {
  17508. var result string
  17509. var requestLog string
  17510. //if miConfig.UserOrgId == 10138 {
  17511. if id_card_type != 4 || id_card_type != 1 {
  17512. var insa string
  17513. if len(patient.InsuplcAdmdvs) > 0 {
  17514. insa = patient.InsuplcAdmdvs
  17515. } else {
  17516. insa = miConfig.InsuplcAdmdvs
  17517. }
  17518. //psn_info, _ := service.GetPsnByPatientId(id)
  17519. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  17520. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time, admin_user_id)
  17521. }
  17522. //}
  17523. //else {
  17524. // var insa string
  17525. // if len(patient.InsuplcAdmdvs) > 0 {
  17526. // insa = patient.InsuplcAdmdvs
  17527. // } else {
  17528. // insa = miConfig.InsuplcAdmdvs
  17529. // }
  17530. // result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  17531. //}
  17532. if id_card_type == 4 || id_card_type == 1 {
  17533. psn_info, _ := service.GetPsnByPatientId(id)
  17534. PsnNo = psn_info.PsnNo
  17535. PsnCertType = psn_info.PsnCertType
  17536. Certno = psn_info.Certno
  17537. PsnName = psn_info.PsnName
  17538. Gend = psn_info.Gend
  17539. Naty = psn_info.Naty
  17540. Brdy = psn_info.Brdy
  17541. Age = psn_info.Age
  17542. infoStr = psn_info.Insuinfo
  17543. idetinfoStr = psn_info.Idetinfo
  17544. infocode = 0
  17545. verify_number = psn_info.VerifyNumber
  17546. } else {
  17547. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17548. if miConfig.Code == "H15049901371" {
  17549. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17550. utils.ErrorLog("解析失败:%v", err)
  17551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17552. return
  17553. }
  17554. res.ErrMsg = res10265.ErrMsg
  17555. res.Output = res10265.Output
  17556. res.InfRefmsgid = res10265.InfRefmsgid
  17557. } else {
  17558. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17559. utils.ErrorLog("解析失败:%v", err)
  17560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17561. return
  17562. }
  17563. }
  17564. PsnNo = res.Output.Baseinfo.PsnNo
  17565. PsnCertType = res.Output.Baseinfo.PsnCertType
  17566. Certno = res.Output.Baseinfo.Certno
  17567. PsnName = res.Output.Baseinfo.PsnName
  17568. Gend = res.Output.Baseinfo.Gend
  17569. Naty = res.Output.Baseinfo.Naty
  17570. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17571. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17572. infoStr = string(Iinfos)
  17573. idetinfoStr = string(Idetinfos)
  17574. if miConfig.Code == "H15049901371" {
  17575. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17576. } else {
  17577. infocode = res.Infcode
  17578. }
  17579. }
  17580. }
  17581. if infocode == 0 {
  17582. his := models.VMHisPatient{
  17583. Name: name,
  17584. Gender: gender,
  17585. Birthday: birthUnix,
  17586. MedicalTreatmentType: medical_care,
  17587. IdType: certificates,
  17588. IdCardNo: id_card,
  17589. BalanceAccountsType: settlementValue,
  17590. SocialType: social_type,
  17591. MedicalInsuranceNumber: medical_insurance_card,
  17592. RegisterType: register_type,
  17593. RegisterCost: registration_fee,
  17594. TreatmentCost: medical_expenses,
  17595. Status: 1,
  17596. Ctime: time.Now().Unix(),
  17597. Mtime: time.Now().Unix(),
  17598. PsnNo: PsnNo,
  17599. PsnCertType: PsnCertType,
  17600. Certno: Certno,
  17601. PsnName: PsnName,
  17602. Gend: Gend,
  17603. Naty: Naty,
  17604. Brdy: Brdy,
  17605. Age: Age,
  17606. Iinfo: infoStr,
  17607. Idetinfo: idetinfoStr,
  17608. PatientId: patient.ID,
  17609. RecordDate: theTime.Unix(),
  17610. UserOrgId: adminInfo.CurrentOrgId,
  17611. AdminUserId: admin_user_id,
  17612. IsReturn: 1,
  17613. IdCardType: id_card_type,
  17614. Doctor: doctor,
  17615. Departments: department,
  17616. MdtrtGrpType: mdtrt_type,
  17617. }
  17618. timestamp := time.Now().Unix()
  17619. tempTime := time.Unix(timestamp, 0)
  17620. timeFormat := tempTime.Format("20060102150405")
  17621. chrgBchno := rand.Intn(100000) + 10000
  17622. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17623. his.Number = ipt_otp_no
  17624. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  17625. department, _ := service.GetDepartMentDetail(department)
  17626. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  17627. IdCardNo := ""
  17628. if id_card_type == 1 {
  17629. // IdCardNo = medical_insurance_card
  17630. IdCardNo = patient.IdCardNo
  17631. } else {
  17632. IdCardNo = patient.IdCardNo
  17633. }
  17634. var rf []*ResultFive
  17635. json.Unmarshal([]byte(his.Iinfo), &rf)
  17636. var insutypes []*ResultFive
  17637. var insutype string
  17638. var insuplc_admdvs_temp string
  17639. var is390 int = 0
  17640. var is310 int = 0
  17641. for _, item := range rf {
  17642. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17643. insutypes = append(insutypes, item)
  17644. }
  17645. }
  17646. if len(insutypes) == 1 {
  17647. insutype = insutypes[0].Insutype
  17648. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17649. if insutype == "390" {
  17650. is390 = 1
  17651. }
  17652. if insutype == "310" {
  17653. is310 = 1
  17654. }
  17655. } else {
  17656. for _, i := range insutypes {
  17657. if i.Insutype == "390" {
  17658. is390 = 1
  17659. }
  17660. if i.Insutype == "310" {
  17661. is310 = 1
  17662. }
  17663. }
  17664. }
  17665. if is390 == 1 {
  17666. insutype = "390"
  17667. }
  17668. if is310 == 1 {
  17669. insutype = "310"
  17670. }
  17671. fmt.Println(social_type)
  17672. if social_type > 0 {
  17673. insutype = strconv.FormatInt(social_type, 10)
  17674. }
  17675. var infocode int64
  17676. var resThree ResultThree
  17677. var resThree10265 ResultThree10265
  17678. if len(insuplc_admdvs) == 0 {
  17679. psn_info, _ := service.GetPsnByPatientId(id)
  17680. //if len(psn_info.InsuplcAdmdvs) > 0 {
  17681. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17682. //}
  17683. } else {
  17684. insuplc_admdvs_temp = insuplc_admdvs
  17685. }
  17686. if miConfig.MdtrtareaAdmvs == "421300" {
  17687. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17688. psn_info, _ := service.GetPsnByPatientId(id)
  17689. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17690. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17691. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  17692. resp, requestErr := http.Get(api)
  17693. if requestErr != nil {
  17694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17695. return
  17696. }
  17697. body, ioErr := ioutil.ReadAll(resp.Body)
  17698. if ioErr != nil {
  17699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17701. return
  17702. }
  17703. var respJSON map[string]interface{}
  17704. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17707. return
  17708. }
  17709. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17710. result, _ := json.Marshal(respJSON)
  17711. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17712. utils.ErrorLog("解析失败:%v", err)
  17713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17714. return
  17715. }
  17716. infocode = resThree.Infcode
  17717. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17718. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17719. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17720. // insuplc_admdvs_temp =
  17721. //}
  17722. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17723. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17724. //}
  17725. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17726. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17727. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  17728. resp, requestErr := http.Get(api)
  17729. if requestErr != nil {
  17730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17731. return
  17732. }
  17733. body, ioErr := ioutil.ReadAll(resp.Body)
  17734. if ioErr != nil {
  17735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17737. return
  17738. }
  17739. var respJSON map[string]interface{}
  17740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17743. return
  17744. }
  17745. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17746. result, _ := json.Marshal(respJSON)
  17747. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17748. utils.ErrorLog("解析失败:%v", err)
  17749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17750. return
  17751. }
  17752. infocode = resThree.Infcode
  17753. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17754. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17755. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17756. // insuplc_admdvs_temp =
  17757. //}
  17758. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17759. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17760. //}
  17761. utils.ErrorLog("解析失败:%v", insutype)
  17762. utils.ErrorLog("解析失败:%v", PsnNo)
  17763. utils.ErrorLog("解析失败:%v", Certno)
  17764. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  17765. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  17766. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  17767. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  17768. utils.ErrorLog("解析失败:%v", PsnNo)
  17769. utils.ErrorLog("解析失败:%v", department.Number)
  17770. utils.ErrorLog("解析失败:%v", department.Name)
  17771. utils.ErrorLog("解析失败:%v", roles.UserName)
  17772. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17773. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17774. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  17775. resp, requestErr := http.Get(api)
  17776. if requestErr != nil {
  17777. utils.ErrorLog("解析失败:%v", requestErr)
  17778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17779. return
  17780. }
  17781. body, ioErr := ioutil.ReadAll(resp.Body)
  17782. if ioErr != nil {
  17783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17785. return
  17786. }
  17787. var respJSON map[string]interface{}
  17788. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17791. return
  17792. }
  17793. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17794. result, _ := json.Marshal(respJSON)
  17795. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17796. utils.ErrorLog("解析失败:%v", err)
  17797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17798. return
  17799. }
  17800. infocode = resThree.Infcode
  17801. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17802. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17803. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17804. // insuplc_admdvs_temp =
  17805. //}
  17806. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17807. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17808. //}
  17809. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17810. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17811. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  17812. resp, requestErr := http.Get(api)
  17813. if requestErr != nil {
  17814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17815. return
  17816. }
  17817. body, ioErr := ioutil.ReadAll(resp.Body)
  17818. if ioErr != nil {
  17819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17821. return
  17822. }
  17823. var respJSON map[string]interface{}
  17824. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17827. return
  17828. }
  17829. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17830. result, _ := json.Marshal(respJSON)
  17831. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17832. utils.ErrorLog("解析失败:%v", err)
  17833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17834. return
  17835. }
  17836. infocode = resThree.Infcode
  17837. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17838. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17839. psn_info, _ := service.GetPsnByPatientId(id)
  17840. var verify_number string
  17841. if id_card_type == 4 {
  17842. verify_number = psn_info.VerifyNumber
  17843. } else if id_card_type == 1 {
  17844. bas := strings.Split(psn_info.CardInfo, "|")
  17845. cardNumber := bas[2]
  17846. verify_number = cardNumber
  17847. }
  17848. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17849. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17850. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName + "&verify_number=" + verify_number
  17851. resp, requestErr := http.Get(api)
  17852. if requestErr != nil {
  17853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17854. return
  17855. }
  17856. body, ioErr := ioutil.ReadAll(resp.Body)
  17857. if ioErr != nil {
  17858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17860. return
  17861. }
  17862. var respJSON map[string]interface{}
  17863. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17866. return
  17867. }
  17868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17869. result, _ := json.Marshal(respJSON)
  17870. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17871. // utils.ErrorLog("解析失败:%v", err)
  17872. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17873. // return
  17874. //}
  17875. //infocode = resThree.Infcode
  17876. //result, _ := json.Marshal(respJSON)
  17877. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17878. utils.ErrorLog("解析失败:%v", err)
  17879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17880. return
  17881. }
  17882. resThree.ErrMsg = resThree10265.ErrMsg
  17883. resThree.Output = resThree10265.Output
  17884. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17885. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17886. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17887. psn_info, _ := service.GetPsnByPatientId(id)
  17888. his.PsnNo = psn_info.PsnNo
  17889. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17890. var cert_no string
  17891. if id_card_type == 3 {
  17892. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  17893. cert_no = IdCardNo
  17894. } else if id_card_type == 4 {
  17895. cert_no = IdCardNo
  17896. psn_info.VerifyNumber = psn_info.VerifyNumber
  17897. } else {
  17898. bas := strings.Split(psn_info.CardInfo, "|")
  17899. cert_no = bas[2]
  17900. }
  17901. var hisPrescription []*models.HisPrescription
  17902. for _, item := range rf {
  17903. if item.Insutype == insutype {
  17904. //insuplc_admdvs = item.InsuplcAdmdvs
  17905. his.InsuplcAdmdvs = insuplc_admdvs
  17906. }
  17907. }
  17908. his.Insutype = insutype
  17909. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17910. fmt.Println(res3101)
  17911. fmt.Println(res3101.Infcode)
  17912. if res3101.Infcode == "0" {
  17913. fmt.Println("33333333")
  17914. if len(res3101.Output.Result) > 0 {
  17915. fmt.Println("222222")
  17916. for _, item := range res3101.Output.Result {
  17917. if len(res3101.ErrMsg) == 0 {
  17918. res3101.ErrMsg = item.VolaCont
  17919. } else {
  17920. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17921. }
  17922. }
  17923. c.ServeSuccessJSON(map[string]interface{}{
  17924. "failed_code": -10,
  17925. "msg": res3101.ErrMsg,
  17926. })
  17927. return
  17928. } else {
  17929. fmt.Println("11111")
  17930. var api string
  17931. if miConfig.MdtrtareaAdmvs == "320921" {
  17932. ipt_otp_no = timeFormat
  17933. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17934. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17935. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  17936. } else {
  17937. ipt_otp_no = timeFormat
  17938. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17939. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17940. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  17941. }
  17942. resp, requestErr := http.Get(api)
  17943. if requestErr != nil {
  17944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17945. return
  17946. }
  17947. body, ioErr := ioutil.ReadAll(resp.Body)
  17948. if ioErr != nil {
  17949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17951. return
  17952. }
  17953. var respJSON map[string]interface{}
  17954. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17957. return
  17958. }
  17959. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17960. result, _ := json.Marshal(respJSON)
  17961. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17962. utils.ErrorLog("解析失败:%v", err)
  17963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17964. return
  17965. }
  17966. resThree.ErrMsg = resThree10265.ErrMsg
  17967. resThree.Output = resThree10265.Output
  17968. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17969. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17970. }
  17971. } else if res3101.Infcode != "0" {
  17972. c.ServeSuccessJSON(map[string]interface{}{
  17973. "failed_code": -10,
  17974. "msg": res3101.ErrMsg,
  17975. })
  17976. return
  17977. }
  17978. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17979. psn_info, _ := service.GetPsnByPatientId(id)
  17980. var cert_no string
  17981. if id_card_type == 1 {
  17982. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  17983. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17984. } else if id_card_type == 4 {
  17985. cert_no = psn_info.VerifyNumber
  17986. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17987. } else {
  17988. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17989. cert_no = psn_info.VerifyNumber
  17990. }
  17991. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no, record_time)
  17992. saveLog(result, requestLog, "2201", "挂号")
  17993. if miConfig.Code == "H15049901371" {
  17994. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17995. utils.ErrorLog("解析失败:%v", err)
  17996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17997. return
  17998. }
  17999. resThree.ErrMsg = resThree10265.ErrMsg
  18000. resThree.Output = resThree10265.Output
  18001. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18002. } else {
  18003. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18004. utils.ErrorLog("解析失败:%v", err)
  18005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18006. return
  18007. }
  18008. }
  18009. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18010. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  18011. psn_info, _ := service.GetPsnByPatientId(id)
  18012. var result string
  18013. var requestLog string
  18014. if id_card_type == 1 {
  18015. bas := strings.Split(psn_info.CardInfo, "|")
  18016. basNumber := bas[2]
  18017. card_sn := bas[3]
  18018. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, "01", IdCardNo, "15", psn_info.PsnName)
  18019. saveLog(result, requestLog, "2201A", "挂号")
  18020. } else if id_card_type == 2 {
  18021. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "", "", "", "", "")
  18022. saveLog(result, requestLog, "2201A", "挂号")
  18023. } else {
  18024. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "", "01", IdCardNo, "15", psn_info.PsnName)
  18025. saveLog(result, requestLog, "2201A", "挂号")
  18026. }
  18027. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18028. utils.ErrorLog("解析失败:%v", err)
  18029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18030. return
  18031. }
  18032. infocode = resThree.Infcode
  18033. } else if miConfig.MdtrtareaAdmvs == "341203" {
  18034. psn_info, _ := service.GetPsnByPatientId(id)
  18035. his.PsnNo = psn_info.PsnNo
  18036. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18037. var cert_no string
  18038. if id_card_type == 1 {
  18039. bas := strings.Split(psn_info.CardInfo, "|")
  18040. cert_no = bas[2]
  18041. } else if id_card_type == 4 {
  18042. cert_no = IdCardNo
  18043. psn_info.VerifyNumber = psn_info.VerifyNumber
  18044. } else {
  18045. cert_no = IdCardNo
  18046. psn_info.VerifyNumber = cert_no
  18047. }
  18048. for _, item := range rf {
  18049. if item.Insutype == insutype {
  18050. his.InsuplcAdmdvs = insuplc_admdvs
  18051. }
  18052. }
  18053. his.Insutype = insutype
  18054. var api string
  18055. ipt_otp_no = timeFormat
  18056. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18057. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18058. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  18059. resp, requestErr := http.Get(api)
  18060. if requestErr != nil {
  18061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18062. return
  18063. }
  18064. body, ioErr := ioutil.ReadAll(resp.Body)
  18065. if ioErr != nil {
  18066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18068. return
  18069. }
  18070. var respJSON map[string]interface{}
  18071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18074. return
  18075. }
  18076. status := respJSON["data"].(map[string]interface{})["status"].(string)
  18077. if status == "0" {
  18078. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  18079. c.ServeSuccessJSON(map[string]interface{}{
  18080. "failed_code": -10,
  18081. "msg": err_msg,
  18082. })
  18083. return
  18084. }
  18085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18086. result, _ := json.Marshal(respJSON)
  18087. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18088. utils.ErrorLog("解析失败:%v", err)
  18089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18090. return
  18091. }
  18092. infocode = resThree.Infcode
  18093. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18094. psn_info, _ := service.GetPsnByPatientId(id)
  18095. var result string
  18096. var requestLog string
  18097. if id_card_type == 1 {
  18098. bas := strings.Split(psn_info.CardInfo, "|")
  18099. basNumber := bas[2]
  18100. card_sn := bas[3]
  18101. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  18102. saveLog(result, requestLog, "2201A", "挂号")
  18103. } else if id_card_type == 2 {
  18104. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, psn_info.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "")
  18105. saveLog(result, requestLog, "2201A", "挂号")
  18106. } else {
  18107. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "")
  18108. saveLog(result, requestLog, "2201A", "挂号")
  18109. }
  18110. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18111. utils.ErrorLog("解析失败:%v", err)
  18112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18113. return
  18114. }
  18115. infocode = resThree.Infcode
  18116. } else if miConfig.MdtrtareaAdmvs == "131023" {
  18117. psn_info, _ := service.GetPsnByPatientId(id)
  18118. result, requestLog := service.HeBeiyb2201A(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  18119. saveLog(result, requestLog, "2201A", "挂号")
  18120. if miConfig.Code == "H15049901371" {
  18121. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18122. utils.ErrorLog("解析失败:%v", err)
  18123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18124. return
  18125. }
  18126. resThree.ErrMsg = resThree10265.ErrMsg
  18127. resThree.Output = resThree10265.Output
  18128. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18129. } else {
  18130. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18131. utils.ErrorLog("解析失败:%v", err)
  18132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18133. return
  18134. }
  18135. }
  18136. if miConfig.Code == "H15049901371" {
  18137. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18138. } else {
  18139. infocode = resThree.Infcode
  18140. }
  18141. } else {
  18142. psn_info, _ := service.GetPsnByPatientId(id)
  18143. if id_card_type == 4 || id_card_type == 1 {
  18144. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18145. }
  18146. var rf []*ResultFive
  18147. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  18148. var insutypes []*ResultFive
  18149. var insutype string
  18150. var is390 int = 0
  18151. var is310 int = 0
  18152. for _, item := range rf {
  18153. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18154. insutypes = append(insutypes, item)
  18155. }
  18156. }
  18157. if len(insutypes) == 1 {
  18158. insutype = insutypes[0].Insutype
  18159. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18160. } else {
  18161. for _, i := range insutypes {
  18162. if i.Insutype == "390" {
  18163. is390 = 1
  18164. }
  18165. if i.Insutype == "310" {
  18166. is310 = 1
  18167. }
  18168. }
  18169. }
  18170. if is390 == 1 {
  18171. insutype = "390"
  18172. }
  18173. if is310 == 1 {
  18174. insutype = "310"
  18175. }
  18176. fmt.Println(len(insutypes))
  18177. if len(insutypes) == 0 {
  18178. for index, item := range rf {
  18179. if index == 0 {
  18180. insutype = item.Insutype
  18181. insuplc_admdvs = item.InsuplcAdmdvs
  18182. }
  18183. }
  18184. fmt.Println(insutype)
  18185. fmt.Println(insuplc_admdvs)
  18186. }
  18187. if social_type > 0 {
  18188. insutype = strconv.FormatInt(social_type, 10)
  18189. }
  18190. fmt.Println("--------")
  18191. fmt.Println(psn_info)
  18192. fmt.Println(psn_info.PsnNo)
  18193. if miConfig.MdtrtareaAdmvs == "441202" {
  18194. var hisPrescription []*models.HisPrescription
  18195. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  18196. if res3101.Infcode == 0 {
  18197. fmt.Println("33333333")
  18198. if len(res3101.Output.Result) > 0 {
  18199. fmt.Println("222222")
  18200. for _, item := range res3101.Output.Result {
  18201. if len(res3101.ErrMsg) == 0 {
  18202. res3101.ErrMsg = item.VolaCont
  18203. } else {
  18204. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  18205. }
  18206. }
  18207. c.ServeSuccessJSON(map[string]interface{}{
  18208. "failed_code": -10,
  18209. "msg": res3101.ErrMsg,
  18210. })
  18211. return
  18212. } else {
  18213. hour := time.Now().Format("15")
  18214. min := time.Now().Format("04")
  18215. sec := time.Now().Format("05")
  18216. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18217. fmt.Println(record_time_two)
  18218. result, requestLog := service.Gdyb2201A(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time_two, psn_info.VerifyNumber, admin_user_id)
  18219. saveLog(result, requestLog, "2201A", "挂号")
  18220. if miConfig.Code == "H15049901371" {
  18221. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18222. utils.ErrorLog("解析失败:%v", err)
  18223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18224. return
  18225. }
  18226. resThree.ErrMsg = resThree10265.ErrMsg
  18227. resThree.Output = resThree10265.Output
  18228. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18229. } else {
  18230. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18231. utils.ErrorLog("解析失败:%v", err)
  18232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18233. return
  18234. }
  18235. }
  18236. if miConfig.Code == "H15049901371" {
  18237. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18238. } else {
  18239. infocode = resThree.Infcode
  18240. }
  18241. }
  18242. } else if res3101.Infcode != 0 {
  18243. c.ServeSuccessJSON(map[string]interface{}{
  18244. "failed_code": -10,
  18245. "msg": res3101.ErrMsg,
  18246. })
  18247. return
  18248. }
  18249. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18250. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18251. psn_info, _ := service.GetPsnByPatientId(id)
  18252. var verify_number string
  18253. if id_card_type == 4 {
  18254. verify_number = psn_info.VerifyNumber
  18255. } else if id_card_type == 1 {
  18256. bas := strings.Split(psn_info.CardInfo, "|")
  18257. cardNumber := bas[2]
  18258. verify_number = cardNumber
  18259. } else {
  18260. verify_number = psn_info.Certno
  18261. }
  18262. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18263. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18264. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&doctor_name=" + doctor_info.UserName + "&verify_number=" + verify_number + "&record_time=" + record_time
  18265. resp, requestErr := http.Get(api)
  18266. if requestErr != nil {
  18267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18268. return
  18269. }
  18270. body, ioErr := ioutil.ReadAll(resp.Body)
  18271. if ioErr != nil {
  18272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18274. return
  18275. }
  18276. var respJSON map[string]interface{}
  18277. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18280. return
  18281. }
  18282. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18283. result, _ := json.Marshal(respJSON)
  18284. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18285. utils.ErrorLog("解析失败:%v", err)
  18286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18287. return
  18288. }
  18289. infocode = resThree.Infcode
  18290. } else {
  18291. hour := time.Now().Format("15")
  18292. min := time.Now().Format("04")
  18293. sec := time.Now().Format("05")
  18294. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18295. if id_card_type == 1 {
  18296. for _, item := range rf {
  18297. if item.Insutype == strconv.FormatInt(social_type, 10) {
  18298. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  18299. insuplc_admdvs_temp = item.InsuplcAdmdvs
  18300. } else if strconv.FormatInt(social_type, 10) == "390" {
  18301. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18302. } else {
  18303. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18304. }
  18305. }
  18306. }
  18307. }
  18308. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  18309. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18310. }
  18311. if id_card_type == 1 {
  18312. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  18313. bas := strings.Split(psn_info.CardInfo, "|")
  18314. basNumber := bas[1]
  18315. IdCardNo = basNumber
  18316. }
  18317. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  18318. IdCardNo = psn_info.VerifyNumber
  18319. }
  18320. result, requestLog := service.Gdyb2201A(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time_two, psn_info.VerifyNumber, admin_user_id)
  18321. saveLog(result, requestLog, "2201A", "挂号")
  18322. if miConfig.Code == "H15049901371" {
  18323. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18324. utils.ErrorLog("解析失败:%v", err)
  18325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18326. return
  18327. }
  18328. resThree.ErrMsg = resThree10265.ErrMsg
  18329. resThree.Output = resThree10265.Output
  18330. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18331. } else {
  18332. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18333. utils.ErrorLog("解析失败:%v", err)
  18334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18335. return
  18336. }
  18337. }
  18338. if miConfig.Code == "H15049901371" {
  18339. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18340. } else {
  18341. infocode = resThree.Infcode
  18342. }
  18343. }
  18344. }
  18345. if infocode != 0 {
  18346. adminUser := c.GetAdminUserInfo()
  18347. errlog := &models.HisOrderError{
  18348. UserOrgId: adminUser.CurrentOrgId,
  18349. Ctime: time.Now().Unix(),
  18350. Mtime: time.Now().Unix(),
  18351. ErrMsg: resThree.ErrMsg,
  18352. Status: 1,
  18353. PatientId: id,
  18354. RecordTime: recordDateTime,
  18355. Stage: 2,
  18356. }
  18357. service.CreateErrMsgLog(errlog)
  18358. c.ServeSuccessJSON(map[string]interface{}{
  18359. "failed_code": -10,
  18360. "msg": resThree.ErrMsg,
  18361. })
  18362. return
  18363. }
  18364. his.Number = resThree.Output.Data.MdtrtID
  18365. his.PsnNo = resThree.Output.Data.PsnNo
  18366. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  18367. his.IdCardNo = patient.IdCardNo
  18368. his.PhoneNumber = patient.Phone
  18369. his.UserOrgId = adminInfo.CurrentOrgId
  18370. his.Insutype = insutype
  18371. his.Ctime = time.Now().Unix()
  18372. his.Mtime = time.Now().Unix()
  18373. his.InsuplcAdmdvs = insuplc_admdvs_temp
  18374. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  18375. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18376. }
  18377. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  18378. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18379. }
  18380. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  18381. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18382. }
  18383. his.Status = 1
  18384. his.MdtrtGrpType = mdtrt_type
  18385. service.UpdateHisPatientStatus(&his)
  18386. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  18387. c.ServeSuccessJSON(map[string]interface{}{
  18388. "his_info": his,
  18389. })
  18390. } else {
  18391. adminUser := c.GetAdminUserInfo()
  18392. errlog := &models.HisOrderError{
  18393. UserOrgId: adminUser.CurrentOrgId,
  18394. Ctime: time.Now().Unix(),
  18395. Mtime: time.Now().Unix(),
  18396. ErrMsg: res.ErrMsg,
  18397. Status: 1,
  18398. PatientId: id,
  18399. RecordTime: recordDateTime,
  18400. Stage: 1,
  18401. }
  18402. service.CreateErrMsgLog(errlog)
  18403. c.ServeSuccessJSON(map[string]interface{}{
  18404. "failed_code": -10,
  18405. "msg": res.ErrMsg,
  18406. })
  18407. return
  18408. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  18409. }
  18410. }
  18411. }
  18412. func (c *HisApiController) GetUploadInfo() {
  18413. id, _ := c.GetInt64("id")
  18414. record_time := c.GetString("record_time")
  18415. his_patient_id, _ := c.GetInt64("his_patient_id")
  18416. order_id, _ := c.GetInt64("order_id")
  18417. pay_way, _ := c.GetInt64("pay_way")
  18418. pay_ways := c.GetString("pay_ways")
  18419. oth_desc := c.GetString("oth_desc")
  18420. pay_price, _ := c.GetFloat("pay_price")
  18421. pay_card_no := c.GetString("pay_card_no")
  18422. discount_price, _ := c.GetFloat("discount_price")
  18423. preferential_price, _ := c.GetFloat("preferential_price")
  18424. reality_price, _ := c.GetFloat("reality_price")
  18425. found_price, _ := c.GetFloat("found_price")
  18426. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  18427. private_price, _ := c.GetFloat("private_price")
  18428. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  18429. admin_user_id, _ := c.GetInt64("admin_user_id")
  18430. fapiao_code := c.GetString("fapiao_code")
  18431. fapiao_number := c.GetString("fapiao_number")
  18432. diagnosis_id := c.GetString("diagnosis")
  18433. sick_type, _ := c.GetInt64("sick_type")
  18434. reg_type, _ := c.GetInt64("p_type")
  18435. begin_time := c.GetString("begin_time")
  18436. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  18437. cash_pay := c.GetString("cash_pay")
  18438. band_card_pay := c.GetString("band_card_pay")
  18439. wechat_pay := c.GetString("wechat_pay")
  18440. ali_pay := c.GetString("ali_pay")
  18441. jifen_pay := c.GetString("jifen_pay")
  18442. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  18443. fmt.Println(acct_used_flag)
  18444. id_str := c.GetString("ids")
  18445. ids_arr := strings.Split(id_str, ",")
  18446. timeLayout := "2006-01-02"
  18447. loc, _ := time.LoadLocation("Local")
  18448. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  18449. if err != nil {
  18450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18451. return
  18452. }
  18453. recordDateTime := theTime.Unix()
  18454. adminUser := c.GetAdminUserInfo()
  18455. var tempOrder models.HisOrder
  18456. tempOrder, _ = service.GetHisOrderByID(order_id)
  18457. var prescriptions []*models.HisPrescription
  18458. var start_time int64
  18459. var end_time int64
  18460. //押金模块
  18461. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  18462. tmp_decimal := c.GetString("tmp_decimal")
  18463. var decimal float64 //本次使用的押金
  18464. var errmsg error
  18465. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  18466. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  18467. return
  18468. }
  18469. if len(tmp_decimal) > 0 {
  18470. if tmp_decimal[0] == 45 {
  18471. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  18472. return
  18473. }
  18474. }
  18475. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  18476. fmt.Println(errs)
  18477. decimal = tt
  18478. //if adminUser.CurrentOrgId == 10106{
  18479. // if len(fapiao_code) == 0{
  18480. // fapiao_code = "144072080589"
  18481. // }
  18482. // if len(fapiao_number) == 0{
  18483. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  18484. // if order.ID == 0{
  18485. // fapiao_number = "00001520"
  18486. // }else{
  18487. // //fapiao_code = "00001520"
  18488. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  18489. // var zero string
  18490. // if fpNumber >= 1000{
  18491. // zero = "0000" + strconv.Itoa(fpNumber)
  18492. // }else if fpNumber >= 10000{
  18493. // zero = "000" + strconv.Itoa(fpNumber)
  18494. // } else if fpNumber >= 100000{
  18495. // zero = "00" + strconv.Itoa(fpNumber)
  18496. // } else if fpNumber >= 1000000{
  18497. // zero = "0" + strconv.Itoa(fpNumber)
  18498. // }else {
  18499. // zero = strconv.Itoa(fpNumber)
  18500. // }
  18501. // fapiao_number = zero
  18502. // }
  18503. // }
  18504. //}
  18505. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18506. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18507. var patientPrescription models.HisPrescriptionInfo
  18508. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18509. if patientPrescription.ID == 0 {
  18510. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  18511. }
  18512. //if patientPrescription.Do
  18513. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18514. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  18515. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  18516. diagnosis_ids := strings.Split(diagnosis_id, ",")
  18517. var config []*models.HisXtDiagnoseConfig
  18518. for _, item := range diagnosis_ids {
  18519. id, _ := strconv.ParseInt(item, 10, 64)
  18520. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18521. config = append(config, &diagnosisConfig)
  18522. }
  18523. sickConfig, _ := service.FindSickById(sick_type)
  18524. //if tempOrder.ID == 0 {
  18525. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  18526. //}
  18527. if tempOrder.ID == 0 {
  18528. var result string
  18529. var requestLog string
  18530. var res2 ResultSix
  18531. var res3 GZResultSix
  18532. var ressix10265 ResultSix10265
  18533. if miConfig.MdtrtareaAdmvs == "421300" {
  18534. data := make(map[string]interface{})
  18535. client := &http.Client{}
  18536. data["psn_no"] = his.PsnNo
  18537. data["mdtrt_id"] = his.Number
  18538. data["opter"] = roles.UserName
  18539. data["org_name"] = miConfig.OrgName
  18540. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18541. data["doctor_id"] = doctor_info.DoctorNumber
  18542. data["doctor_name"] = doctor_info.UserName
  18543. data["department"] = department.Name
  18544. data["fixmedins_code"] = miConfig.Code
  18545. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18546. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18547. data["secret_key"] = miConfig.SecretKey
  18548. data["sick_code"] = sickConfig.CountryCode
  18549. data["sick_name"] = sickConfig.ClassName
  18550. data["dept"] = strconv.FormatInt(department.ID, 10)
  18551. data["config"] = config
  18552. data["begin_time"] = begin_time
  18553. bytesData, _ := json.Marshal(data)
  18554. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18555. resp, _ := client.Do(req)
  18556. defer resp.Body.Close()
  18557. body, ioErr := ioutil.ReadAll(resp.Body)
  18558. if ioErr != nil {
  18559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18561. return
  18562. }
  18563. var respJSON map[string]interface{}
  18564. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18567. return
  18568. }
  18569. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18570. userJSONBytes, _ := json.Marshal(respJSON)
  18571. fmt.Println("log")
  18572. fmt.Println(string(userJSONBytes))
  18573. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18574. utils.ErrorLog("解析失败:%v", err)
  18575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18576. return
  18577. }
  18578. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18579. data := make(map[string]interface{})
  18580. client := &http.Client{}
  18581. data["psn_no"] = his.PsnNo
  18582. data["mdtrt_id"] = his.Number
  18583. data["opter"] = roles.UserName
  18584. data["org_name"] = miConfig.OrgName
  18585. if reg_type == 11 && his.Insutype == "390" {
  18586. data["med_type"] = "110104"
  18587. } else {
  18588. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18589. }
  18590. data["doctor_id"] = doctor_info.DoctorNumber
  18591. data["doctor_name"] = doctor_info.UserName
  18592. data["department"] = department.Name
  18593. data["fixmedins_code"] = miConfig.Code
  18594. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18595. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18596. data["secret_key"] = miConfig.SecretKey
  18597. data["sick_code"] = sickConfig.CountryCode
  18598. data["sick_name"] = sickConfig.ClassName
  18599. data["dept"] = strconv.FormatInt(department.ID, 10)
  18600. data["config"] = config
  18601. data["begin_time"] = begin_time
  18602. bytesData, _ := json.Marshal(data)
  18603. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18604. resp, _ := client.Do(req)
  18605. defer resp.Body.Close()
  18606. body, ioErr := ioutil.ReadAll(resp.Body)
  18607. if ioErr != nil {
  18608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18610. return
  18611. }
  18612. var respJSON map[string]interface{}
  18613. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18616. return
  18617. }
  18618. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18619. userJSONBytes, _ := json.Marshal(respJSON)
  18620. fmt.Println("log")
  18621. fmt.Println(string(userJSONBytes))
  18622. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18623. utils.ErrorLog("解析失败:%v", err)
  18624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18625. return
  18626. }
  18627. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18628. data := make(map[string]interface{})
  18629. client := &http.Client{}
  18630. data["psn_no"] = his.PsnNo
  18631. data["mdtrt_id"] = his.Number
  18632. data["opter"] = roles.UserName
  18633. data["org_name"] = miConfig.OrgName
  18634. if reg_type == 11 && his.Insutype == "390" {
  18635. data["med_type"] = "110104"
  18636. } else {
  18637. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18638. }
  18639. data["doctor_id"] = doctor_info.DoctorNumber
  18640. data["doctor_name"] = doctor_info.UserName
  18641. data["department"] = department.Name
  18642. data["fixmedins_code"] = miConfig.Code
  18643. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18644. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18645. data["secret_key"] = miConfig.SecretKey
  18646. data["sick_code"] = sickConfig.CountryCode
  18647. data["sick_name"] = sickConfig.ClassName
  18648. data["dept"] = strconv.FormatInt(department.ID, 10)
  18649. data["config"] = config
  18650. data["begin_time"] = begin_time
  18651. bytesData, _ := json.Marshal(data)
  18652. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18653. resp, _ := client.Do(req)
  18654. defer resp.Body.Close()
  18655. body, ioErr := ioutil.ReadAll(resp.Body)
  18656. if ioErr != nil {
  18657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18659. return
  18660. }
  18661. var respJSON map[string]interface{}
  18662. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18665. return
  18666. }
  18667. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18668. userJSONBytes, _ := json.Marshal(respJSON)
  18669. fmt.Println("log")
  18670. fmt.Println(string(userJSONBytes))
  18671. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18672. utils.ErrorLog("解析失败:%v", err)
  18673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18674. return
  18675. }
  18676. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18677. data := make(map[string]interface{})
  18678. client := &http.Client{}
  18679. data["psn_no"] = his.PsnNo
  18680. data["mdtrt_id"] = his.Number
  18681. data["opter"] = roles.UserName
  18682. data["org_name"] = miConfig.OrgName
  18683. if reg_type == 11 && his.Insutype == "390" {
  18684. data["med_type"] = "110104"
  18685. } else {
  18686. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18687. }
  18688. data["doctor_id"] = doctor_info.DoctorNumber
  18689. data["doctor_name"] = doctor_info.UserName
  18690. data["department"] = department.Name
  18691. data["fixmedins_code"] = miConfig.Code
  18692. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18693. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18694. data["secret_key"] = miConfig.SecretKey
  18695. data["sick_code"] = sickConfig.CountryCode
  18696. data["sick_name"] = sickConfig.ClassName
  18697. data["dept"] = strconv.FormatInt(department.ID, 10)
  18698. data["config"] = config
  18699. data["begin_time"] = begin_time
  18700. bytesData, _ := json.Marshal(data)
  18701. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18702. resp, _ := client.Do(req)
  18703. defer resp.Body.Close()
  18704. body, ioErr := ioutil.ReadAll(resp.Body)
  18705. if ioErr != nil {
  18706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18708. return
  18709. }
  18710. var respJSON map[string]interface{}
  18711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18714. return
  18715. }
  18716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18717. userJSONBytes, _ := json.Marshal(respJSON)
  18718. fmt.Println("log")
  18719. fmt.Println(string(userJSONBytes))
  18720. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18721. utils.ErrorLog("解析失败:%v", err)
  18722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18723. return
  18724. }
  18725. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18726. data := make(map[string]interface{})
  18727. client := &http.Client{}
  18728. data["psn_no"] = his.PsnNo
  18729. data["mdtrt_id"] = his.Number
  18730. data["doctor"] = roles.UserName
  18731. data["department"] = department.Name
  18732. data["org_name"] = miConfig.OrgName
  18733. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18734. data["doctor_id"] = doctor_info.DoctorNumber
  18735. data["new_doctor_name"] = doctor_info.UserName
  18736. data["fixmedins_code"] = miConfig.Code
  18737. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18738. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18739. data["secret_key"] = miConfig.SecretKey
  18740. data["sick_code"] = sickConfig.CountryCode
  18741. data["sick_name"] = sickConfig.ClassName
  18742. data["url"] = miConfig.Url
  18743. data["ak"] = miConfig.AccessKey
  18744. data["begin_time"] = begin_time
  18745. data["cainfo"] = miConfig.Cainfo
  18746. data["dept"] = strconv.FormatInt(department.ID, 10)
  18747. data["config"] = config
  18748. bytesData, _ := json.Marshal(data)
  18749. var req *http.Request
  18750. if miConfig.MdtrtareaAdmvs == "320921" {
  18751. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18752. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  18753. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  18754. } else {
  18755. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18756. }
  18757. resp, _ := client.Do(req)
  18758. defer resp.Body.Close()
  18759. body, ioErr := ioutil.ReadAll(resp.Body)
  18760. if ioErr != nil {
  18761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18763. return
  18764. }
  18765. var respJSON map[string]interface{}
  18766. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18769. return
  18770. }
  18771. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18772. userJSONBytes, _ := json.Marshal(respJSON)
  18773. fmt.Println("log")
  18774. fmt.Println(string(userJSONBytes))
  18775. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18776. utils.ErrorLog("解析失败:%v", err)
  18777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18778. return
  18779. }
  18780. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18781. res2.Output = ressix10265.Output
  18782. res2.ErrMsg = ressix10265.ErrMsg
  18783. res2.Cainfo = ressix10265.Cainfo
  18784. res2.WarnMsg = ressix10265.WarnMsg
  18785. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18786. res2.Infcode = infocode
  18787. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18788. data := make(map[string]interface{})
  18789. client := &http.Client{}
  18790. data["psn_no"] = his.PsnNo
  18791. data["mdtrt_id"] = his.Number
  18792. data["doctor"] = roles.UserName
  18793. data["department"] = department.Name
  18794. data["org_name"] = miConfig.OrgName
  18795. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18796. data["doctor_id"] = doctor_info.DoctorNumber
  18797. data["new_doctor_name"] = doctor_info.UserName
  18798. data["fixmedins_code"] = miConfig.Code
  18799. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18800. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18801. data["secret_key"] = miConfig.SecretKey
  18802. data["sick_code"] = sickConfig.CountryCode
  18803. data["sick_name"] = sickConfig.ClassName
  18804. data["url"] = miConfig.Url
  18805. data["ak"] = miConfig.AccessKey
  18806. data["begin_time"] = begin_time
  18807. data["cainfo"] = miConfig.Cainfo
  18808. data["dept"] = strconv.FormatInt(department.ID, 10)
  18809. data["config"] = config
  18810. bytesData, _ := json.Marshal(data)
  18811. var req *http.Request
  18812. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  18813. resp, _ := client.Do(req)
  18814. defer resp.Body.Close()
  18815. body, ioErr := ioutil.ReadAll(resp.Body)
  18816. if ioErr != nil {
  18817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18819. return
  18820. }
  18821. var respJSON map[string]interface{}
  18822. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18825. return
  18826. }
  18827. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18828. userJSONBytes, _ := json.Marshal(respJSON)
  18829. fmt.Println("log")
  18830. fmt.Println(string(userJSONBytes))
  18831. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18832. utils.ErrorLog("解析失败:%v", err)
  18833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18834. return
  18835. }
  18836. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18837. res2.Output = ressix10265.Output
  18838. res2.ErrMsg = ressix10265.ErrMsg
  18839. res2.Cainfo = ressix10265.Cainfo
  18840. res2.WarnMsg = ressix10265.WarnMsg
  18841. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18842. res2.Infcode = infocode
  18843. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18844. result, requestLog, _ = service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  18845. saveLog(result, requestLog, "2203", "上传就诊信息")
  18846. var respJSON2 map[string]interface{}
  18847. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18850. return
  18851. }
  18852. userJSONBytes2, _ := json.Marshal(respJSON2)
  18853. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18854. utils.ErrorLog("解析失败:%v", err)
  18855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18856. return
  18857. }
  18858. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  18859. fmt.Println(result2)
  18860. fmt.Println(src_request)
  18861. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18862. data := make(map[string]interface{})
  18863. client := &http.Client{}
  18864. data["psn_no"] = his.PsnNo
  18865. data["mdtrt_id"] = his.Number
  18866. data["doctor"] = roles.UserName
  18867. data["department"] = department.Name
  18868. data["org_name"] = miConfig.OrgName
  18869. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18870. data["doctor_id"] = doctor_info.DoctorNumber
  18871. data["new_doctor_name"] = doctor_info.UserName
  18872. data["fixmedins_code"] = miConfig.Code
  18873. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18874. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18875. data["secret_key"] = miConfig.SecretKey
  18876. data["sick_code"] = sickConfig.CountryCode
  18877. data["sick_name"] = sickConfig.ClassName
  18878. data["url"] = miConfig.Url
  18879. data["ak"] = miConfig.AccessKey
  18880. data["begin_time"] = begin_time
  18881. data["cainfo"] = miConfig.Cainfo
  18882. data["dept"] = strconv.FormatInt(department.ID, 10)
  18883. data["config"] = config
  18884. bytesData, _ := json.Marshal(data)
  18885. var req *http.Request
  18886. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  18887. resp, _ := client.Do(req)
  18888. defer resp.Body.Close()
  18889. body, ioErr := ioutil.ReadAll(resp.Body)
  18890. if ioErr != nil {
  18891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18893. return
  18894. }
  18895. var respJSON map[string]interface{}
  18896. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18899. return
  18900. }
  18901. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18902. userJSONBytes, _ := json.Marshal(respJSON)
  18903. fmt.Println("log")
  18904. fmt.Println(string(userJSONBytes))
  18905. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18906. utils.ErrorLog("解析失败:%v", err)
  18907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18908. return
  18909. }
  18910. } else {
  18911. if miConfig.MdtrtareaAdmvs == "440781" { //
  18912. 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)
  18913. } else {
  18914. if miConfig.Code == "H15049901371" {
  18915. //赤峰地区国家医保医疗类别
  18916. //职工透析:医疗类别选特殊情况门诊990502
  18917. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18918. var med_type string
  18919. if his.Insutype == "390" {
  18920. if reg_type == 14 {
  18921. med_type = "9933"
  18922. } else if reg_type == 11 {
  18923. med_type = "11"
  18924. }
  18925. } else if his.Insutype == "310" {
  18926. if reg_type == 14 {
  18927. med_type = "990502"
  18928. } else if reg_type == 11 {
  18929. med_type = "11"
  18930. }
  18931. }
  18932. 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)
  18933. } else {
  18934. 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, doctor_info.UserName, admin_user_id, roles.UserName)
  18935. }
  18936. }
  18937. saveLog(result, requestLog, "2203", "上传就诊信息")
  18938. var respJSON2 map[string]interface{}
  18939. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18942. return
  18943. }
  18944. userJSONBytes2, _ := json.Marshal(respJSON2)
  18945. if miConfig.Code == "H15049901371" {
  18946. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  18947. utils.ErrorLog("解析失败:%v", err)
  18948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18949. return
  18950. }
  18951. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18952. res2.Output = ressix10265.Output
  18953. res2.ErrMsg = ressix10265.ErrMsg
  18954. res2.Cainfo = ressix10265.Cainfo
  18955. res2.WarnMsg = ressix10265.WarnMsg
  18956. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18957. res2.Infcode = infocode
  18958. } else {
  18959. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18960. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  18961. utils.ErrorLog("解析失败:%v", err)
  18962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18963. return
  18964. }
  18965. res2.Infcode = res3.Infcode
  18966. } else {
  18967. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18968. utils.ErrorLog("解析失败:%v", err)
  18969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18970. return
  18971. }
  18972. }
  18973. }
  18974. }
  18975. if res2.Infcode != 0 {
  18976. adminUser := c.GetAdminUserInfo()
  18977. errlog := &models.HisOrderError{
  18978. UserOrgId: adminUser.CurrentOrgId,
  18979. Ctime: time.Now().Unix(),
  18980. Mtime: time.Now().Unix(),
  18981. ErrMsg: res2.ErrMsg,
  18982. Status: 1,
  18983. PatientId: id,
  18984. RecordTime: recordDateTime,
  18985. Stage: 3,
  18986. }
  18987. service.CreateErrMsgLog(errlog)
  18988. c.ServeSuccessJSON(map[string]interface{}{
  18989. "failed_code": -10,
  18990. "msg": res2.ErrMsg,
  18991. })
  18992. return
  18993. } else {
  18994. his.Diagnosis = diagnosis_id
  18995. his.SickType = sickConfig.ID
  18996. //var p_type int64
  18997. //if reg_type == 1111 || reg_type == 1112 {
  18998. // p_type = 11
  18999. //
  19000. //}
  19001. his.PType = fmt.Sprintf("%d", reg_type)
  19002. service.UpdateHisPatientThree(&his)
  19003. data := make(map[string]interface{})
  19004. if settle_accounts_type == 1 { //日结
  19005. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  19006. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  19007. } else {
  19008. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  19009. }
  19010. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  19011. data["pre"] = prescriptions
  19012. } else { //月结
  19013. start_time_str := c.GetString("start_time")
  19014. end_time_str := c.GetString("end_time")
  19015. timeLayout := "2006-01-02"
  19016. loc, _ := time.LoadLocation("Local")
  19017. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  19018. if err != nil {
  19019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19020. return
  19021. }
  19022. recordStartTime := theStartTime.Unix()
  19023. start_time = recordStartTime
  19024. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  19025. if err != nil {
  19026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19027. return
  19028. }
  19029. recordEndTime := theEndTime.Unix()
  19030. end_time = recordEndTime
  19031. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  19032. data["pre"] = prescriptions
  19033. }
  19034. timestamp := time.Now().Unix()
  19035. tempTime := time.Unix(timestamp, 0)
  19036. timeFormat := tempTime.Format("20060102150405")
  19037. chrgBchno := rand.Intn(100000) + 10000
  19038. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  19039. strconv.FormatInt(his.PatientId, 10)
  19040. client := &http.Client{}
  19041. data["psn_no"] = his.PsnNo
  19042. data["mdtrt_id"] = his.Number
  19043. data["chrg_bchno"] = chrg_bchno
  19044. data["org_name"] = miConfig.OrgName
  19045. data["doctor"] = doctor_info.UserName
  19046. data["doctor_id"] = doctor_info.DoctorNumber
  19047. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  19048. data["fixmedins_code"] = miConfig.Code
  19049. data["dept_code"] = department.Number
  19050. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19051. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19052. data["secret_key"] = miConfig.SecretKey
  19053. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  19054. data["url"] = miConfig.Url
  19055. data["ak"] = miConfig.AccessKey
  19056. data["new_doctor_name"] = patientPrescription.Doctor
  19057. data["diag_code"] = sickConfig.CountryCode
  19058. data["cainfo"] = miConfig.Cainfo
  19059. data["opter"] = roles.UserName
  19060. var ids []int64
  19061. for _, item := range prescriptions {
  19062. ids = append(ids, item.ID)
  19063. }
  19064. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  19065. if config.IsOpen == 1 { //对接了医保,走医保流程
  19066. var res ResultFour
  19067. var resFour10265 ResultFour10265
  19068. if miConfig.MdtrtareaAdmvs == "421300" {
  19069. bytesData, _ := json.Marshal(data)
  19070. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19071. resp, _ := client.Do(req)
  19072. defer resp.Body.Close()
  19073. body, ioErr := ioutil.ReadAll(resp.Body)
  19074. if ioErr != nil {
  19075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19077. return
  19078. }
  19079. var respJSON map[string]interface{}
  19080. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19083. return
  19084. }
  19085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19086. userJSONBytes, _ := json.Marshal(respJSON)
  19087. fmt.Println("log")
  19088. fmt.Println(string(userJSONBytes))
  19089. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19090. utils.ErrorLog("解析失败:%v", err)
  19091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19092. return
  19093. }
  19094. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19095. bytesData, _ := json.Marshal(data)
  19096. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19097. resp, _ := client.Do(req)
  19098. defer resp.Body.Close()
  19099. body, ioErr := ioutil.ReadAll(resp.Body)
  19100. if ioErr != nil {
  19101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19103. return
  19104. }
  19105. var respJSON map[string]interface{}
  19106. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19109. return
  19110. }
  19111. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19112. userJSONBytes, _ := json.Marshal(respJSON)
  19113. fmt.Println("log")
  19114. fmt.Println(string(userJSONBytes))
  19115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19116. utils.ErrorLog("解析失败:%v", err)
  19117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19118. return
  19119. }
  19120. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19121. bytesData, _ := json.Marshal(data)
  19122. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  19123. resp, _ := client.Do(req)
  19124. defer resp.Body.Close()
  19125. body, ioErr := ioutil.ReadAll(resp.Body)
  19126. if ioErr != nil {
  19127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19129. return
  19130. }
  19131. var respJSON map[string]interface{}
  19132. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19135. return
  19136. }
  19137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19138. userJSONBytes, _ := json.Marshal(respJSON)
  19139. fmt.Println("log")
  19140. fmt.Println(string(userJSONBytes))
  19141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19142. utils.ErrorLog("解析失败:%v", err)
  19143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19144. return
  19145. }
  19146. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19147. bytesData, _ := json.Marshal(data)
  19148. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  19149. resp, _ := client.Do(req)
  19150. defer resp.Body.Close()
  19151. body, ioErr := ioutil.ReadAll(resp.Body)
  19152. if ioErr != nil {
  19153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19155. return
  19156. }
  19157. var respJSON map[string]interface{}
  19158. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19161. return
  19162. }
  19163. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19164. userJSONBytes, _ := json.Marshal(respJSON)
  19165. fmt.Println("log")
  19166. fmt.Println(string(userJSONBytes))
  19167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19168. utils.ErrorLog("解析失败:%v", err)
  19169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19170. return
  19171. }
  19172. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19173. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  19174. if result3101.Infcode == "0" {
  19175. if len(result3101.Output.Result) > 0 {
  19176. var errMsgs []string
  19177. for _, item := range result3101.Output.Result {
  19178. errMsgs = append(errMsgs, item.VolaCont)
  19179. }
  19180. c.ServeSuccessJSON(map[string]interface{}{
  19181. "failed_code": -10,
  19182. "msg": errMsgs,
  19183. })
  19184. return
  19185. }
  19186. }
  19187. bytesData, _ := json.Marshal(data)
  19188. var req *http.Request
  19189. if miConfig.MdtrtareaAdmvs == "320921" {
  19190. data["diag_code"] = sickConfig.CountryCode
  19191. fmt.Println(data)
  19192. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19193. } else {
  19194. data["diag_code"] = sickConfig.CountryCode
  19195. fmt.Println(data)
  19196. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19197. }
  19198. resp, _ := client.Do(req)
  19199. defer resp.Body.Close()
  19200. body, ioErr := ioutil.ReadAll(resp.Body)
  19201. if ioErr != nil {
  19202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19204. return
  19205. }
  19206. var respJSON map[string]interface{}
  19207. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19210. return
  19211. }
  19212. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19213. userJSONBytes, _ := json.Marshal(respJSON)
  19214. fmt.Println("log")
  19215. fmt.Println(string(userJSONBytes))
  19216. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19217. utils.ErrorLog("解析失败:%v", err)
  19218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19219. return
  19220. }
  19221. res.InfRefmsgid = resFour10265.InfRefmsgid
  19222. res.Output = resFour10265.Output
  19223. res.ErrMsg = resFour10265.ErrMsg
  19224. res.Cainfo = resFour10265.Cainfo
  19225. res.WarnMsg = resFour10265.WarnMsg
  19226. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19227. res.Infcode = infocode
  19228. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19229. var pagesize int = 2
  19230. var start int = 1
  19231. var stop int
  19232. var pagecount int
  19233. var curpage int
  19234. var isSuccess bool = true
  19235. data["doctor_id"] = doctor_info.DoctorNumber
  19236. //总页数,向上取整,注意除之前要先转换类型为float64
  19237. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  19238. for curpage = 1; curpage <= pagecount; curpage++ {
  19239. if curpage == 1 {
  19240. start = 1
  19241. } else {
  19242. start = (curpage-1)*pagesize + 1
  19243. }
  19244. stop = curpage * pagesize
  19245. if stop > len(prescriptions) {
  19246. stop = len(prescriptions)
  19247. }
  19248. //var requestLog string
  19249. data["pre"] = prescriptions[start-1 : stop]
  19250. fmt.Println(data["pre"])
  19251. bytesData, _ := json.Marshal(data)
  19252. var req *http.Request
  19253. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  19254. resp, _ := client.Do(req)
  19255. defer resp.Body.Close()
  19256. body, ioErr := ioutil.ReadAll(resp.Body)
  19257. if ioErr != nil {
  19258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19260. return
  19261. }
  19262. var respJSON map[string]interface{}
  19263. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19266. return
  19267. }
  19268. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19269. userJSONBytes, _ := json.Marshal(respJSON)
  19270. fmt.Println("log")
  19271. fmt.Println(string(userJSONBytes))
  19272. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19273. utils.ErrorLog("解析失败:%v", err)
  19274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19275. return
  19276. }
  19277. res.InfRefmsgid = resFour10265.InfRefmsgid
  19278. res.Output = resFour10265.Output
  19279. res.ErrMsg = resFour10265.ErrMsg
  19280. res.Cainfo = resFour10265.Cainfo
  19281. res.WarnMsg = resFour10265.WarnMsg
  19282. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19283. res.Infcode = infocode
  19284. if infocode == 0 {
  19285. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  19286. } else {
  19287. isSuccess = false
  19288. errlog := &models.HisOrderError{
  19289. UserOrgId: adminUser.CurrentOrgId,
  19290. Ctime: time.Now().Unix(),
  19291. Mtime: time.Now().Unix(),
  19292. Number: chrg_bchno,
  19293. ErrMsg: "",
  19294. Status: 1,
  19295. PatientId: id,
  19296. RecordTime: recordDateTime,
  19297. Stage: 4,
  19298. }
  19299. service.CreateErrMsgLog(errlog)
  19300. c.ServeSuccessJSON(map[string]interface{}{
  19301. "failed_code": -10,
  19302. "msg": res.ErrMsg,
  19303. })
  19304. return
  19305. }
  19306. }
  19307. if isSuccess {
  19308. res.Infcode = 0
  19309. }
  19310. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19311. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, doctor_info.DoctorNumber, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  19312. var dat map[string]interface{}
  19313. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19314. fmt.Println(dat)
  19315. } else {
  19316. fmt.Println(err)
  19317. }
  19318. saveLog(result, request_log, "2204", "上传费用明细")
  19319. userJSONBytes, _ := json.Marshal(dat)
  19320. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19321. utils.ErrorLog("解析失败:%v", err)
  19322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19323. return
  19324. }
  19325. res.InfRefmsgid = resFour10265.InfRefmsgid
  19326. res.Output = resFour10265.Output
  19327. res.ErrMsg = resFour10265.ErrMsg
  19328. res.Cainfo = resFour10265.Cainfo
  19329. res.WarnMsg = resFour10265.WarnMsg
  19330. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19331. res.Infcode = infocode
  19332. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19333. bytesData, _ := json.Marshal(data)
  19334. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  19335. resp, _ := client.Do(req)
  19336. defer resp.Body.Close()
  19337. body, ioErr := ioutil.ReadAll(resp.Body)
  19338. if ioErr != nil {
  19339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19341. return
  19342. }
  19343. var respJSON map[string]interface{}
  19344. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19347. return
  19348. }
  19349. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19350. userJSONBytes, _ := json.Marshal(respJSON)
  19351. fmt.Println("log")
  19352. fmt.Println(string(userJSONBytes))
  19353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19354. utils.ErrorLog("解析失败:%v", err)
  19355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19356. return
  19357. }
  19358. } else {
  19359. if miConfig.Code == "H15049901371" {
  19360. 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, doctor_info.DoctorNumber, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode, admin_user_id)
  19361. var dat map[string]interface{}
  19362. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19363. fmt.Println(dat)
  19364. } else {
  19365. fmt.Println(err)
  19366. }
  19367. saveLog(result, request_log, "2204", "上传费用明细")
  19368. userJSONBytes, _ := json.Marshal(dat)
  19369. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19370. utils.ErrorLog("解析失败:%v", err)
  19371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19372. return
  19373. }
  19374. res.InfRefmsgid = resFour10265.InfRefmsgid
  19375. res.Output = resFour10265.Output
  19376. res.ErrMsg = resFour10265.ErrMsg
  19377. res.Cainfo = resFour10265.Cainfo
  19378. res.WarnMsg = resFour10265.WarnMsg
  19379. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19380. res.Infcode = infocode
  19381. } else {
  19382. 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, admin_user_id)
  19383. var dat map[string]interface{}
  19384. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19385. fmt.Println(dat)
  19386. } else {
  19387. fmt.Println(err)
  19388. }
  19389. saveLog(result, request_log, "2204", "上传费用明细")
  19390. userJSONBytes, _ := json.Marshal(dat)
  19391. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19392. utils.ErrorLog("解析失败:%v", err)
  19393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19394. return
  19395. }
  19396. }
  19397. }
  19398. if res.Infcode == 0 {
  19399. order := &models.HisOrder{
  19400. UserOrgId: adminUser.CurrentOrgId,
  19401. HisPatientId: his.ID,
  19402. PatientId: his.PatientId,
  19403. SettleAccountsDate: recordDateTime,
  19404. MdtrtId: his.Number,
  19405. PsnNo: his.PsnNo,
  19406. MedType: strconv.FormatInt(reg_type, 10),
  19407. Ctime: time.Now().Unix(),
  19408. Mtime: time.Now().Unix(),
  19409. Status: 1,
  19410. Number: chrg_bchno,
  19411. Infcode: res.Infcode,
  19412. WarnMsg: res.WarnMsg,
  19413. Cainfo: res.Cainfo,
  19414. ErrMsg: res.ErrMsg,
  19415. RespondTime: res.RefmsgTime,
  19416. InfRefmsgid: res.InfRefmsgid,
  19417. OrderStatus: 1,
  19418. PayWay: pay_way,
  19419. PayWays: pay_ways,
  19420. OthDesc: oth_desc,
  19421. PayPrice: pay_price,
  19422. PayCardNo: pay_card_no,
  19423. DiscountPrice: discount_price,
  19424. PreferentialPrice: preferential_price,
  19425. RealityPrice: reality_price,
  19426. FoundPrice: found_price,
  19427. MedicalInsurancePrice: medical_insurance_price,
  19428. PrivatePrice: private_price,
  19429. IsMedicineInsurance: 1,
  19430. SettleType: settle_accounts_type,
  19431. SettleStartTime: start_time,
  19432. SettleEndTime: end_time,
  19433. Creator: roles.AdminUserId,
  19434. Modify: roles.AdminUserId,
  19435. FaPiaoNumber: fapiao_number,
  19436. FaPiaoCode: fapiao_code,
  19437. PType: 2,
  19438. Diagnosis: diagnosis_id,
  19439. CashPay: cash_pay,
  19440. WechatPay: wechat_pay,
  19441. AliPay: ali_pay,
  19442. JifenPay: jifen_pay,
  19443. BandCardPay: band_card_pay,
  19444. }
  19445. err = service.CreateOrder(order)
  19446. if err != nil {
  19447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  19448. return
  19449. }
  19450. for _, item := range res.Output.Result {
  19451. temp := strings.Split(item.FeedetlSn, "-")
  19452. var advice_id int64 = 0
  19453. var project_id int64 = 0
  19454. var types int64 = 0
  19455. id, _ := strconv.ParseInt(temp[2], 10, 64)
  19456. types, _ = strconv.ParseInt(temp[1], 10, 64)
  19457. if temp[1] == "1" {
  19458. advice_id = id
  19459. project_id = 0
  19460. } else if temp[1] == "2" {
  19461. advice_id = 0
  19462. project_id = id
  19463. }
  19464. if item.MedChrgitmType == "9" {
  19465. item.MedChrgitmType = "09"
  19466. }
  19467. info := &models.HisOrderInfo{
  19468. OrderNumber: order.Number,
  19469. FeedetlSn: item.FeedetlSn,
  19470. UploadDate: time.Now().Unix(),
  19471. AdviceId: advice_id,
  19472. DetItemFeeSumamt: item.DetItemFeeSumamt,
  19473. Cnt: item.Cnt,
  19474. Pric: float64(item.Pric),
  19475. PatientId: his.PatientId,
  19476. PricUplmtAmt: item.PricUplmtAmt,
  19477. SelfpayProp: item.SelfpayProp,
  19478. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  19479. OverlmtAmt: item.OverlmtAmt,
  19480. PreselfpayAmt: item.PreselfpayAmt,
  19481. BasMednFlag: item.BasMednFlag,
  19482. MedChrgitmType: item.MedChrgitmType,
  19483. HiNegoDrugFlag: item.HiNegoDrugFlag,
  19484. Status: 1,
  19485. Memo: item.Memo,
  19486. Mtime: time.Now().Unix(),
  19487. InscpScpAmt: item.InscpScpAmt,
  19488. DrtReimFlag: item.DrtReimFlag,
  19489. Ctime: time.Now().Unix(),
  19490. ListSpItemFlag: item.ListSpItemFlag,
  19491. ChldMedcFlag: item.ChldMedcFlag,
  19492. LmtUsedFlag: item.LmtUsedFlag,
  19493. ChrgitmLv: item.ChrgitmLv,
  19494. UserOrgId: adminUser.CurrentOrgId,
  19495. HisPatientId: his.ID,
  19496. OrderId: order.ID,
  19497. ProjectId: project_id,
  19498. Type: types,
  19499. }
  19500. service.CreateOrderInfo(info)
  19501. }
  19502. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  19503. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  19504. var total float64
  19505. for _, item := range prescriptions {
  19506. if item.Type == 1 { //药品
  19507. for _, subItem := range item.HisDoctorAdviceInfo {
  19508. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19509. total_one := price * subItem.PrescribingNumber
  19510. total = total + total_one
  19511. }
  19512. }
  19513. if item.Type == 2 { //项目
  19514. for _, subItem := range item.HisPrescriptionProject {
  19515. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  19516. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19517. total_one := price * cnt
  19518. total = total + total_one
  19519. }
  19520. }
  19521. }
  19522. allTotal := fmt.Sprintf("%.2f", total)
  19523. //if adminUser.CurrentOrgId == 9919 {
  19524. //
  19525. // allTotal = fmt.Sprintf("%.2f", total)
  19526. //
  19527. //} else {
  19528. //
  19529. // allTotal = fmt.Sprintf("%.2f", total)
  19530. //
  19531. //}
  19532. if res.Infcode == 0 {
  19533. var rf []*ResultFive
  19534. json.Unmarshal([]byte(his.Iinfo), &rf)
  19535. chrg_bchno := chrg_bchno
  19536. cert_no := his.Certno
  19537. var insutypes []string
  19538. var insutype string
  19539. var is390 int = 0
  19540. var is310 int = 0
  19541. for _, item := range rf {
  19542. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19543. insutypes = append(insutypes, item.Insutype)
  19544. }
  19545. }
  19546. if len(insutypes) == 1 {
  19547. insutype = insutypes[0]
  19548. } else {
  19549. for _, i := range insutypes {
  19550. if i == "390" {
  19551. is390 = 1
  19552. }
  19553. if i == "310" {
  19554. is310 = 1
  19555. }
  19556. }
  19557. }
  19558. if is390 == 1 {
  19559. insutype = "390"
  19560. }
  19561. if is310 == 1 {
  19562. insutype = "310"
  19563. }
  19564. if len(insutypes) == 0 {
  19565. insutype = "310"
  19566. }
  19567. if len(insutypes) == 2 {
  19568. insutype = strconv.FormatInt(his.SocialType, 10)
  19569. }
  19570. insutype = strconv.FormatInt(his.SocialType, 10)
  19571. //insutype = "390"
  19572. if his.IdCardType == 1 {
  19573. // cert_no = his.MedicalInsuranceNumber
  19574. cert_no = his.Certno
  19575. } else {
  19576. cert_no = his.Certno
  19577. }
  19578. var res ResultSeven
  19579. var resSeven10265 ResultSeven10265
  19580. var gzresSeven10265Two GZResultSeven10265Two
  19581. var src_resquest string
  19582. var result2 string
  19583. if miConfig.MdtrtareaAdmvs == "421300" {
  19584. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19585. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19586. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19587. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19588. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19589. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19590. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19591. resp, requestErr := http.Get(api)
  19592. if requestErr != nil {
  19593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19594. return
  19595. }
  19596. body, ioErr := ioutil.ReadAll(resp.Body)
  19597. if ioErr != nil {
  19598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19600. return
  19601. }
  19602. var respJSON map[string]interface{}
  19603. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19606. return
  19607. }
  19608. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19609. result, _ := json.Marshal(respJSON)
  19610. if miConfig.Code == "H15049901371" {
  19611. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19612. utils.ErrorLog("解析失败:%v", err)
  19613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19614. return
  19615. }
  19616. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19617. res.Output = resSeven10265.Output
  19618. res.ErrMsg = resSeven10265.ErrMsg
  19619. res.Cainfo = resSeven10265.Cainfo
  19620. res.WarnMsg = resSeven10265.WarnMsg
  19621. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19622. res.Infcode = infocode
  19623. } else {
  19624. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19625. utils.ErrorLog("解析失败:%v", err)
  19626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19627. return
  19628. }
  19629. }
  19630. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19631. if reg_type == 11 && his.Insutype == "390" {
  19632. reg_type = 110104
  19633. }
  19634. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19635. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19636. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19637. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19638. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19639. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19640. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19641. resp, requestErr := http.Get(api)
  19642. if requestErr != nil {
  19643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19644. return
  19645. }
  19646. body, ioErr := ioutil.ReadAll(resp.Body)
  19647. if ioErr != nil {
  19648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19650. return
  19651. }
  19652. var respJSON map[string]interface{}
  19653. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19656. return
  19657. }
  19658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19659. result, _ := json.Marshal(respJSON)
  19660. if miConfig.Code == "H15049901371" {
  19661. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19662. utils.ErrorLog("解析失败:%v", err)
  19663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19664. return
  19665. }
  19666. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19667. res.Output = resSeven10265.Output
  19668. res.ErrMsg = resSeven10265.ErrMsg
  19669. res.Cainfo = resSeven10265.Cainfo
  19670. res.WarnMsg = resSeven10265.WarnMsg
  19671. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19672. res.Infcode = infocode
  19673. } else {
  19674. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19675. utils.ErrorLog("解析失败:%v", err)
  19676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19677. return
  19678. }
  19679. }
  19680. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19681. if reg_type == 11 && his.Insutype == "390" {
  19682. reg_type = 110104
  19683. }
  19684. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19685. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19686. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19687. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19688. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19689. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19690. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19691. resp, requestErr := http.Get(api)
  19692. if requestErr != nil {
  19693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19694. return
  19695. }
  19696. body, ioErr := ioutil.ReadAll(resp.Body)
  19697. if ioErr != nil {
  19698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19700. return
  19701. }
  19702. var respJSON map[string]interface{}
  19703. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19706. return
  19707. }
  19708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19709. result, _ := json.Marshal(respJSON)
  19710. if miConfig.Code == "H15049901371" {
  19711. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19712. utils.ErrorLog("解析失败:%v", err)
  19713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19714. return
  19715. }
  19716. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19717. res.Output = resSeven10265.Output
  19718. res.ErrMsg = resSeven10265.ErrMsg
  19719. res.Cainfo = resSeven10265.Cainfo
  19720. res.WarnMsg = resSeven10265.WarnMsg
  19721. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19722. res.Infcode = infocode
  19723. } else {
  19724. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19725. utils.ErrorLog("解析失败:%v", err)
  19726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19727. return
  19728. }
  19729. }
  19730. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19731. if reg_type == 11 && his.Insutype == "390" {
  19732. reg_type = 110104
  19733. }
  19734. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19735. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19736. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19737. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19738. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19739. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19740. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19741. resp, requestErr := http.Get(api)
  19742. if requestErr != nil {
  19743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19744. return
  19745. }
  19746. body, ioErr := ioutil.ReadAll(resp.Body)
  19747. if ioErr != nil {
  19748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19750. return
  19751. }
  19752. var respJSON map[string]interface{}
  19753. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19756. return
  19757. }
  19758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19759. result, _ := json.Marshal(respJSON)
  19760. if miConfig.Code == "H15049901371" {
  19761. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19762. utils.ErrorLog("解析失败:%v", err)
  19763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19764. return
  19765. }
  19766. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19767. res.Output = resSeven10265.Output
  19768. res.ErrMsg = resSeven10265.ErrMsg
  19769. res.Cainfo = resSeven10265.Cainfo
  19770. res.WarnMsg = resSeven10265.WarnMsg
  19771. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19772. res.Infcode = infocode
  19773. } else {
  19774. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19775. utils.ErrorLog("解析失败:%v", err)
  19776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19777. return
  19778. }
  19779. }
  19780. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19781. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  19782. if result3101.Infcode == "0" {
  19783. if len(result3101.Output.Result) > 0 {
  19784. var errMsgs []string
  19785. for _, item := range result3101.Output.Result {
  19786. errMsgs = append(errMsgs, item.VolaCont)
  19787. }
  19788. c.ServeSuccessJSON(map[string]interface{}{
  19789. "failed_code": -10,
  19790. "msg": errMsgs,
  19791. })
  19792. return
  19793. } else {
  19794. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19795. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19796. bas := strings.Split(psn_info.CardInfo, "|")
  19797. if his.IdCardType == 1 {
  19798. cert_no = bas[2]
  19799. } else if his.IdCardType == 3 {
  19800. cert_no = his.Certno
  19801. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19802. } else if his.IdCardType == 4 {
  19803. cert_no = his.Certno
  19804. psn_info.VerifyNumber = psn_info.VerifyNumber
  19805. }
  19806. var api string
  19807. if miConfig.MdtrtareaAdmvs == "320921" {
  19808. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19809. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19810. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19811. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19812. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19813. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19814. "&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 + "&mdtrt_grp_type=" + his.MdtrtGrpType
  19815. } else {
  19816. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19817. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19818. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19819. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19820. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19821. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19822. "&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 + "&mdtrt_grp_type=" + his.MdtrtGrpType
  19823. }
  19824. resp, requestErr := http.Get(api)
  19825. if requestErr != nil {
  19826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19827. return
  19828. }
  19829. body, ioErr := ioutil.ReadAll(resp.Body)
  19830. if ioErr != nil {
  19831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19833. return
  19834. }
  19835. var respJSON map[string]interface{}
  19836. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19839. return
  19840. }
  19841. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19842. result, _ := json.Marshal(respJSON)
  19843. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19844. utils.ErrorLog("解析失败:%v", err)
  19845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19846. return
  19847. }
  19848. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19849. res.Output = resSeven10265.Output
  19850. res.ErrMsg = resSeven10265.ErrMsg
  19851. res.Cainfo = resSeven10265.Cainfo
  19852. res.WarnMsg = resSeven10265.WarnMsg
  19853. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19854. res.Infcode = infocode
  19855. }
  19856. }
  19857. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19858. psn_info, _ := service.GetPsnByPatientId(id)
  19859. var verify_number string
  19860. if psn_info.IdCardType == 4 {
  19861. verify_number = psn_info.VerifyNumber
  19862. } else if psn_info.IdCardType == 1 {
  19863. bas := strings.Split(psn_info.CardInfo, "|")
  19864. cardNumber := bas[2]
  19865. verify_number = cardNumber
  19866. } else {
  19867. psn_info.IdCardType = 2
  19868. verify_number = psn_info.Certno
  19869. }
  19870. var api string
  19871. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19872. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19873. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19874. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19875. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19876. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19877. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType + "&verify_number=" + verify_number
  19878. resp, requestErr := http.Get(api)
  19879. if requestErr != nil {
  19880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19881. return
  19882. }
  19883. body, ioErr := ioutil.ReadAll(resp.Body)
  19884. if ioErr != nil {
  19885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19887. return
  19888. }
  19889. var respJSON map[string]interface{}
  19890. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19893. return
  19894. }
  19895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19896. result, _ := json.Marshal(respJSON)
  19897. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19898. utils.ErrorLog("解析失败:%v", err)
  19899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19900. return
  19901. }
  19902. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19903. res.Output = resSeven10265.Output
  19904. res.ErrMsg = resSeven10265.ErrMsg
  19905. res.Cainfo = resSeven10265.Cainfo
  19906. res.WarnMsg = resSeven10265.WarnMsg
  19907. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19908. res.Infcode = infocode
  19909. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19910. var cert_no string
  19911. if his.IdCardType == 4 {
  19912. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19913. cert_no = psn_info.VerifyNumber
  19914. result2, src_resquest, _ = service.FJyb2207ForToken(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  19915. } else if his.IdCardType == 1 {
  19916. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19917. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19918. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  19919. }
  19920. //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)
  19921. var dat map[string]interface{}
  19922. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19923. fmt.Println(dat)
  19924. } else {
  19925. fmt.Println(err)
  19926. }
  19927. saveLog(result2, src_resquest, "2207", "结算")
  19928. userJSONBytes, _ := json.Marshal(dat)
  19929. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19930. utils.ErrorLog("解析失败:%v", err)
  19931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19932. return
  19933. }
  19934. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19935. res.Output = resSeven10265.Output
  19936. res.ErrMsg = resSeven10265.ErrMsg
  19937. res.Cainfo = resSeven10265.Cainfo
  19938. res.WarnMsg = resSeven10265.WarnMsg
  19939. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19940. res.Infcode = infocode
  19941. } else if miConfig.MdtrtareaAdmvs == "450721" {
  19942. res2 := c.GetoleInfo()
  19943. if res2.Infcode == 0 {
  19944. var result string
  19945. var request_log string
  19946. var result_log string
  19947. if res2.Output.MdtrtCertType == "02" {
  19948. result, request_log, result_log = service.ZHGdyb1101(res2.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res2.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", 1, res2.Output.PsnName, admin_user_id)
  19949. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19950. } else if res2.Output.MdtrtCertType == "01" {
  19951. result, request_log, result_log = service.ZHGdyb1101d(res2.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res2.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, "", 1, res2.Output.PsnName, admin_user_id, res2.Output.EcToken)
  19952. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19953. } else {
  19954. result, request_log, result_log = service.ZHGdyb1101d(res2.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res2.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res2.Output.CardSN, 1, res2.Output.PsnName, admin_user_id, res2.Output.CardNo)
  19955. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19956. }
  19957. var dat map[string]interface{}
  19958. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19959. fmt.Println(dat)
  19960. } else {
  19961. fmt.Println(err)
  19962. }
  19963. userJSONBytes, _ := json.Marshal(dat)
  19964. var res5 ResultTwo
  19965. //var resTwo10265 ResultTwo10265
  19966. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19967. utils.ErrorLog("解析失败:%v", err)
  19968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19969. return
  19970. }
  19971. if res5.Infcode == -1 {
  19972. c.ServeSuccessJSON(map[string]interface{}{
  19973. "failed_code": -10,
  19974. "msg": res5.ErrMsg,
  19975. })
  19976. return
  19977. }
  19978. var insutypes []string
  19979. var insutype string
  19980. var is390 int = 0
  19981. var is310 int = 0
  19982. for _, item := range res5.Output.Iinfo {
  19983. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19984. insutypes = append(insutypes, item.Insutype)
  19985. }
  19986. }
  19987. if len(insutypes) == 1 {
  19988. insutype = insutypes[0]
  19989. } else {
  19990. for _, i := range insutypes {
  19991. if i == "390" {
  19992. is390 = 1
  19993. }
  19994. if i == "310" {
  19995. is310 = 1
  19996. }
  19997. }
  19998. }
  19999. if is390 == 1 {
  20000. insutype = "390"
  20001. }
  20002. if is310 == 1 {
  20003. insutype = "310"
  20004. }
  20005. if len(insutypes) == 0 {
  20006. insutype = "310"
  20007. }
  20008. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20009. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20010. infoStr := string(Iinfos)
  20011. idetinfoStr := string(Idetinfos)
  20012. psn := &models.HisPsn{
  20013. PsnNo: res5.Output.Baseinfo.PsnNo,
  20014. PatientId: id,
  20015. Certno: res5.Output.Baseinfo.Certno,
  20016. Gend: res5.Output.Baseinfo.Gend,
  20017. Naty: res5.Output.Baseinfo.Naty,
  20018. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20019. PsnName: res5.Output.Baseinfo.PsnName,
  20020. Idetinfo: idetinfoStr,
  20021. Insuinfo: infoStr,
  20022. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20023. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20024. VerifyNumber: res2.Output.EcToken,
  20025. }
  20026. if res2.Output.MdtrtCertType == "01" {
  20027. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20028. psn.VerifyNumber = res2.Output.EcToken
  20029. } else if res2.Output.MdtrtCertType == "02" {
  20030. psn.VerifyNumber = res2.Output.CardNo
  20031. } else {
  20032. psn.VerifyNumber = res2.Output.MdtrtCertNo
  20033. }
  20034. service.CreateHisPsn(psn)
  20035. if res2.Output.MdtrtCertType == "01" {
  20036. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20037. token := res2.Output.EcToken
  20038. 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, 4, acct_used_flag, token, admin_user_id)
  20039. } else if res2.Output.MdtrtCertType == "02" {
  20040. 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, 2, acct_used_flag, "", admin_user_id)
  20041. } else {
  20042. 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, 1, acct_used_flag, "", admin_user_id)
  20043. }
  20044. var dat2 map[string]interface{}
  20045. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20046. fmt.Println(dat2)
  20047. } else {
  20048. fmt.Println(err)
  20049. }
  20050. userJSONBytes3, _ := json.Marshal(dat2)
  20051. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20052. utils.ErrorLog("解析失败:%v", err)
  20053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20054. return
  20055. }
  20056. saveLog(result2, src_resquest, "2207", "结算")
  20057. } else {
  20058. c.ServeSuccessJSON(map[string]interface{}{
  20059. "failed_code": -10,
  20060. "msg": res2.ErrMsg,
  20061. })
  20062. return
  20063. }
  20064. } else {
  20065. if miConfig.Code == "H15049901371" {
  20066. //赤峰地区国家医保医疗类别
  20067. //职工透析:医疗类别选特殊情况门诊990502
  20068. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20069. var med_type string
  20070. if his.Insutype == "390" {
  20071. if reg_type == 14 {
  20072. med_type = "9933"
  20073. } else if reg_type == 11 {
  20074. med_type = "11"
  20075. }
  20076. } else if his.Insutype == "310" {
  20077. if reg_type == 14 {
  20078. med_type = "990502"
  20079. } else if reg_type == 11 {
  20080. med_type = "11"
  20081. }
  20082. }
  20083. 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, "", admin_user_id)
  20084. } else {
  20085. if his.IdCardType == 4 {
  20086. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20087. var token string
  20088. token = psn_info.VerifyNumber
  20089. 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, token, admin_user_id)
  20090. } else {
  20091. if his.IdCardType == 1 {
  20092. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20093. bas := strings.Split(psn_info.CardInfo, "|")
  20094. basNumber := bas[2]
  20095. cert_no = basNumber
  20096. }
  20097. 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, "", admin_user_id)
  20098. }
  20099. }
  20100. //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)
  20101. var dat map[string]interface{}
  20102. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20103. fmt.Println(dat)
  20104. } else {
  20105. fmt.Println(err)
  20106. }
  20107. saveLog(result2, src_resquest, "2207", "结算")
  20108. userJSONBytes, _ := json.Marshal(dat)
  20109. if miConfig.Code == "H15049901371" {
  20110. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20111. utils.ErrorLog("解析失败:%v", err)
  20112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20113. return
  20114. }
  20115. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20116. res.Output = resSeven10265.Output
  20117. res.ErrMsg = resSeven10265.ErrMsg
  20118. res.Cainfo = resSeven10265.Cainfo
  20119. res.WarnMsg = resSeven10265.WarnMsg
  20120. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20121. res.Infcode = infocode
  20122. } else {
  20123. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20124. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20125. utils.ErrorLog("解析失败:%v", err)
  20126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20127. return
  20128. }
  20129. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20130. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20131. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20132. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20133. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20134. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20135. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20136. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20137. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20138. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20139. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20140. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20141. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20142. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20143. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20144. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20145. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  20146. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  20147. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  20148. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  20149. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20150. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  20151. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  20152. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  20153. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  20154. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  20155. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  20156. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  20157. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  20158. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  20159. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  20160. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  20161. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  20162. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  20163. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  20164. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20165. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20166. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20167. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20168. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20169. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20170. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  20171. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  20172. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  20173. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20174. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20175. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20176. res.Cainfo = gzresSeven10265Two.Cainfo
  20177. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20178. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20179. //res.Infcode = infocode
  20180. } else {
  20181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20182. utils.ErrorLog("解析失败:%v", err)
  20183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20184. return
  20185. }
  20186. }
  20187. }
  20188. }
  20189. if res.Infcode == -1 {
  20190. errlog := &models.HisOrderError{
  20191. UserOrgId: adminUser.CurrentOrgId,
  20192. Ctime: time.Now().Unix(),
  20193. Mtime: time.Now().Unix(),
  20194. Number: chrg_bchno,
  20195. ErrMsg: res.ErrMsg,
  20196. Status: 1,
  20197. PatientId: id,
  20198. RecordTime: recordDateTime,
  20199. Stage: 6,
  20200. }
  20201. service.CreateErrMsgLog(errlog)
  20202. c.ServeSuccessJSON(map[string]interface{}{
  20203. "failed_code": -10,
  20204. "msg": res.ErrMsg,
  20205. })
  20206. return
  20207. } else {
  20208. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20209. order.OrderStatus = 2
  20210. order.Status = 1
  20211. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20212. order.SetlId = res.Output.Setlinfo.SetlID
  20213. order.PsnNo = res.Output.Setlinfo.PsnNo
  20214. order.PsnName = res.Output.Setlinfo.PsnName
  20215. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20216. order.Certno = res.Output.Setlinfo.Certno
  20217. order.Gend = res.Output.Setlinfo.Gend
  20218. order.Naty = res.Output.Setlinfo.Naty
  20219. order.Age = res.Output.Setlinfo.Age
  20220. order.Insutype = res.Output.Setlinfo.Insutype
  20221. order.PsnType = res.Output.Setlinfo.PsnType
  20222. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20223. order.SetlTime = res.Output.Setlinfo.SetlTime
  20224. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20225. if res.Output.Setlinfo.MedType == "140101" {
  20226. order.MedType = "14"
  20227. } else {
  20228. if res.Output.Setlinfo.MedType == "110104" {
  20229. order.MedType = "11"
  20230. } else {
  20231. order.MedType = res.Output.Setlinfo.MedType
  20232. }
  20233. }
  20234. if reg_type == 1112 {
  20235. order.MedType = "1112"
  20236. }
  20237. if reg_type == 1111 {
  20238. order.MedType = "1111"
  20239. }
  20240. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20241. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20242. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20243. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20244. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20245. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20246. order.HifpPay = res.Output.Setlinfo.HifpPay
  20247. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20248. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20249. order.HifesPay = res.Output.Setlinfo.HifesPay
  20250. order.HifobPay = res.Output.Setlinfo.HifobPay
  20251. order.MafPay = res.Output.Setlinfo.MafPay
  20252. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20253. order.OthPay = res.Output.Setlinfo.OthPay
  20254. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20255. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20256. order.AcctPay = res.Output.Setlinfo.AcctPay
  20257. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20258. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20259. order.Balc = res.Output.Setlinfo.Balc
  20260. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20261. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20262. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20263. order.ClrType = res.Output.Setlinfo.ClrType
  20264. order.ClrWay = res.Output.Setlinfo.ClrWay
  20265. order.Creator = order.Creator
  20266. order.Modify = roles.AdminUserId
  20267. order.RequestLog = src_resquest
  20268. order.FaPiaoNumber = fapiao_number
  20269. order.FaPiaoCode = fapiao_code
  20270. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20271. //detailStr := string(setlDetail)
  20272. //order.SetlDetail = detailStr
  20273. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20274. err = service.UpDateOrder(order)
  20275. if err == nil {
  20276. //判断是否使用了押金
  20277. if dec_way == "true" {
  20278. tmpstring := strconv.FormatInt(order.ID, 10)
  20279. order.Decimal = decimal
  20280. service.UpDateOrder(order)
  20281. //扣押金
  20282. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20283. if errmsg != nil {
  20284. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20285. return
  20286. }
  20287. }
  20288. c.ServeSuccessJSON(map[string]interface{}{
  20289. "msg": "结算成功",
  20290. })
  20291. } else {
  20292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20293. return
  20294. }
  20295. }
  20296. } else {
  20297. adminUser := c.GetAdminUserInfo()
  20298. errlog := &models.HisOrderError{
  20299. UserOrgId: adminUser.CurrentOrgId,
  20300. Ctime: time.Now().Unix(),
  20301. Mtime: time.Now().Unix(),
  20302. ErrMsg: res.ErrMsg,
  20303. Status: 1,
  20304. PatientId: id,
  20305. RecordTime: recordDateTime,
  20306. Stage: 4,
  20307. }
  20308. service.CreateErrMsgLog(errlog)
  20309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  20310. return
  20311. }
  20312. } else {
  20313. adminUser := c.GetAdminUserInfo()
  20314. errlog := &models.HisOrderError{
  20315. UserOrgId: adminUser.CurrentOrgId,
  20316. Ctime: time.Now().Unix(),
  20317. Mtime: time.Now().Unix(),
  20318. ErrMsg: res.ErrMsg,
  20319. Status: 1,
  20320. PatientId: id,
  20321. RecordTime: recordDateTime,
  20322. Stage: 4,
  20323. }
  20324. service.CreateErrMsgLog(errlog)
  20325. c.ServeSuccessJSON(map[string]interface{}{
  20326. "failed_code": -10,
  20327. "msg": res.ErrMsg,
  20328. })
  20329. return
  20330. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  20331. //return
  20332. }
  20333. }
  20334. }
  20335. } else if tempOrder.ID > 0 {
  20336. if tempOrder.IsPre == 1 {
  20337. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  20338. var rf []*ResultFive
  20339. json.Unmarshal([]byte(his.Iinfo), &rf)
  20340. chrg_bchno := tempOrder.Number
  20341. cert_no := his.Certno
  20342. var insutypes []string
  20343. var insutype string
  20344. var is390 int = 0
  20345. var is310 int = 0
  20346. for _, item := range rf {
  20347. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20348. insutypes = append(insutypes, item.Insutype)
  20349. }
  20350. }
  20351. if len(insutypes) == 1 {
  20352. insutype = insutypes[0]
  20353. } else {
  20354. for _, i := range insutypes {
  20355. if i == "390" {
  20356. is390 = 1
  20357. }
  20358. if i == "310" {
  20359. is310 = 1
  20360. }
  20361. }
  20362. }
  20363. if is390 == 1 {
  20364. insutype = "390"
  20365. }
  20366. if is310 == 1 {
  20367. insutype = "310"
  20368. }
  20369. if len(insutypes) == 0 {
  20370. insutype = "310"
  20371. }
  20372. if len(insutypes) == 2 {
  20373. insutype = strconv.FormatInt(his.SocialType, 10)
  20374. }
  20375. //insutype = "390"
  20376. if his.IdCardType == 1 {
  20377. // cert_no = his.MedicalInsuranceNumber
  20378. cert_no = his.Certno
  20379. } else {
  20380. cert_no = his.Certno
  20381. }
  20382. var res ResultSeven
  20383. var ahres ResultSevenAH
  20384. var resSeven10265 ResultSeven10265
  20385. var gzresSeven10265Two GZResultSeven10265Two
  20386. var src_resquest string
  20387. var result2 string
  20388. if miConfig.MdtrtareaAdmvs == "450721" {
  20389. res2 := c.GetoleInfo()
  20390. if res2.Infcode == 0 {
  20391. var result string
  20392. var request_log string
  20393. var result_log string
  20394. if res2.Output.MdtrtCertType == "02" {
  20395. result, request_log, result_log = service.ZHGdyb1101(res2.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res2.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", 1, res2.Output.PsnName, admin_user_id)
  20396. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20397. } else if res2.Output.MdtrtCertType == "01" {
  20398. result, request_log, result_log = service.ZHGdyb1101d(res2.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res2.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, "", 1, res2.Output.PsnName, admin_user_id, res2.Output.EcToken)
  20399. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20400. } else {
  20401. result, request_log, result_log = service.ZHGdyb1101d(res2.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res2.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res2.Output.CardSN, 1, res2.Output.PsnName, admin_user_id, res2.Output.CardNo)
  20402. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20403. }
  20404. var dat map[string]interface{}
  20405. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20406. fmt.Println(dat)
  20407. } else {
  20408. fmt.Println(err)
  20409. }
  20410. userJSONBytes, _ := json.Marshal(dat)
  20411. var res5 ResultTwo
  20412. //var resTwo10265 ResultTwo10265
  20413. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20414. utils.ErrorLog("解析失败:%v", err)
  20415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20416. return
  20417. }
  20418. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  20419. if res5.Infcode == -1 {
  20420. c.ServeSuccessJSON(map[string]interface{}{
  20421. "failed_code": -10,
  20422. "msg": res5.ErrMsg,
  20423. })
  20424. return
  20425. }
  20426. var insutypes []string
  20427. var insutype string
  20428. var is390 int = 0
  20429. var is310 int = 0
  20430. for _, item := range res5.Output.Iinfo {
  20431. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20432. insutypes = append(insutypes, item.Insutype)
  20433. }
  20434. }
  20435. if len(insutypes) == 1 {
  20436. insutype = insutypes[0]
  20437. } else {
  20438. for _, i := range insutypes {
  20439. if i == "390" {
  20440. is390 = 1
  20441. }
  20442. if i == "310" {
  20443. is310 = 1
  20444. }
  20445. }
  20446. }
  20447. if is390 == 1 {
  20448. insutype = "390"
  20449. }
  20450. if is310 == 1 {
  20451. insutype = "310"
  20452. }
  20453. if len(insutypes) == 0 {
  20454. insutype = "310"
  20455. }
  20456. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20457. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20458. infoStr := string(Iinfos)
  20459. idetinfoStr := string(Idetinfos)
  20460. psn := &models.HisPsn{
  20461. PsnNo: res5.Output.Baseinfo.PsnNo,
  20462. PatientId: id,
  20463. Certno: res5.Output.Baseinfo.Certno,
  20464. Gend: res5.Output.Baseinfo.Gend,
  20465. Naty: res5.Output.Baseinfo.Naty,
  20466. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20467. PsnName: res5.Output.Baseinfo.PsnName,
  20468. Idetinfo: idetinfoStr,
  20469. Insuinfo: infoStr,
  20470. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20471. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20472. VerifyNumber: res2.Output.EcToken,
  20473. }
  20474. service.CreateHisPsn(psn)
  20475. if res2.Output.MdtrtCertType == "01" {
  20476. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20477. token := res2.Output.EcToken
  20478. result2, src_resquest = service.Gxyb2207(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), 4, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 4, acct_used_flag, token, admin_user_id)
  20479. } else if res2.Output.MdtrtCertType == "02" {
  20480. result2, src_resquest = service.Gxyb2207(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), 2, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 2, acct_used_flag, "", admin_user_id)
  20481. } else {
  20482. result2, src_resquest = service.Gxyb2207(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), 1, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 1, acct_used_flag, res2.Output.CardNo, admin_user_id)
  20483. }
  20484. var dat2 map[string]interface{}
  20485. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20486. fmt.Println(dat2)
  20487. } else {
  20488. fmt.Println(err)
  20489. }
  20490. userJSONBytes3, _ := json.Marshal(dat2)
  20491. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20492. utils.ErrorLog("解析失败:%v", err)
  20493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20494. return
  20495. }
  20496. saveLog(result2, src_resquest, "2207", "结算")
  20497. } else {
  20498. c.ServeSuccessJSON(map[string]interface{}{
  20499. "failed_code": -10,
  20500. "msg": res2.ErrMsg,
  20501. })
  20502. return
  20503. }
  20504. } else if miConfig.MdtrtareaAdmvs == "421300" {
  20505. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20506. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20507. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20508. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20509. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20510. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20511. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20512. resp, requestErr := http.Get(api)
  20513. if requestErr != nil {
  20514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20515. return
  20516. }
  20517. body, ioErr := ioutil.ReadAll(resp.Body)
  20518. if ioErr != nil {
  20519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20521. return
  20522. }
  20523. var respJSON map[string]interface{}
  20524. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20527. return
  20528. }
  20529. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20530. result, _ := json.Marshal(respJSON)
  20531. fmt.Println("log")
  20532. fmt.Println(string(result))
  20533. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20534. utils.ErrorLog("解析失败:%v", err)
  20535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20536. return
  20537. }
  20538. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20539. if reg_type == 11 && his.Insutype == "390" {
  20540. reg_type = 110104
  20541. }
  20542. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20543. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20544. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20545. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20546. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20547. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20548. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20549. resp, requestErr := http.Get(api)
  20550. if requestErr != nil {
  20551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20552. return
  20553. }
  20554. body, ioErr := ioutil.ReadAll(resp.Body)
  20555. if ioErr != nil {
  20556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20558. return
  20559. }
  20560. var respJSON map[string]interface{}
  20561. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20564. return
  20565. }
  20566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20567. result, _ := json.Marshal(respJSON)
  20568. fmt.Println("log")
  20569. fmt.Println(string(result))
  20570. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20571. utils.ErrorLog("解析失败:%v", err)
  20572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20573. return
  20574. }
  20575. } else if miConfig.MdtrtareaAdmvs == "420902" {
  20576. if reg_type == 11 && his.Insutype == "390" {
  20577. reg_type = 110104
  20578. }
  20579. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20580. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20581. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20582. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20583. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20584. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20585. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20586. resp, requestErr := http.Get(api)
  20587. if requestErr != nil {
  20588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20589. return
  20590. }
  20591. body, ioErr := ioutil.ReadAll(resp.Body)
  20592. if ioErr != nil {
  20593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20595. return
  20596. }
  20597. var respJSON map[string]interface{}
  20598. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20601. return
  20602. }
  20603. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20604. result, _ := json.Marshal(respJSON)
  20605. fmt.Println("log")
  20606. fmt.Println(string(result))
  20607. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20608. utils.ErrorLog("解析失败:%v", err)
  20609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20610. return
  20611. }
  20612. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20613. if reg_type == 11 && his.Insutype == "390" {
  20614. reg_type = 110104
  20615. }
  20616. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20617. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20618. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20619. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20620. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20621. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20622. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20623. resp, requestErr := http.Get(api)
  20624. if requestErr != nil {
  20625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20626. return
  20627. }
  20628. body, ioErr := ioutil.ReadAll(resp.Body)
  20629. if ioErr != nil {
  20630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20632. return
  20633. }
  20634. var respJSON map[string]interface{}
  20635. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20638. return
  20639. }
  20640. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20641. result, _ := json.Marshal(respJSON)
  20642. fmt.Println("log")
  20643. fmt.Println(string(result))
  20644. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20645. utils.ErrorLog("解析失败:%v", err)
  20646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20647. return
  20648. }
  20649. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20650. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  20651. if result3101.Infcode == "0" {
  20652. if len(result3101.Output.Result) > 0 {
  20653. var errMsgs []string
  20654. for _, item := range result3101.Output.Result {
  20655. errMsgs = append(errMsgs, item.VolaCont)
  20656. }
  20657. c.ServeSuccessJSON(map[string]interface{}{
  20658. "failed_code": -10,
  20659. "msg": errMsgs,
  20660. })
  20661. return
  20662. } else {
  20663. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20664. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20665. bas := strings.Split(psn_info.CardInfo, "|")
  20666. if his.IdCardType == 1 {
  20667. cert_no = bas[2]
  20668. } else if his.IdCardType == 3 {
  20669. cert_no = his.Certno
  20670. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20671. } else if his.IdCardType == 4 {
  20672. cert_no = his.Certno
  20673. psn_info.VerifyNumber = psn_info.VerifyNumber
  20674. }
  20675. //江苏地区国家医保医疗类别
  20676. //职工透析:医疗类别选特殊情况门诊9933
  20677. //居民血透门慢: 医疗类别选门诊慢病1402
  20678. //var med_type string
  20679. //if his.Insutype == "310" {
  20680. // if reg_type == 14 {
  20681. // med_type = "9933"
  20682. // } else if reg_type == 11 {
  20683. // med_type = "11"
  20684. //
  20685. // }
  20686. //} else if his.Insutype == "390" {
  20687. // if reg_type == 14 {
  20688. // med_type = "1402"
  20689. // } else if reg_type == 11 {
  20690. // med_type = "11"
  20691. // }
  20692. //}
  20693. var api string
  20694. if miConfig.MdtrtareaAdmvs == "320921" {
  20695. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20696. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20697. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20698. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20699. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20700. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20701. "&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 + "&mdtrt_grp_type=" + his.MdtrtGrpType
  20702. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20703. } else {
  20704. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20705. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20706. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20707. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20708. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20709. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20710. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20711. "&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 + "&mdtrt_grp_type=" + his.MdtrtGrpType
  20712. }
  20713. resp, requestErr := http.Get(api)
  20714. if requestErr != nil {
  20715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20716. return
  20717. }
  20718. body, ioErr := ioutil.ReadAll(resp.Body)
  20719. if ioErr != nil {
  20720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20722. return
  20723. }
  20724. var respJSON map[string]interface{}
  20725. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20728. return
  20729. }
  20730. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20731. result, _ := json.Marshal(respJSON)
  20732. fmt.Println("log")
  20733. fmt.Println(string(result))
  20734. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20735. utils.ErrorLog("解析失败:%v", err)
  20736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20737. return
  20738. }
  20739. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20740. res.Output = resSeven10265.Output
  20741. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20742. res.ErrMsg = resSeven10265.ErrMsg
  20743. res.Cainfo = resSeven10265.Cainfo
  20744. res.WarnMsg = resSeven10265.WarnMsg
  20745. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20746. res.Infcode = infocode
  20747. }
  20748. }
  20749. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20750. psn_info, _ := service.GetPsnByPatientId(id)
  20751. var verify_number string
  20752. if psn_info.IdCardType == 4 {
  20753. verify_number = psn_info.VerifyNumber
  20754. } else if psn_info.IdCardType == 1 {
  20755. bas := strings.Split(psn_info.CardInfo, "|")
  20756. cardNumber := bas[2]
  20757. verify_number = cardNumber
  20758. } else {
  20759. verify_number = psn_info.Certno
  20760. psn_info.IdCardType = 2
  20761. }
  20762. var api string
  20763. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20764. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20765. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20766. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20767. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20768. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20769. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType + "&verify_number=" + verify_number
  20770. resp, requestErr := http.Get(api)
  20771. if requestErr != nil {
  20772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20773. return
  20774. }
  20775. body, ioErr := ioutil.ReadAll(resp.Body)
  20776. if ioErr != nil {
  20777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20779. return
  20780. }
  20781. var respJSON map[string]interface{}
  20782. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20785. return
  20786. }
  20787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20788. result, _ := json.Marshal(respJSON)
  20789. fmt.Println("log")
  20790. fmt.Println(string(result))
  20791. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20792. utils.ErrorLog("解析失败:%v", err)
  20793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20794. return
  20795. }
  20796. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20797. res.Output = resSeven10265.Output
  20798. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20799. res.ErrMsg = resSeven10265.ErrMsg
  20800. res.Cainfo = resSeven10265.Cainfo
  20801. res.WarnMsg = resSeven10265.WarnMsg
  20802. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20803. res.Infcode = infocode
  20804. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20805. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20806. var cert_no string
  20807. if his.IdCardType == 1 {
  20808. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20809. } else {
  20810. cert_no = psn_info.VerifyNumber
  20811. }
  20812. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  20813. var dat map[string]interface{}
  20814. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20815. fmt.Println(dat)
  20816. } else {
  20817. fmt.Println(err)
  20818. }
  20819. saveLog(result2, src_resquest, "2207", "结算")
  20820. userJSONBytes, _ := json.Marshal(dat)
  20821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20822. utils.ErrorLog("解析失败:%v", err)
  20823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20824. return
  20825. }
  20826. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20827. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20828. var cert_no string
  20829. var card_sn string
  20830. if his.IdCardType == 1 {
  20831. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20832. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20833. bas := strings.Split(psn_info.CardInfo, "|")
  20834. card_sn = bas[3]
  20835. } else if his.IdCardType == 2 {
  20836. cert_no = his.IdCardNo
  20837. } else {
  20838. cert_no = psn_info.VerifyNumber
  20839. }
  20840. var rf []*ResultFive
  20841. json.Unmarshal([]byte(his.Iinfo), &rf)
  20842. var psn_type string
  20843. for _, item := range rf {
  20844. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  20845. psn_type = item.PsnType
  20846. }
  20847. }
  20848. result2, src_resquest := service.Jxyb2207(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.IdCardType, acct_used_flag, miConfig.Url, miConfig.AccessKey, cert_no, "", card_sn, his.PsnCertType, his.Certno, psn_type, his.PsnName)
  20849. var dat map[string]interface{}
  20850. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20851. fmt.Println(dat)
  20852. } else {
  20853. fmt.Println(err)
  20854. }
  20855. saveLog(result2, src_resquest, "2207", "结算")
  20856. userJSONBytes, _ := json.Marshal(dat)
  20857. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20858. utils.ErrorLog("解析失败:%v", err)
  20859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20860. return
  20861. }
  20862. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20863. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20864. if his.IdCardType == 1 {
  20865. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20866. bas := strings.Split(psn_info.CardInfo, "|")
  20867. cert_no = bas[2]
  20868. } else if his.IdCardType == 3 {
  20869. cert_no = his.Certno
  20870. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20871. } else if his.IdCardType == 4 {
  20872. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20873. cert_no = his.Certno
  20874. psn_info.VerifyNumber = psn_info.VerifyNumber
  20875. } else {
  20876. cert_no = his.Certno
  20877. psn_info.VerifyNumber = his.Certno
  20878. }
  20879. var api string
  20880. var med_type string
  20881. if his.Insutype == "390" {
  20882. if reg_type == 992102 {
  20883. med_type = "992102"
  20884. }
  20885. if reg_type == 140104 {
  20886. med_type = "140104"
  20887. }
  20888. if reg_type == 14 {
  20889. med_type = "14"
  20890. }
  20891. } else if his.Insutype == "310" {
  20892. if reg_type == 992102 {
  20893. med_type = "992102"
  20894. }
  20895. if reg_type == 14 {
  20896. med_type = "14"
  20897. }
  20898. }
  20899. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20900. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20901. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20902. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20903. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20904. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20905. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + med_type + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  20906. resp, requestErr := http.Get(api)
  20907. if requestErr != nil {
  20908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20909. return
  20910. }
  20911. body, ioErr := ioutil.ReadAll(resp.Body)
  20912. if ioErr != nil {
  20913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20915. return
  20916. }
  20917. var respJSON map[string]interface{}
  20918. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20921. return
  20922. }
  20923. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20924. if status == "0" {
  20925. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20926. c.ServeSuccessJSON(map[string]interface{}{
  20927. "failed_code": -10,
  20928. "msg": err_msg,
  20929. })
  20930. return
  20931. }
  20932. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20933. result, _ := json.Marshal(respJSON)
  20934. fmt.Println("log")
  20935. fmt.Println(string(result))
  20936. if err := json.Unmarshal(result, &ahres); err != nil {
  20937. utils.ErrorLog("解析失败:%v", err)
  20938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20939. return
  20940. }
  20941. res.InfRefmsgid = ahres.InfRefmsgid
  20942. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  20943. // 创建对应的Time类型
  20944. t := time.UnixMilli(timestamp)
  20945. // 格式化成指定的日期字符串
  20946. str := t.Format("2006-01-02 15:04:05")
  20947. res.Output.Setlinfo.SetlTime = str
  20948. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  20949. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  20950. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20951. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  20952. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  20953. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  20954. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20955. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  20956. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  20957. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  20958. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  20959. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  20960. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20961. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  20962. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  20963. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  20964. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  20965. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  20966. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  20967. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20968. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  20969. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  20970. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  20971. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  20972. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  20973. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  20974. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  20975. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  20976. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  20977. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  20978. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  20979. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  20980. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  20981. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  20982. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  20983. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  20984. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  20985. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  20986. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  20987. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  20988. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  20989. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  20990. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  20991. res.Output.Setldetail = ahres.Output.Setldetail
  20992. res.ErrMsg = ahres.ErrMsg
  20993. res.Cainfo = ahres.Cainfo
  20994. res.WarnMsg = ahres.WarnMsg
  20995. res.Infcode = ahres.Infcode
  20996. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20997. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20998. var cert_no string
  20999. if his.IdCardType == 1 {
  21000. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  21001. } else if his.IdCardType == 2 {
  21002. cert_no = his.IdCardNo
  21003. } else {
  21004. cert_no = psn_info.VerifyNumber
  21005. }
  21006. result2, src_resquest := service.Hnyb2207(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.IdCardType, acct_used_flag, miConfig.Url, miConfig.AccessKey, cert_no, "")
  21007. var dat map[string]interface{}
  21008. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21009. fmt.Println(dat)
  21010. } else {
  21011. fmt.Println(err)
  21012. }
  21013. saveLog(result2, src_resquest, "2207", "结算")
  21014. userJSONBytes, _ := json.Marshal(dat)
  21015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21016. utils.ErrorLog("解析失败:%v", err)
  21017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21018. return
  21019. }
  21020. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21021. psn_info, _ := service.GetPsnByPatientId(id)
  21022. var verify_number string
  21023. if psn_info.IdCardType == 4 {
  21024. verify_number = psn_info.VerifyNumber
  21025. } else if psn_info.IdCardType == 1 {
  21026. bas := strings.Split(psn_info.CardInfo, "|")
  21027. cardNumber := bas[2]
  21028. verify_number = cardNumber
  21029. } else {
  21030. verify_number = psn_info.Certno
  21031. psn_info.IdCardType = 2
  21032. }
  21033. var api string
  21034. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21035. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21036. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21037. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21038. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  21039. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21040. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  21041. resp, requestErr := http.Get(api)
  21042. if requestErr != nil {
  21043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21044. return
  21045. }
  21046. body, ioErr := ioutil.ReadAll(resp.Body)
  21047. if ioErr != nil {
  21048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21050. return
  21051. }
  21052. var respJSON map[string]interface{}
  21053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21056. return
  21057. }
  21058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21059. result, _ := json.Marshal(respJSON)
  21060. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21061. utils.ErrorLog("解析失败:%v", err)
  21062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21063. return
  21064. }
  21065. } else {
  21066. var src_resquest string
  21067. if miConfig.Code == "H15049901371" {
  21068. //赤峰地区国家医保医疗类别
  21069. //职工透析:医疗类别选特殊情况门诊990502
  21070. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21071. var med_type string
  21072. if his.Insutype == "390" {
  21073. if reg_type == 14 {
  21074. med_type = "9933"
  21075. } else if reg_type == 11 {
  21076. med_type = "11"
  21077. }
  21078. } else if his.Insutype == "310" {
  21079. if reg_type == 14 {
  21080. med_type = "990502"
  21081. } else if reg_type == 11 {
  21082. med_type = "11"
  21083. }
  21084. }
  21085. 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, "", admin_user_id)
  21086. } else {
  21087. if his.IdCardType == 4 {
  21088. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21089. token := psn_info.VerifyNumber
  21090. 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, token, admin_user_id)
  21091. } else {
  21092. 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, "", admin_user_id)
  21093. }
  21094. }
  21095. var dat map[string]interface{}
  21096. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21097. fmt.Println(dat)
  21098. } else {
  21099. fmt.Println(err)
  21100. }
  21101. saveLog(result2, src_resquest, "2207", "结算")
  21102. userJSONBytes, _ := json.Marshal(dat)
  21103. if miConfig.Code == "H15049901371" {
  21104. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  21105. utils.ErrorLog("解析失败:%v", err)
  21106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21107. return
  21108. }
  21109. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21110. res.Output = resSeven10265.Output
  21111. res.ErrMsg = resSeven10265.ErrMsg
  21112. res.Cainfo = resSeven10265.Cainfo
  21113. res.WarnMsg = resSeven10265.WarnMsg
  21114. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21115. res.Infcode = infocode
  21116. } else {
  21117. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21118. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  21119. utils.ErrorLog("解析失败:%v", err)
  21120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21121. return
  21122. }
  21123. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  21124. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  21125. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  21126. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21127. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  21128. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  21129. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  21130. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21131. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  21132. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21133. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21134. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21135. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21136. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21137. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  21138. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  21139. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  21140. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  21141. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  21142. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  21143. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21144. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  21145. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  21146. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  21147. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  21148. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  21149. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  21150. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  21151. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  21152. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  21153. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  21154. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  21155. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  21156. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  21157. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21158. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  21159. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  21160. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  21161. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21162. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  21163. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  21164. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  21165. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  21166. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  21167. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  21168. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  21169. res.ErrMsg = gzresSeven10265Two.ErrMsg
  21170. res.Cainfo = gzresSeven10265Two.Cainfo
  21171. res.WarnMsg = gzresSeven10265Two.WarnMsg
  21172. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  21173. //res.Infcode = infocode
  21174. } else {
  21175. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21176. utils.ErrorLog("解析失败:%v", err)
  21177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21178. return
  21179. }
  21180. }
  21181. }
  21182. }
  21183. if res.Infcode != 0 {
  21184. errlog := &models.HisOrderError{
  21185. UserOrgId: adminUser.CurrentOrgId,
  21186. Ctime: time.Now().Unix(),
  21187. Mtime: time.Now().Unix(),
  21188. Number: chrg_bchno,
  21189. ErrMsg: res.ErrMsg,
  21190. Status: 1,
  21191. PatientId: id,
  21192. RecordTime: recordDateTime,
  21193. Stage: 6,
  21194. }
  21195. service.CreateErrMsgLog(errlog)
  21196. c.ServeSuccessJSON(map[string]interface{}{
  21197. "failed_code": -10,
  21198. "msg": res.ErrMsg,
  21199. })
  21200. return
  21201. } else {
  21202. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  21203. order.OrderStatus = 2
  21204. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  21205. order.SetlId = res.Output.Setlinfo.SetlID
  21206. order.PsnNo = res.Output.Setlinfo.PsnNo
  21207. order.PsnName = res.Output.Setlinfo.PsnName
  21208. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  21209. order.Certno = res.Output.Setlinfo.Certno
  21210. order.Gend = res.Output.Setlinfo.Gend
  21211. order.Naty = res.Output.Setlinfo.Naty
  21212. order.Age = res.Output.Setlinfo.Age
  21213. order.Insutype = res.Output.Setlinfo.Insutype
  21214. order.PsnType = res.Output.Setlinfo.PsnType
  21215. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  21216. order.SetlTime = res.Output.Setlinfo.SetlTime
  21217. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  21218. order.PayWays = pay_ways
  21219. order.AcctUsedFlag = acct_used_flag
  21220. order.WechatPay = wechat_pay
  21221. order.AliPay = ali_pay
  21222. order.JifenPay = jifen_pay
  21223. order.BandCardPay = band_card_pay
  21224. order.CashPay = cash_pay
  21225. order.OthDesc = oth_desc
  21226. //order.MedType = res.Output.Setlinfo.MedType
  21227. if reg_type == 1112 {
  21228. order.MedType = "1112"
  21229. }
  21230. if reg_type == 1111 {
  21231. order.MedType = "1111"
  21232. }
  21233. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  21234. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  21235. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  21236. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  21237. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  21238. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  21239. order.HifpPay = res.Output.Setlinfo.HifpPay
  21240. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  21241. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  21242. order.HifesPay = res.Output.Setlinfo.HifesPay
  21243. order.HifobPay = res.Output.Setlinfo.HifobPay
  21244. order.MafPay = res.Output.Setlinfo.MafPay
  21245. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  21246. order.OthPay = res.Output.Setlinfo.OthPay
  21247. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  21248. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  21249. order.AcctPay = res.Output.Setlinfo.AcctPay
  21250. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  21251. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  21252. order.Balc = res.Output.Setlinfo.Balc
  21253. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  21254. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  21255. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  21256. order.ClrWay = res.Output.Setlinfo.ClrWay
  21257. order.Creator = order.Creator
  21258. order.ClrType = res.Output.Setlinfo.ClrType
  21259. order.Modify = roles.AdminUserId
  21260. order.RequestLog = src_resquest
  21261. order.Diagnosis = diagnosis_id
  21262. order.FaPiaoNumber = fapiao_number
  21263. order.FaPiaoCode = fapiao_code
  21264. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  21265. detailStr := string(setlDetail)
  21266. order.SetlDetail = detailStr
  21267. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  21268. err = service.UpDateOrder(order)
  21269. if err == nil {
  21270. //判断是否使用了押金
  21271. if dec_way == "true" {
  21272. tmpstring := strconv.FormatInt(order.ID, 10)
  21273. //扣押金
  21274. order.Decimal = decimal
  21275. service.UpDateOrder(order)
  21276. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  21277. if errmsg != nil {
  21278. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  21279. return
  21280. }
  21281. }
  21282. c.ServeSuccessJSON(map[string]interface{}{
  21283. "msg": "结算成功",
  21284. })
  21285. } else {
  21286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  21287. return
  21288. }
  21289. }
  21290. }
  21291. }
  21292. }
  21293. // 上传明细-预结算-
  21294. func (c *HisApiController) GetPreUploadInfo() {
  21295. id, _ := c.GetInt64("id")
  21296. record_time := c.GetString("record_time")
  21297. his_patient_id, _ := c.GetInt64("his_patient_id")
  21298. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  21299. admin_user_id, _ := c.GetInt64("admin_user_id")
  21300. diagnosis_id := c.GetString("diagnosis")
  21301. sick_type, _ := c.GetInt64("sick_type")
  21302. reg_type, _ := c.GetInt64("p_type")
  21303. begin_time := c.GetString("begin_time")
  21304. acct_used_flag := c.GetString("acct_used_flag")
  21305. id_str := c.GetString("ids")
  21306. ids_arr := strings.Split(id_str, ",")
  21307. timeLayout := "2006-01-02"
  21308. loc, _ := time.LoadLocation("Local")
  21309. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21310. if err != nil {
  21311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21312. return
  21313. }
  21314. recordDateTime := theTime.Unix()
  21315. adminUser := c.GetAdminUserInfo()
  21316. diagnosis_ids := strings.Split(diagnosis_id, ",")
  21317. var config []*models.HisXtDiagnoseConfig
  21318. for _, item := range diagnosis_ids {
  21319. id, _ := strconv.ParseInt(item, 10, 64)
  21320. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21321. config = append(config, &diagnosisConfig)
  21322. }
  21323. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  21324. sickConfig, _ := service.FindSickById(sick_type)
  21325. var prescriptions []*models.HisPrescription
  21326. var start_time int64
  21327. var end_time int64
  21328. var isSuccess bool = true
  21329. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21330. fmt.Println(his_patient_id)
  21331. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21332. timestamp := time.Now().Unix()
  21333. tempTime := time.Unix(timestamp, 0)
  21334. timeFormat := tempTime.Format("20060102150405")
  21335. chrgBchno := rand.Intn(100000) + 10000
  21336. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  21337. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21338. var patientPrescription models.HisPrescriptionInfo
  21339. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21340. if patientPrescription.ID == 0 {
  21341. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  21342. }
  21343. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21344. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  21345. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  21346. strconv.FormatInt(his.PatientId, 10)
  21347. var res2406 Result2406
  21348. //安徽单病种处理
  21349. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  21350. data := make(map[string]interface{})
  21351. client := &http.Client{}
  21352. data["psn_no"] = his.PsnNo
  21353. data["mdtrt_id"] = his.Number
  21354. data["operator"] = roles.UserName
  21355. data["cert_no"] = his.IdCardNo
  21356. data["org_name"] = miConfig.OrgName
  21357. data["psn_name"] = his.Name
  21358. data["ipt_otp_no"] = his.IptOtpNo
  21359. data["ipt_psn_sp_flag_type"] = "0901"
  21360. data["ipt_psn_sp_flag"] = "1"
  21361. data["fixmedins_code"] = miConfig.Code
  21362. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21363. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21364. data["url"] = miConfig.Url
  21365. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  21366. bytesData, _ := json.Marshal(data)
  21367. var req *http.Request
  21368. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  21369. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  21370. resp, _ := client.Do(req)
  21371. defer resp.Body.Close()
  21372. body, ioErr := ioutil.ReadAll(resp.Body)
  21373. if ioErr != nil {
  21374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21376. return
  21377. }
  21378. var respJSON map[string]interface{}
  21379. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21382. return
  21383. }
  21384. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21385. if status == "0" {
  21386. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21387. c.ServeSuccessJSON(map[string]interface{}{
  21388. "failed_code": -10,
  21389. "msg": err_msg,
  21390. })
  21391. return
  21392. }
  21393. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21394. userJSONBytes, _ := json.Marshal(respJSON)
  21395. fmt.Println("log")
  21396. fmt.Println(string(userJSONBytes))
  21397. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  21398. utils.ErrorLog("解析失败:%v", err)
  21399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21400. return
  21401. }
  21402. }
  21403. if res2406.Infcode != 0 {
  21404. adminUser := c.GetAdminUserInfo()
  21405. errlog := &models.HisOrderError{
  21406. UserOrgId: adminUser.CurrentOrgId,
  21407. Ctime: time.Now().Unix(),
  21408. Mtime: time.Now().Unix(),
  21409. ErrMsg: res2406.ErrMsg,
  21410. Status: 1,
  21411. PatientId: id,
  21412. RecordTime: recordDateTime,
  21413. Stage: 3,
  21414. }
  21415. service.CreateErrMsgLog(errlog)
  21416. c.ServeSuccessJSON(map[string]interface{}{
  21417. "failed_code": -10,
  21418. "msg": res2406.ErrMsg,
  21419. })
  21420. return
  21421. }
  21422. var res2 ResultSix
  21423. var res3 GZResultSix
  21424. var resSix10265 ResultSix10265
  21425. //var time_stamp string
  21426. if miConfig.MdtrtareaAdmvs == "421300" {
  21427. data := make(map[string]interface{})
  21428. client := &http.Client{}
  21429. data["psn_no"] = his.PsnNo
  21430. data["mdtrt_id"] = his.Number
  21431. data["department"] = department.Name
  21432. data["org_name"] = miConfig.OrgName
  21433. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21434. data["doctor_id"] = doctor_info.DoctorNumber
  21435. data["doctor_name"] = roles.UserName
  21436. data["fixmedins_code"] = miConfig.Code
  21437. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21438. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21439. data["secret_key"] = miConfig.SecretKey
  21440. data["sick_code"] = sickConfig.CountryCode
  21441. data["sick_name"] = sickConfig.ClassName
  21442. data["begin_time"] = begin_time
  21443. data["dept"] = strconv.FormatInt(department.ID, 10)
  21444. data["config"] = config
  21445. data["opter"] = roles.UserName
  21446. fmt.Println(data)
  21447. bytesData, _ := json.Marshal(data)
  21448. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21449. resp, _ := client.Do(req)
  21450. defer resp.Body.Close()
  21451. body, ioErr := ioutil.ReadAll(resp.Body)
  21452. if ioErr != nil {
  21453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21455. return
  21456. }
  21457. var respJSON map[string]interface{}
  21458. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21461. return
  21462. }
  21463. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21464. userJSONBytes, _ := json.Marshal(respJSON)
  21465. fmt.Println("log")
  21466. fmt.Println(string(userJSONBytes))
  21467. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21468. utils.ErrorLog("解析失败:%v", err)
  21469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21470. return
  21471. }
  21472. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21473. data := make(map[string]interface{})
  21474. client := &http.Client{}
  21475. data["psn_no"] = his.PsnNo
  21476. data["mdtrt_id"] = his.Number
  21477. data["department"] = department.Name
  21478. data["org_name"] = miConfig.OrgName
  21479. if reg_type == 11 && his.Insutype == "390" {
  21480. data["med_type"] = "110104"
  21481. } else {
  21482. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21483. }
  21484. data["doctor_id"] = doctor_info.DoctorNumber
  21485. data["doctor_name"] = roles.UserName
  21486. data["fixmedins_code"] = miConfig.Code
  21487. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21488. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21489. data["secret_key"] = miConfig.SecretKey
  21490. data["sick_code"] = sickConfig.CountryCode
  21491. data["sick_name"] = sickConfig.ClassName
  21492. data["begin_time"] = begin_time
  21493. data["dept"] = strconv.FormatInt(department.ID, 10)
  21494. data["config"] = config
  21495. data["opter"] = roles.UserName
  21496. fmt.Println(data)
  21497. bytesData, _ := json.Marshal(data)
  21498. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21499. resp, _ := client.Do(req)
  21500. defer resp.Body.Close()
  21501. body, ioErr := ioutil.ReadAll(resp.Body)
  21502. if ioErr != nil {
  21503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21505. return
  21506. }
  21507. var respJSON map[string]interface{}
  21508. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21511. return
  21512. }
  21513. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21514. userJSONBytes, _ := json.Marshal(respJSON)
  21515. fmt.Println("log")
  21516. fmt.Println(string(userJSONBytes))
  21517. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21518. utils.ErrorLog("解析失败:%v", err)
  21519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21520. return
  21521. }
  21522. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21523. data := make(map[string]interface{})
  21524. client := &http.Client{}
  21525. data["psn_no"] = his.PsnNo
  21526. data["mdtrt_id"] = his.Number
  21527. data["department"] = department.Name
  21528. data["org_name"] = miConfig.OrgName
  21529. if reg_type == 11 && his.Insutype == "390" {
  21530. data["med_type"] = "110104"
  21531. } else {
  21532. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21533. }
  21534. data["doctor_id"] = doctor_info.DoctorNumber
  21535. data["doctor_name"] = roles.UserName
  21536. data["fixmedins_code"] = miConfig.Code
  21537. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21538. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21539. data["secret_key"] = miConfig.SecretKey
  21540. data["sick_code"] = sickConfig.CountryCode
  21541. data["sick_name"] = sickConfig.ClassName
  21542. data["begin_time"] = begin_time
  21543. data["dept"] = strconv.FormatInt(department.ID, 10)
  21544. data["config"] = config
  21545. data["opter"] = roles.UserName
  21546. fmt.Println(data)
  21547. bytesData, _ := json.Marshal(data)
  21548. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21549. resp, _ := client.Do(req)
  21550. defer resp.Body.Close()
  21551. body, ioErr := ioutil.ReadAll(resp.Body)
  21552. if ioErr != nil {
  21553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21555. return
  21556. }
  21557. var respJSON map[string]interface{}
  21558. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21561. return
  21562. }
  21563. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21564. userJSONBytes, _ := json.Marshal(respJSON)
  21565. fmt.Println("log")
  21566. fmt.Println(string(userJSONBytes))
  21567. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21568. utils.ErrorLog("解析失败:%v", err)
  21569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21570. return
  21571. }
  21572. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21573. data := make(map[string]interface{})
  21574. client := &http.Client{}
  21575. data["psn_no"] = his.PsnNo
  21576. data["mdtrt_id"] = his.Number
  21577. data["department"] = department.Name
  21578. data["org_name"] = miConfig.OrgName
  21579. if reg_type == 11 && his.Insutype == "390" {
  21580. data["med_type"] = "110104"
  21581. } else {
  21582. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21583. }
  21584. data["doctor_id"] = doctor_info.DoctorNumber
  21585. data["doctor_name"] = roles.UserName
  21586. data["fixmedins_code"] = miConfig.Code
  21587. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21588. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21589. data["secret_key"] = miConfig.SecretKey
  21590. data["sick_code"] = sickConfig.CountryCode
  21591. data["sick_name"] = sickConfig.ClassName
  21592. data["begin_time"] = begin_time
  21593. data["dept"] = strconv.FormatInt(department.ID, 10)
  21594. data["config"] = config
  21595. data["opter"] = roles.UserName
  21596. fmt.Println(data)
  21597. bytesData, _ := json.Marshal(data)
  21598. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21599. resp, _ := client.Do(req)
  21600. defer resp.Body.Close()
  21601. body, ioErr := ioutil.ReadAll(resp.Body)
  21602. if ioErr != nil {
  21603. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21605. return
  21606. }
  21607. var respJSON map[string]interface{}
  21608. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21611. return
  21612. }
  21613. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21614. userJSONBytes, _ := json.Marshal(respJSON)
  21615. fmt.Println("log")
  21616. fmt.Println(string(userJSONBytes))
  21617. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21618. utils.ErrorLog("解析失败:%v", err)
  21619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21620. return
  21621. }
  21622. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21623. data := make(map[string]interface{})
  21624. client := &http.Client{}
  21625. data["psn_no"] = his.PsnNo
  21626. data["mdtrt_id"] = his.Number
  21627. data["doctor"] = roles.UserName
  21628. data["department"] = department.Name
  21629. data["org_name"] = miConfig.OrgName
  21630. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21631. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21632. data["fixmedins_code"] = miConfig.Code
  21633. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21634. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21635. data["secret_key"] = miConfig.SecretKey
  21636. data["sick_code"] = sickConfig.CountryCode
  21637. data["sick_name"] = sickConfig.ClassName
  21638. data["begin_time"] = begin_time
  21639. data["dept"] = strconv.FormatInt(department.ID, 10)
  21640. data["config"] = config
  21641. data["url"] = miConfig.Url
  21642. data["ak"] = miConfig.AccessKey
  21643. data["cainfo"] = miConfig.Cainfo
  21644. bytesData, _ := json.Marshal(data)
  21645. var req *http.Request
  21646. if miConfig.MdtrtareaAdmvs == "320921" {
  21647. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21648. } else {
  21649. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21650. }
  21651. resp, _ := client.Do(req)
  21652. defer resp.Body.Close()
  21653. body, ioErr := ioutil.ReadAll(resp.Body)
  21654. if ioErr != nil {
  21655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21657. return
  21658. }
  21659. var respJSON map[string]interface{}
  21660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21663. return
  21664. }
  21665. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21666. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21667. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21668. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21669. userJSONBytes, _ := json.Marshal(respJSON)
  21670. fmt.Println("log")
  21671. fmt.Println(string(userJSONBytes))
  21672. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21673. utils.ErrorLog("解析失败:%v", err)
  21674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21675. return
  21676. }
  21677. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21678. res2.Output = resSix10265.Output
  21679. res2.ErrMsg = resSix10265.ErrMsg
  21680. res2.Cainfo = resSix10265.Cainfo
  21681. res2.WarnMsg = resSix10265.WarnMsg
  21682. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21683. res2.Infcode = infocode
  21684. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21685. data := make(map[string]interface{})
  21686. client := &http.Client{}
  21687. data["psn_no"] = his.PsnNo
  21688. data["mdtrt_id"] = his.Number
  21689. data["doctor"] = roles.UserName
  21690. data["department"] = department.Name
  21691. data["org_name"] = miConfig.OrgName
  21692. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21693. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21694. data["fixmedins_code"] = miConfig.Code
  21695. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21696. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21697. data["secret_key"] = miConfig.SecretKey
  21698. data["sick_code"] = sickConfig.CountryCode
  21699. data["sick_name"] = sickConfig.ClassName
  21700. data["begin_time"] = begin_time
  21701. data["dept"] = strconv.FormatInt(department.ID, 10)
  21702. data["config"] = config
  21703. //data["url"] = miConfig.Url
  21704. //data["ak"] = miConfig.AccessKey
  21705. data["cainfo"] = miConfig.Cainfo
  21706. fmt.Println(data)
  21707. bytesData, _ := json.Marshal(data)
  21708. var req *http.Request
  21709. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  21710. resp, _ := client.Do(req)
  21711. defer resp.Body.Close()
  21712. body, ioErr := ioutil.ReadAll(resp.Body)
  21713. if ioErr != nil {
  21714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21716. return
  21717. }
  21718. var respJSON map[string]interface{}
  21719. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21722. return
  21723. }
  21724. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21725. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21726. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21727. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21728. userJSONBytes, _ := json.Marshal(respJSON)
  21729. fmt.Println("log")
  21730. fmt.Println(string(userJSONBytes))
  21731. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21732. utils.ErrorLog("解析失败:%v", err)
  21733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21734. return
  21735. }
  21736. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21737. res2.Output = resSix10265.Output
  21738. res2.ErrMsg = resSix10265.ErrMsg
  21739. res2.Cainfo = resSix10265.Cainfo
  21740. res2.WarnMsg = resSix10265.WarnMsg
  21741. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21742. res2.Infcode = infocode
  21743. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21744. result, requestLog, _ := service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  21745. saveLog(result, requestLog, "2203", "上传就诊信息")
  21746. var respJSON2 map[string]interface{}
  21747. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21750. return
  21751. }
  21752. userJSONBytes2, _ := json.Marshal(respJSON2)
  21753. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21754. utils.ErrorLog("解析失败:%v", err)
  21755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21756. return
  21757. }
  21758. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21759. var result string
  21760. var requestLog string
  21761. result, requestLog = service.Jxyb2203A(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, miConfig.Url, miConfig.AccessKey, "")
  21762. saveLog(result, requestLog, "2203", "上传就诊信息")
  21763. var respJSON2 map[string]interface{}
  21764. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21767. return
  21768. }
  21769. userJSONBytes2, _ := json.Marshal(respJSON2)
  21770. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21771. utils.ErrorLog("解析失败:%v", err)
  21772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21773. return
  21774. }
  21775. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21776. data := make(map[string]interface{})
  21777. client := &http.Client{}
  21778. data["psn_no"] = his.PsnNo
  21779. data["mdtrt_id"] = his.Number
  21780. data["operator"] = roles.UserName
  21781. data["department"] = department.Name
  21782. data["org_name"] = miConfig.OrgName
  21783. var med_type string
  21784. if his.Insutype == "390" {
  21785. if reg_type == 992102 {
  21786. med_type = "992102"
  21787. data["sick_code"] = "ZDZ940"
  21788. data["sick_name"] = "慢性肾衰竭"
  21789. }
  21790. if reg_type == 140104 {
  21791. med_type = "140104"
  21792. data["sick_code"] = sickConfig.CountryCode
  21793. data["sick_name"] = sickConfig.ClassName
  21794. }
  21795. if reg_type == 14 {
  21796. med_type = "140104"
  21797. data["sick_code"] = sickConfig.CountryCode
  21798. data["sick_name"] = sickConfig.ClassName
  21799. }
  21800. } else if his.Insutype == "310" {
  21801. if reg_type == 992102 {
  21802. med_type = "992102"
  21803. data["sick_code"] = "ZDZ940"
  21804. data["sick_name"] = "慢性肾衰竭"
  21805. }
  21806. if reg_type == 140104 {
  21807. med_type = "140104"
  21808. data["sick_code"] = sickConfig.CountryCode
  21809. data["sick_name"] = sickConfig.ClassName
  21810. }
  21811. if reg_type == 14 {
  21812. med_type = "14"
  21813. data["sick_code"] = sickConfig.CountryCode
  21814. data["sick_name"] = sickConfig.ClassName
  21815. }
  21816. }
  21817. data["med_type"] = med_type
  21818. data["doctor_number"] = doctor_info.DoctorNumber
  21819. data["doctor_name"] = doctor_info.UserName
  21820. data["fixmedins_code"] = miConfig.Code
  21821. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21822. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21823. data["secret_key"] = miConfig.SecretKey
  21824. data["begin_time"] = begin_time
  21825. data["dept"] = strconv.FormatInt(department.ID, 10)
  21826. data["config"] = config
  21827. data["url"] = miConfig.Url
  21828. data["ak"] = miConfig.AccessKey
  21829. data["cainfo"] = miConfig.Cainfo
  21830. bytesData, _ := json.Marshal(data)
  21831. var req *http.Request
  21832. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  21833. resp, _ := client.Do(req)
  21834. defer resp.Body.Close()
  21835. body, ioErr := ioutil.ReadAll(resp.Body)
  21836. if ioErr != nil {
  21837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21839. return
  21840. }
  21841. var respJSON map[string]interface{}
  21842. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21845. return
  21846. }
  21847. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21848. if status == "0" {
  21849. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21850. c.ServeSuccessJSON(map[string]interface{}{
  21851. "failed_code": -10,
  21852. "msg": err_msg,
  21853. })
  21854. return
  21855. }
  21856. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21857. userJSONBytes, _ := json.Marshal(respJSON)
  21858. fmt.Println("log")
  21859. fmt.Println(string(userJSONBytes))
  21860. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21861. utils.ErrorLog("解析失败:%v", err)
  21862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21863. return
  21864. }
  21865. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21866. var result string
  21867. var requestLog string
  21868. result, requestLog = service.Hnyb2203A(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, miConfig.Url, miConfig.AccessKey, "")
  21869. saveLog(result, requestLog, "2203", "上传就诊信息")
  21870. var respJSON2 map[string]interface{}
  21871. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21874. return
  21875. }
  21876. userJSONBytes2, _ := json.Marshal(respJSON2)
  21877. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21878. utils.ErrorLog("解析失败:%v", err)
  21879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21880. return
  21881. }
  21882. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21883. data := make(map[string]interface{})
  21884. client := &http.Client{}
  21885. data["psn_no"] = his.PsnNo
  21886. data["mdtrt_id"] = his.Number
  21887. data["doctor"] = roles.UserName
  21888. data["department"] = department.Name
  21889. data["org_name"] = miConfig.OrgName
  21890. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21891. data["doctor_id"] = doctor_info.DoctorNumber
  21892. data["fixmedins_code"] = miConfig.Code
  21893. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21894. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21895. data["secret_key"] = miConfig.SecretKey
  21896. data["sick_code"] = sickConfig.CountryCode
  21897. data["sick_name"] = sickConfig.ClassName
  21898. data["begin_time"] = begin_time
  21899. data["new_doctor_name"] = doctor_info.UserName
  21900. data["dept"] = strconv.FormatInt(department.ID, 10)
  21901. data["config"] = config
  21902. bytesData, _ := json.Marshal(data)
  21903. var req *http.Request
  21904. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  21905. resp, _ := client.Do(req)
  21906. defer resp.Body.Close()
  21907. body, ioErr := ioutil.ReadAll(resp.Body)
  21908. if ioErr != nil {
  21909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21911. return
  21912. }
  21913. var respJSON map[string]interface{}
  21914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21917. return
  21918. }
  21919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21920. userJSONBytes, _ := json.Marshal(respJSON)
  21921. fmt.Println("log")
  21922. fmt.Println(string(userJSONBytes))
  21923. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21924. utils.ErrorLog("解析失败:%v", err)
  21925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21926. return
  21927. }
  21928. } else {
  21929. var result string
  21930. var requestLog string
  21931. if miConfig.MdtrtareaAdmvs == "440781" { //
  21932. 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)
  21933. } else {
  21934. if miConfig.Code == "H15049901371" {
  21935. //赤峰地区国家医保医疗类别
  21936. //职工透析:医疗类别选特殊情况门诊990502
  21937. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21938. var med_type string
  21939. if his.Insutype == "390" {
  21940. if reg_type == 14 {
  21941. med_type = "9933"
  21942. } else if reg_type == 11 {
  21943. med_type = "11"
  21944. }
  21945. } else if his.Insutype == "310" {
  21946. if reg_type == 14 {
  21947. med_type = "990502"
  21948. } else if reg_type == 11 {
  21949. med_type = "11"
  21950. }
  21951. }
  21952. 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)
  21953. } else {
  21954. 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, doctor_info.UserName, admin_user_id, roles.UserName)
  21955. }
  21956. saveLog(result, requestLog, "2203", "上传就诊信息")
  21957. var respJSON2 map[string]interface{}
  21958. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21961. return
  21962. }
  21963. userJSONBytes2, _ := json.Marshal(respJSON2)
  21964. if miConfig.Code == "H15049901371" {
  21965. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  21966. utils.ErrorLog("解析失败:%v", err)
  21967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21968. return
  21969. }
  21970. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21971. res2.Output = resSix10265.Output
  21972. res2.ErrMsg = resSix10265.ErrMsg
  21973. res2.Cainfo = resSix10265.Cainfo
  21974. res2.WarnMsg = resSix10265.WarnMsg
  21975. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21976. res2.Infcode = infocode
  21977. } else {
  21978. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21979. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  21980. utils.ErrorLog("解析失败:%v", err)
  21981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21982. return
  21983. }
  21984. res2.Infcode = res3.Infcode
  21985. } else {
  21986. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21987. utils.ErrorLog("解析失败:%v", err)
  21988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21989. return
  21990. }
  21991. }
  21992. }
  21993. }
  21994. }
  21995. if res2.Infcode == -1 {
  21996. adminUser := c.GetAdminUserInfo()
  21997. errlog := &models.HisOrderError{
  21998. UserOrgId: adminUser.CurrentOrgId,
  21999. Ctime: time.Now().Unix(),
  22000. Mtime: time.Now().Unix(),
  22001. ErrMsg: res2.ErrMsg,
  22002. Status: 1,
  22003. PatientId: id,
  22004. RecordTime: recordDateTime,
  22005. Stage: 3,
  22006. }
  22007. service.CreateErrMsgLog(errlog)
  22008. c.ServeSuccessJSON(map[string]interface{}{
  22009. "failed_code": -10,
  22010. "msg": res2.ErrMsg,
  22011. })
  22012. return
  22013. }
  22014. if res2.Infcode != 0 {
  22015. adminUser := c.GetAdminUserInfo()
  22016. errlog := &models.HisOrderError{
  22017. UserOrgId: adminUser.CurrentOrgId,
  22018. Ctime: time.Now().Unix(),
  22019. Mtime: time.Now().Unix(),
  22020. ErrMsg: res2.ErrMsg,
  22021. Status: 1,
  22022. PatientId: id,
  22023. RecordTime: recordDateTime,
  22024. Stage: 3,
  22025. }
  22026. service.CreateErrMsgLog(errlog)
  22027. c.ServeSuccessJSON(map[string]interface{}{
  22028. "failed_code": -10,
  22029. "msg": res2.ErrMsg,
  22030. })
  22031. return
  22032. } else {
  22033. his.Diagnosis = diagnosis_id
  22034. his.SickType = sickConfig.ID
  22035. his.PType = fmt.Sprintf("%d", reg_type)
  22036. service.UpdateHisPatientThree(&his)
  22037. data := make(map[string]interface{})
  22038. if settle_accounts_type == 1 { //日结
  22039. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  22040. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  22041. } else {
  22042. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  22043. }
  22044. data["pre"] = prescriptions
  22045. } else { //月结
  22046. start_time_str := c.GetString("start_time")
  22047. end_time_str := c.GetString("end_time")
  22048. timeLayout := "2006-01-02"
  22049. loc, _ := time.LoadLocation("Local")
  22050. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  22051. if err != nil {
  22052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22053. return
  22054. }
  22055. recordStartTime := theStartTime.Unix()
  22056. start_time = recordStartTime
  22057. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  22058. if err != nil {
  22059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22060. return
  22061. }
  22062. recordEndTime := theEndTime.Unix()
  22063. end_time = recordEndTime
  22064. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  22065. data["pre"] = prescriptions
  22066. }
  22067. client := &http.Client{}
  22068. data["psn_no"] = his.PsnNo
  22069. data["mdtrt_id"] = his.Number
  22070. data["chrg_bchno"] = chrg_bchno
  22071. data["org_name"] = miConfig.OrgName
  22072. data["doctor"] = doctor_info.UserName
  22073. data["doctor_id"] = doctor_info.DoctorNumber
  22074. data["dept"] = department.Name
  22075. data["fixmedins_code"] = miConfig.Code
  22076. data["opter"] = roles.UserName
  22077. data["dept_code"] = department.Number
  22078. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22079. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22080. data["secret_key"] = miConfig.SecretKey
  22081. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  22082. data["url"] = miConfig.Url
  22083. data["ak"] = miConfig.AccessKey
  22084. data["new_doctor_name"] = patientPrescription.Doctor
  22085. if his.Insutype == "390" {
  22086. if reg_type == 992102 {
  22087. data["diag_code"] = "ZDZ940"
  22088. }
  22089. if reg_type == 140104 {
  22090. data["diag_code"] = sickConfig.CountryCode
  22091. }
  22092. if reg_type == 14 {
  22093. data["diag_code"] = sickConfig.CountryCode
  22094. }
  22095. } else if his.Insutype == "310" {
  22096. if reg_type == 992102 {
  22097. data["diag_code"] = "ZDZ940"
  22098. }
  22099. if reg_type == 14 {
  22100. data["diag_code"] = sickConfig.CountryCode
  22101. }
  22102. }
  22103. data["cainfo"] = miConfig.Cainfo
  22104. data["opter"] = roles.UserName
  22105. var ids []int64
  22106. for _, item := range prescriptions {
  22107. ids = append(ids, item.ID)
  22108. }
  22109. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22110. if config.IsOpen == 1 { //对接了医保,走医保流程
  22111. var res ResultFour
  22112. var resFour10265 ResultFour10265
  22113. if miConfig.MdtrtareaAdmvs == "421300" {
  22114. bytesData, _ := json.Marshal(data)
  22115. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  22116. resp, _ := client.Do(req)
  22117. defer resp.Body.Close()
  22118. body, ioErr := ioutil.ReadAll(resp.Body)
  22119. if ioErr != nil {
  22120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22122. return
  22123. }
  22124. var respJSON map[string]interface{}
  22125. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22128. return
  22129. }
  22130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22131. userJSONBytes, _ := json.Marshal(respJSON)
  22132. fmt.Println("log")
  22133. fmt.Println(string(userJSONBytes))
  22134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22135. utils.ErrorLog("解析失败:%v", err)
  22136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22137. return
  22138. }
  22139. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22140. bytesData, _ := json.Marshal(data)
  22141. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  22142. resp, _ := client.Do(req)
  22143. defer resp.Body.Close()
  22144. body, ioErr := ioutil.ReadAll(resp.Body)
  22145. if ioErr != nil {
  22146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22148. return
  22149. }
  22150. var respJSON map[string]interface{}
  22151. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22154. return
  22155. }
  22156. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22157. userJSONBytes, _ := json.Marshal(respJSON)
  22158. fmt.Println("log")
  22159. fmt.Println(string(userJSONBytes))
  22160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22161. utils.ErrorLog("解析失败:%v", err)
  22162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22163. return
  22164. }
  22165. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22166. bytesData, _ := json.Marshal(data)
  22167. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22168. resp, _ := client.Do(req)
  22169. defer resp.Body.Close()
  22170. body, ioErr := ioutil.ReadAll(resp.Body)
  22171. if ioErr != nil {
  22172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22174. return
  22175. }
  22176. var respJSON map[string]interface{}
  22177. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22180. return
  22181. }
  22182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22183. userJSONBytes, _ := json.Marshal(respJSON)
  22184. fmt.Println("log")
  22185. fmt.Println(string(userJSONBytes))
  22186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22187. utils.ErrorLog("解析失败:%v", err)
  22188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22189. return
  22190. }
  22191. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22192. bytesData, _ := json.Marshal(data)
  22193. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22194. resp, _ := client.Do(req)
  22195. defer resp.Body.Close()
  22196. body, ioErr := ioutil.ReadAll(resp.Body)
  22197. if ioErr != nil {
  22198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22200. return
  22201. }
  22202. var respJSON map[string]interface{}
  22203. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22206. return
  22207. }
  22208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22209. userJSONBytes, _ := json.Marshal(respJSON)
  22210. fmt.Println("log")
  22211. fmt.Println(string(userJSONBytes))
  22212. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22213. utils.ErrorLog("解析失败:%v", err)
  22214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22215. return
  22216. }
  22217. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22218. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22219. if result3101.Infcode == "0" {
  22220. if len(result3101.Output.Result) > 0 {
  22221. var errMsgs []string
  22222. for _, item := range result3101.Output.Result {
  22223. errMsgs = append(errMsgs, item.VolaCont)
  22224. }
  22225. c.ServeSuccessJSON(map[string]interface{}{
  22226. "failed_code": -10,
  22227. "msg": errMsgs,
  22228. })
  22229. return
  22230. } else {
  22231. if miConfig.MdtrtareaAdmvs == "320921" {
  22232. data["doctor_id"] = "D320923012139"
  22233. } else {
  22234. data["doctor_id"] = "D371621008686"
  22235. }
  22236. bytesData, _ := json.Marshal(data)
  22237. var req *http.Request
  22238. if miConfig.MdtrtareaAdmvs == "320921" {
  22239. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22240. } else {
  22241. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22242. }
  22243. resp, _ := client.Do(req)
  22244. defer resp.Body.Close()
  22245. body, ioErr := ioutil.ReadAll(resp.Body)
  22246. if ioErr != nil {
  22247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22249. return
  22250. }
  22251. var respJSON map[string]interface{}
  22252. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22255. return
  22256. }
  22257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22258. userJSONBytes, _ := json.Marshal(respJSON)
  22259. fmt.Println("log")
  22260. fmt.Println(string(userJSONBytes))
  22261. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22262. utils.ErrorLog("解析失败:%v", err)
  22263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22264. return
  22265. }
  22266. res.InfRefmsgid = resFour10265.InfRefmsgid
  22267. res.Output = resFour10265.Output
  22268. res.ErrMsg = resFour10265.ErrMsg
  22269. res.Cainfo = resFour10265.Cainfo
  22270. res.WarnMsg = resFour10265.WarnMsg
  22271. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22272. res.Infcode = infocode
  22273. }
  22274. }
  22275. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22276. var pagesize int = 5
  22277. var start int = 1
  22278. var stop int
  22279. var pagecount int
  22280. var curpage int
  22281. data["doctor_id"] = doctor_info.DoctorNumber
  22282. var res2 ResultFour
  22283. //var result res.
  22284. //总页数,向上取整,注意除之前要先转换类型为float64
  22285. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  22286. for curpage = 1; curpage <= pagecount; curpage++ {
  22287. if curpage == 1 {
  22288. start = 1
  22289. } else {
  22290. start = (curpage-1)*pagesize + 1
  22291. }
  22292. stop = curpage * pagesize
  22293. if stop > len(prescriptions) {
  22294. stop = len(prescriptions)
  22295. }
  22296. //var requestLog string
  22297. data["pre"] = prescriptions[start-1 : stop]
  22298. fmt.Println(data["pre"])
  22299. bytesData, _ := json.Marshal(data)
  22300. var req *http.Request
  22301. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  22302. resp, _ := client.Do(req)
  22303. defer resp.Body.Close()
  22304. body, ioErr := ioutil.ReadAll(resp.Body)
  22305. if ioErr != nil {
  22306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22308. return
  22309. }
  22310. var respJSON map[string]interface{}
  22311. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22314. return
  22315. }
  22316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22317. userJSONBytes, _ := json.Marshal(respJSON)
  22318. fmt.Println("log")
  22319. fmt.Println(string(userJSONBytes))
  22320. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22321. utils.ErrorLog("解析失败:%v", err)
  22322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22323. return
  22324. }
  22325. res.InfRefmsgid = resFour10265.InfRefmsgid
  22326. res.Output = resFour10265.Output
  22327. res.ErrMsg = resFour10265.ErrMsg
  22328. res.Cainfo = resFour10265.Cainfo
  22329. res.WarnMsg = resFour10265.WarnMsg
  22330. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22331. res.Infcode = infocode
  22332. if infocode == 0 {
  22333. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  22334. } else {
  22335. isSuccess = false
  22336. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  22337. res.Infcode = -1
  22338. res.ErrMsg = resFour10265.ErrMsg
  22339. errlog := &models.HisOrderError{
  22340. UserOrgId: adminUser.CurrentOrgId,
  22341. Ctime: time.Now().Unix(),
  22342. Mtime: time.Now().Unix(),
  22343. Number: chrg_bchno,
  22344. ErrMsg: "",
  22345. Status: 1,
  22346. PatientId: id,
  22347. RecordTime: recordDateTime,
  22348. Stage: 4,
  22349. }
  22350. service.CreateErrMsgLog(errlog)
  22351. }
  22352. }
  22353. if isSuccess {
  22354. res.Infcode = 0
  22355. res.Output.Result = res2.Output.Result
  22356. } else {
  22357. order := &models.HisOrder{
  22358. UserOrgId: adminUser.CurrentOrgId,
  22359. HisPatientId: his.ID,
  22360. PatientId: his.PatientId,
  22361. SettleAccountsDate: recordDateTime,
  22362. Ctime: time.Now().Unix(),
  22363. Mtime: time.Now().Unix(),
  22364. MdtrtId: his.Number,
  22365. PsnNo: his.PsnNo,
  22366. MedType: strconv.FormatInt(reg_type, 10),
  22367. Status: 1,
  22368. Number: chrg_bchno,
  22369. Infcode: res.Infcode,
  22370. WarnMsg: res.WarnMsg,
  22371. Cainfo: res.Cainfo,
  22372. ErrMsg: res.ErrMsg,
  22373. RespondTime: res.RefmsgTime,
  22374. InfRefmsgid: res.InfRefmsgid,
  22375. OrderStatus: 1,
  22376. IsMedicineInsurance: 1,
  22377. SettleType: settle_accounts_type,
  22378. SettleStartTime: start_time,
  22379. SettleEndTime: end_time,
  22380. Creator: roles.AdminUserId,
  22381. Modify: roles.AdminUserId,
  22382. PType: 2,
  22383. Diagnosis: diagnosis_id,
  22384. }
  22385. err = service.CreateOrder(order)
  22386. if err != nil {
  22387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22388. return
  22389. }
  22390. c.ServeSuccessJSON(map[string]interface{}{
  22391. "failed_code": -10,
  22392. "msg": res2.ErrMsg,
  22393. })
  22394. return
  22395. }
  22396. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22397. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  22398. var dat map[string]interface{}
  22399. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22400. fmt.Println(dat)
  22401. } else {
  22402. fmt.Println(err)
  22403. }
  22404. saveLog(result, request_log, "2204", "上传费用明细")
  22405. userJSONBytes, _ := json.Marshal(dat)
  22406. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22407. utils.ErrorLog("解析失败:%v", err)
  22408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22409. return
  22410. }
  22411. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22412. result, request_log := service.Jxyb2204(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), sickConfig.CountryCode, miConfig.Url, miConfig.AccessKey, doctor_info.UserName, "", "")
  22413. var dat map[string]interface{}
  22414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22415. fmt.Println(dat)
  22416. } else {
  22417. fmt.Println(err)
  22418. }
  22419. saveLog(result, request_log, "2204", "上传费用明细")
  22420. userJSONBytes, _ := json.Marshal(dat)
  22421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22422. utils.ErrorLog("解析失败:%v", err)
  22423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22424. return
  22425. }
  22426. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22427. bytesData, _ := json.Marshal(data)
  22428. var req *http.Request
  22429. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  22430. resp, _ := client.Do(req)
  22431. defer resp.Body.Close()
  22432. body, ioErr := ioutil.ReadAll(resp.Body)
  22433. if ioErr != nil {
  22434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22436. return
  22437. }
  22438. var respJSON map[string]interface{}
  22439. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22442. return
  22443. }
  22444. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22445. if status == "0" {
  22446. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22447. c.ServeSuccessJSON(map[string]interface{}{
  22448. "failed_code": -10,
  22449. "msg": err_msg,
  22450. })
  22451. return
  22452. }
  22453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22454. userJSONBytes, _ := json.Marshal(respJSON)
  22455. fmt.Println("log")
  22456. fmt.Println(string(userJSONBytes))
  22457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22458. utils.ErrorLog("解析失败:%v", err)
  22459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22460. return
  22461. }
  22462. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22463. result, request_log := service.Hnyb2204(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), sickConfig.CountryCode, miConfig.Url, miConfig.AccessKey, doctor_info.UserName, "", "")
  22464. var dat map[string]interface{}
  22465. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22466. fmt.Println(dat)
  22467. } else {
  22468. fmt.Println(err)
  22469. }
  22470. saveLog(result, request_log, "2204", "上传费用明细")
  22471. userJSONBytes, _ := json.Marshal(dat)
  22472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22473. utils.ErrorLog("解析失败:%v", err)
  22474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22475. return
  22476. }
  22477. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22478. bytesData, _ := json.Marshal(data)
  22479. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  22480. resp, _ := client.Do(req)
  22481. defer resp.Body.Close()
  22482. body, ioErr := ioutil.ReadAll(resp.Body)
  22483. if ioErr != nil {
  22484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22486. return
  22487. }
  22488. var respJSON map[string]interface{}
  22489. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22492. return
  22493. }
  22494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22495. userJSONBytes, _ := json.Marshal(respJSON)
  22496. fmt.Println("log")
  22497. fmt.Println(string(userJSONBytes))
  22498. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22499. utils.ErrorLog("解析失败:%v", err)
  22500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22501. return
  22502. }
  22503. } else {
  22504. if miConfig.MdtrtareaAdmvs == "441202" {
  22505. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22506. if result3101.Infcode == 0 {
  22507. if len(result3101.Output.Result) > 0 {
  22508. var errMsgs []string
  22509. for _, item := range result3101.Output.Result {
  22510. errMsgs = append(errMsgs, item.VolaCont)
  22511. }
  22512. c.ServeSuccessJSON(map[string]interface{}{
  22513. "failed_code": -10,
  22514. "msg": errMsgs,
  22515. })
  22516. return
  22517. } else {
  22518. 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, admin_user_id)
  22519. var dat map[string]interface{}
  22520. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22521. fmt.Println(dat)
  22522. } else {
  22523. fmt.Println(err)
  22524. }
  22525. saveLog(result, request_log, "2204", "上传费用明细")
  22526. userJSONBytes, _ := json.Marshal(dat)
  22527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22528. utils.ErrorLog("解析失败:%v", err)
  22529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22530. return
  22531. }
  22532. }
  22533. } else {
  22534. c.ServeSuccessJSON(map[string]interface{}{
  22535. "failed_code": -10,
  22536. "msg": result3101.ErrMsg,
  22537. })
  22538. return
  22539. }
  22540. } else {
  22541. if miConfig.Code == "H15049901371" {
  22542. 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, admin_user_id)
  22543. var dat map[string]interface{}
  22544. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22545. fmt.Println(dat)
  22546. } else {
  22547. fmt.Println(err)
  22548. }
  22549. saveLog(result, request_log, "2204", "上传费用明细")
  22550. userJSONBytes, _ := json.Marshal(dat)
  22551. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22552. utils.ErrorLog("解析失败:%v", err)
  22553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22554. return
  22555. }
  22556. res.InfRefmsgid = resFour10265.InfRefmsgid
  22557. res.Output = resFour10265.Output
  22558. res.ErrMsg = resFour10265.ErrMsg
  22559. res.Cainfo = resFour10265.Cainfo
  22560. res.WarnMsg = resFour10265.WarnMsg
  22561. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22562. res.Infcode = infocode
  22563. } else {
  22564. 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, admin_user_id)
  22565. var dat map[string]interface{}
  22566. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22567. fmt.Println(dat)
  22568. } else {
  22569. fmt.Println(err)
  22570. }
  22571. saveLog(result, request_log, "2204", "上传费用明细")
  22572. userJSONBytes, _ := json.Marshal(dat)
  22573. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22574. utils.ErrorLog("解析失败:%v", err)
  22575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22576. return
  22577. }
  22578. }
  22579. }
  22580. }
  22581. var total_two float64
  22582. if res.Infcode == 0 {
  22583. order := &models.HisOrder{
  22584. UserOrgId: adminUser.CurrentOrgId,
  22585. HisPatientId: his.ID,
  22586. PatientId: his.PatientId,
  22587. SettleAccountsDate: recordDateTime,
  22588. Ctime: time.Now().Unix(),
  22589. Mtime: time.Now().Unix(),
  22590. MdtrtId: his.Number,
  22591. PsnNo: his.PsnNo,
  22592. MedType: strconv.FormatInt(reg_type, 10),
  22593. Status: 1,
  22594. Number: chrg_bchno,
  22595. Infcode: res.Infcode,
  22596. WarnMsg: res.WarnMsg,
  22597. Cainfo: res.Cainfo,
  22598. ErrMsg: res.ErrMsg,
  22599. RespondTime: res.RefmsgTime,
  22600. InfRefmsgid: res.InfRefmsgid,
  22601. OrderStatus: 1,
  22602. IsMedicineInsurance: 1,
  22603. SettleType: settle_accounts_type,
  22604. SettleStartTime: start_time,
  22605. SettleEndTime: end_time,
  22606. Creator: roles.AdminUserId,
  22607. Modify: roles.AdminUserId,
  22608. PType: 2,
  22609. Diagnosis: diagnosis_id,
  22610. }
  22611. err = service.CreateOrder(order)
  22612. if err != nil {
  22613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22614. return
  22615. }
  22616. for _, item := range res.Output.Result {
  22617. temp := strings.Split(item.FeedetlSn, "-")
  22618. var advice_id int64 = 0
  22619. var project_id int64 = 0
  22620. var types int64 = 0
  22621. id, _ := strconv.ParseInt(temp[2], 10, 64)
  22622. types, _ = strconv.ParseInt(temp[1], 10, 64)
  22623. if temp[1] == "1" {
  22624. advice_id = id
  22625. project_id = 0
  22626. } else if temp[1] == "2" {
  22627. advice_id = 0
  22628. project_id = id
  22629. }
  22630. total_two = total_two + item.DetItemFeeSumamt
  22631. info := &models.HisOrderInfo{
  22632. OrderNumber: order.Number,
  22633. FeedetlSn: item.FeedetlSn,
  22634. UploadDate: time.Now().Unix(),
  22635. AdviceId: advice_id,
  22636. DetItemFeeSumamt: item.DetItemFeeSumamt,
  22637. Cnt: item.Cnt,
  22638. Pric: float64(item.Pric),
  22639. PatientId: his.PatientId,
  22640. PricUplmtAmt: item.PricUplmtAmt,
  22641. SelfpayProp: item.SelfpayProp,
  22642. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  22643. OverlmtAmt: item.OverlmtAmt,
  22644. PreselfpayAmt: item.PreselfpayAmt,
  22645. BasMednFlag: item.BasMednFlag,
  22646. MedChrgitmType: item.MedChrgitmType,
  22647. HiNegoDrugFlag: item.HiNegoDrugFlag,
  22648. Status: 1,
  22649. Memo: item.Memo,
  22650. Mtime: time.Now().Unix(),
  22651. InscpScpAmt: item.InscpScpAmt,
  22652. DrtReimFlag: item.DrtReimFlag,
  22653. Ctime: time.Now().Unix(),
  22654. ListSpItemFlag: item.ListSpItemFlag,
  22655. ChldMedcFlag: item.ChldMedcFlag,
  22656. LmtUsedFlag: item.LmtUsedFlag,
  22657. ChrgitmLv: item.ChrgitmLv,
  22658. UserOrgId: adminUser.CurrentOrgId,
  22659. HisPatientId: his.ID,
  22660. OrderId: order.ID,
  22661. ProjectId: project_id,
  22662. Type: types,
  22663. }
  22664. service.CreateOrderInfo(info)
  22665. }
  22666. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  22667. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  22668. var total float64
  22669. for _, item := range prescriptions {
  22670. if item.Type == 1 { //药品
  22671. for _, subItem := range item.HisDoctorAdviceInfo {
  22672. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22673. total_one := price * subItem.PrescribingNumber
  22674. fmt.Println("subItem")
  22675. fmt.Println(subItem.Price)
  22676. fmt.Println("price")
  22677. fmt.Println(price)
  22678. fmt.Println("total_one")
  22679. fmt.Println(total_one)
  22680. total = total + total_one
  22681. fmt.Println(total)
  22682. }
  22683. }
  22684. if item.Type == 2 { //项目
  22685. for _, subItem := range item.HisPrescriptionProject {
  22686. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  22687. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22688. total_one := price * cnt
  22689. total = total + total_one
  22690. }
  22691. }
  22692. }
  22693. allTotal := fmt.Sprintf("%.2f", total)
  22694. if res.Infcode == 0 {
  22695. var rf []*ResultFive
  22696. json.Unmarshal([]byte(his.Iinfo), &rf)
  22697. chrg_bchno := chrg_bchno
  22698. cert_no := his.Certno
  22699. var insutypes []string
  22700. var insutype string
  22701. var is390 int = 0
  22702. var is310 int = 0
  22703. for _, item := range rf {
  22704. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22705. insutypes = append(insutypes, item.Insutype)
  22706. }
  22707. }
  22708. if len(insutypes) == 1 {
  22709. insutype = insutypes[0]
  22710. } else {
  22711. for _, i := range insutypes {
  22712. if i == "390" {
  22713. is390 = 1
  22714. }
  22715. if i == "310" {
  22716. is310 = 1
  22717. }
  22718. }
  22719. }
  22720. if is390 == 1 {
  22721. insutype = "390"
  22722. }
  22723. if is310 == 1 {
  22724. insutype = "310"
  22725. }
  22726. if len(insutypes) == 0 {
  22727. insutype = "390"
  22728. }
  22729. if len(insutypes) == 2 {
  22730. insutype = strconv.FormatInt(his.SocialType, 10)
  22731. }
  22732. //insutype = "390"
  22733. if his.IdCardType == 1 {
  22734. cert_no = his.MedicalInsuranceNumber
  22735. } else {
  22736. cert_no = his.Certno
  22737. }
  22738. var res ResultSeven
  22739. var ahres ResultSevenAH
  22740. var resSeven10265 ResultSeven10265
  22741. var resSeven10265Two ResultSeven10265Two
  22742. var gzresSeven10265Two GZResultSeven10265Two
  22743. if miConfig.MdtrtareaAdmvs == "421300" {
  22744. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  22745. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22746. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22747. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22748. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22749. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22750. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22751. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22752. resp, requestErr := http.Get(api)
  22753. if requestErr != nil {
  22754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22755. return
  22756. }
  22757. body, ioErr := ioutil.ReadAll(resp.Body)
  22758. if ioErr != nil {
  22759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22761. return
  22762. }
  22763. var respJSON map[string]interface{}
  22764. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22767. return
  22768. }
  22769. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22770. result, _ := json.Marshal(respJSON)
  22771. fmt.Println("log")
  22772. fmt.Println(string(result))
  22773. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22774. utils.ErrorLog("解析失败:%v", err)
  22775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22776. return
  22777. }
  22778. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22779. if reg_type == 11 && his.Insutype == "390" {
  22780. reg_type = 110104
  22781. }
  22782. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22783. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22784. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22785. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22786. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22787. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22788. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22789. resp, requestErr := http.Get(api)
  22790. if requestErr != nil {
  22791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22792. return
  22793. }
  22794. body, ioErr := ioutil.ReadAll(resp.Body)
  22795. if ioErr != nil {
  22796. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22798. return
  22799. }
  22800. var respJSON map[string]interface{}
  22801. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22804. return
  22805. }
  22806. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22807. result, _ := json.Marshal(respJSON)
  22808. fmt.Println("log")
  22809. fmt.Println(string(result))
  22810. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22811. utils.ErrorLog("解析失败:%v", err)
  22812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22813. return
  22814. }
  22815. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22816. if reg_type == 11 && his.Insutype == "390" {
  22817. reg_type = 110104
  22818. }
  22819. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22820. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22821. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22822. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22823. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22824. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22825. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22826. resp, requestErr := http.Get(api)
  22827. if requestErr != nil {
  22828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22829. return
  22830. }
  22831. body, ioErr := ioutil.ReadAll(resp.Body)
  22832. if ioErr != nil {
  22833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22835. return
  22836. }
  22837. var respJSON map[string]interface{}
  22838. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22841. return
  22842. }
  22843. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22844. result, _ := json.Marshal(respJSON)
  22845. fmt.Println("log")
  22846. fmt.Println(string(result))
  22847. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22848. utils.ErrorLog("解析失败:%v", err)
  22849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22850. return
  22851. }
  22852. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22853. if reg_type == 11 && his.Insutype == "390" {
  22854. reg_type = 110104
  22855. }
  22856. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22857. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22858. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22859. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22860. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22861. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22862. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22863. resp, requestErr := http.Get(api)
  22864. if requestErr != nil {
  22865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22866. return
  22867. }
  22868. body, ioErr := ioutil.ReadAll(resp.Body)
  22869. if ioErr != nil {
  22870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22872. return
  22873. }
  22874. var respJSON map[string]interface{}
  22875. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22878. return
  22879. }
  22880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22881. result, _ := json.Marshal(respJSON)
  22882. fmt.Println("log")
  22883. fmt.Println(string(result))
  22884. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22885. utils.ErrorLog("解析失败:%v", err)
  22886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22887. return
  22888. }
  22889. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22890. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  22891. if result3101.Infcode == "0" {
  22892. if len(result3101.Output.Result) > 0 {
  22893. var errMsgs []string
  22894. for _, item := range result3101.Output.Result {
  22895. errMsgs = append(errMsgs, item.VolaCont)
  22896. }
  22897. c.ServeSuccessJSON(map[string]interface{}{
  22898. "failed_code": -10,
  22899. "msg": errMsgs,
  22900. })
  22901. return
  22902. } else {
  22903. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22904. if his.IdCardType != 4 {
  22905. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22906. bas := strings.Split(psn_info.CardInfo, "|")
  22907. if his.IdCardType == 1 {
  22908. cert_no = bas[2]
  22909. } else {
  22910. cert_no = bas[1]
  22911. }
  22912. } else {
  22913. cert_no = his.Certno
  22914. }
  22915. //江苏地区国家医保医疗类别
  22916. //职工透析:医疗类别选特殊情况门诊9933
  22917. //居民血透门慢: 医疗类别选门诊慢病1402
  22918. //var med_type string
  22919. //if his.Insutype == "310" {
  22920. // if reg_type == 14 {
  22921. // med_type = "9933"
  22922. // } else if reg_type == 11 {
  22923. // med_type = "11"
  22924. //
  22925. // }
  22926. //} else if his.Insutype == "390" {
  22927. // if reg_type == 14 {
  22928. // med_type = "1402"
  22929. // } else if reg_type == 11 {
  22930. // med_type = "11"
  22931. // }
  22932. //}
  22933. var api string
  22934. if miConfig.MdtrtareaAdmvs == "320921" {
  22935. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22936. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22937. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22938. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22939. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22940. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22941. "&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 + "&mdtrt_grp_type=" + his.MdtrtGrpType
  22942. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22943. } else {
  22944. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22945. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22946. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22947. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22948. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22949. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22950. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22951. "&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 + "&mdtrt_grp_type=" + his.MdtrtGrpType
  22952. }
  22953. resp, requestErr := http.Get(api)
  22954. if requestErr != nil {
  22955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22956. return
  22957. }
  22958. body, ioErr := ioutil.ReadAll(resp.Body)
  22959. if ioErr != nil {
  22960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22962. return
  22963. }
  22964. var respJSON map[string]interface{}
  22965. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22968. return
  22969. }
  22970. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22971. result, _ := json.Marshal(respJSON)
  22972. fmt.Println("log")
  22973. fmt.Println(string(result))
  22974. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  22975. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22976. utils.ErrorLog("解析失败:%v", err)
  22977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22978. return
  22979. }
  22980. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22981. res.Output = resSeven10265.Output
  22982. res.ErrMsg = resSeven10265.ErrMsg
  22983. res.Cainfo = resSeven10265.Cainfo
  22984. res.WarnMsg = resSeven10265.WarnMsg
  22985. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22986. res.Infcode = infocode
  22987. } else {
  22988. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  22989. utils.ErrorLog("解析失败:%v", err)
  22990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22991. return
  22992. }
  22993. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  22994. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  22995. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  22996. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  22997. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22998. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  22999. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  23000. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  23001. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  23002. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  23003. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  23004. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23005. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  23006. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  23007. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  23008. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23009. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  23010. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  23011. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  23012. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  23013. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  23014. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23015. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  23016. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  23017. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  23018. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  23019. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  23020. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  23021. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  23022. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  23023. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23024. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  23025. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  23026. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  23027. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23028. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23029. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23030. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23031. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  23032. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23033. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  23034. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  23035. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  23036. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  23037. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  23038. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  23039. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  23040. res.ErrMsg = resSeven10265Two.ErrMsg
  23041. res.Cainfo = resSeven10265Two.Cainfo
  23042. res.WarnMsg = resSeven10265Two.WarnMsg
  23043. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23044. res.Infcode = infocode
  23045. }
  23046. }
  23047. }
  23048. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23049. psn_info, _ := service.GetPsnByPatientId(id)
  23050. var verify_number string
  23051. if psn_info.IdCardType == 4 {
  23052. verify_number = psn_info.VerifyNumber
  23053. } else if psn_info.IdCardType == 1 {
  23054. bas := strings.Split(psn_info.CardInfo, "|")
  23055. cardNumber := bas[2]
  23056. verify_number = cardNumber
  23057. } else {
  23058. psn_info.IdCardType = 2
  23059. verify_number = psn_info.Certno
  23060. }
  23061. var api string
  23062. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23063. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23064. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23065. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23066. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  23067. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23068. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + verify_number + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  23069. resp, requestErr := http.Get(api)
  23070. if requestErr != nil {
  23071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23072. return
  23073. }
  23074. body, ioErr := ioutil.ReadAll(resp.Body)
  23075. if ioErr != nil {
  23076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23078. return
  23079. }
  23080. var respJSON map[string]interface{}
  23081. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23084. return
  23085. }
  23086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23087. result, _ := json.Marshal(respJSON)
  23088. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23089. utils.ErrorLog("解析失败:%v", err)
  23090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23091. return
  23092. }
  23093. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23094. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  23095. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  23096. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  23097. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  23098. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  23099. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  23100. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  23101. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  23102. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  23103. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  23104. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  23105. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  23106. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  23107. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  23108. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  23109. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  23110. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  23111. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  23112. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  23113. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23114. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  23115. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  23116. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  23117. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  23118. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  23119. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  23120. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  23121. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  23122. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  23123. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  23124. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  23125. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  23126. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  23127. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23128. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  23129. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  23130. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  23131. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  23132. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  23133. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  23134. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  23135. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  23136. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  23137. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  23138. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  23139. res.ErrMsg = resSeven10265.ErrMsg
  23140. res.Cainfo = resSeven10265.Cainfo
  23141. res.WarnMsg = resSeven10265.WarnMsg
  23142. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23143. res.Infcode = infocode
  23144. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23145. acct_used_flag := "1"
  23146. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  23147. var result string
  23148. var request_log string
  23149. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  23150. result, request_log, _ = service.FJyb2206ForToken(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, acct_used_flag)
  23151. } else {
  23152. result, request_log, _ = service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, acct_used_flag)
  23153. }
  23154. var dat map[string]interface{}
  23155. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23156. fmt.Println(dat)
  23157. } else {
  23158. fmt.Println(err)
  23159. }
  23160. saveLog(result, request_log, "2206", "预结算")
  23161. userJSONBytes, _ := json.Marshal(dat)
  23162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23163. utils.ErrorLog("解析失败:%v", err)
  23164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23165. return
  23166. }
  23167. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23168. var result string
  23169. var request_log string
  23170. if his.IdCardType == 2 {
  23171. result, request_log = service.Jxyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "")
  23172. } else if his.IdCardType == 1 {
  23173. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23174. bas := strings.Split(psn_info.CardInfo, "|")
  23175. basNumber := bas[2]
  23176. card_sn := bas[3]
  23177. var rf []*ResultFive
  23178. json.Unmarshal([]byte(his.Iinfo), &rf)
  23179. var psn_type string
  23180. for _, item := range rf {
  23181. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  23182. psn_type = item.PsnType
  23183. }
  23184. }
  23185. result, request_log = service.Jxyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, his.PsnCertType, his.Certno, psn_type, his.PsnName)
  23186. } else {
  23187. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23188. result, request_log = service.Jxyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "")
  23189. }
  23190. var dat map[string]interface{}
  23191. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23192. fmt.Println(dat)
  23193. } else {
  23194. fmt.Println(err)
  23195. }
  23196. saveLog(result, request_log, "2206", "预结算")
  23197. userJSONBytes, _ := json.Marshal(dat)
  23198. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23199. utils.ErrorLog("解析失败:%v", err)
  23200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23201. return
  23202. }
  23203. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23204. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23205. if his.IdCardType == 4 {
  23206. psn_info.VerifyNumber = psn_info.VerifyNumber
  23207. cert_no = psn_info.Certno
  23208. } else if his.IdCardType == 2 {
  23209. cert_no = psn_info.Certno
  23210. psn_info.VerifyNumber = psn_info.Certno
  23211. } else {
  23212. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23213. bas := strings.Split(psn_info.CardInfo, "|")
  23214. if his.IdCardType == 1 {
  23215. cert_no = bas[2]
  23216. } else {
  23217. cert_no = bas[1]
  23218. }
  23219. }
  23220. var api string
  23221. var med_type string
  23222. if his.Insutype == "390" {
  23223. if reg_type == 992102 {
  23224. med_type = "992102"
  23225. }
  23226. if reg_type == 140104 {
  23227. med_type = "140104"
  23228. }
  23229. if reg_type == 14 {
  23230. med_type = "140104"
  23231. }
  23232. } else if his.Insutype == "310" {
  23233. if reg_type == 992102 {
  23234. med_type = "992102"
  23235. }
  23236. if reg_type == 14 {
  23237. med_type = "14"
  23238. }
  23239. }
  23240. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23241. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23242. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23243. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23244. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23245. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23246. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + med_type + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  23247. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23248. resp, requestErr := http.Get(api)
  23249. if requestErr != nil {
  23250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23251. return
  23252. }
  23253. body, ioErr := ioutil.ReadAll(resp.Body)
  23254. if ioErr != nil {
  23255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23257. return
  23258. }
  23259. var respJSON map[string]interface{}
  23260. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23263. return
  23264. }
  23265. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23266. if status == "0" {
  23267. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23268. c.ServeSuccessJSON(map[string]interface{}{
  23269. "failed_code": -10,
  23270. "msg": err_msg,
  23271. })
  23272. return
  23273. }
  23274. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23275. result, _ := json.Marshal(respJSON)
  23276. fmt.Println("log")
  23277. fmt.Println(string(result))
  23278. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  23279. utils.ErrorLog("解析失败:%v", err)
  23280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23281. return
  23282. }
  23283. res.InfRefmsgid = ahres.InfRefmsgid
  23284. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23285. // 创建对应的Time类型
  23286. t := time.UnixMilli(timestamp)
  23287. // 格式化成指定的日期字符串
  23288. str := t.Format("2006-01-02 15:04:05")
  23289. res.Output.Setlinfo.SetlTime = str
  23290. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23291. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23292. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23293. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23294. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23295. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23296. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23297. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23298. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23299. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23300. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23301. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23302. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23303. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23304. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23305. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23306. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23307. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23308. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23309. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23310. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23311. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23312. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23313. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23314. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23315. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23316. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23317. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23318. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23319. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23320. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23321. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23322. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23323. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  23324. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23325. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  23326. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  23327. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  23328. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  23329. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23330. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  23331. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23332. //res.Output.Setldetail = ahres.Output.Setldetail
  23333. res.ErrMsg = ahres.ErrMsg
  23334. res.Cainfo = ahres.Cainfo
  23335. res.WarnMsg = ahres.WarnMsg
  23336. res.Infcode = ahres.Infcode
  23337. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23338. var result string
  23339. var request_log string
  23340. if his.IdCardType == 2 {
  23341. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "", "1")
  23342. } else if his.IdCardType == 1 {
  23343. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23344. bas := strings.Split(psn_info.CardInfo, "|")
  23345. basNumber := bas[2]
  23346. card_sn := bas[3]
  23347. result, request_log = service.Hnyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, "1")
  23348. } else {
  23349. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23350. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "1")
  23351. }
  23352. var dat map[string]interface{}
  23353. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23354. fmt.Println(dat)
  23355. } else {
  23356. fmt.Println(err)
  23357. }
  23358. saveLog(result, request_log, "2206", "预结算")
  23359. userJSONBytes, _ := json.Marshal(dat)
  23360. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23361. utils.ErrorLog("解析失败:%v", err)
  23362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23363. return
  23364. }
  23365. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23366. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23367. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23368. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23369. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23370. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23371. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23372. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23373. resp, requestErr := http.Get(api)
  23374. if requestErr != nil {
  23375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23376. return
  23377. }
  23378. body, ioErr := ioutil.ReadAll(resp.Body)
  23379. if ioErr != nil {
  23380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23382. return
  23383. }
  23384. var respJSON map[string]interface{}
  23385. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23388. return
  23389. }
  23390. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23391. result, _ := json.Marshal(respJSON)
  23392. fmt.Println("log")
  23393. fmt.Println(string(result))
  23394. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23395. utils.ErrorLog("解析失败:%v", err)
  23396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23397. return
  23398. }
  23399. } else {
  23400. if miConfig.MdtrtareaAdmvs == "441202" {
  23401. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23402. if result3101.Infcode == 0 {
  23403. if len(result3101.Output.Result) > 0 {
  23404. var errMsgs []string
  23405. for _, item := range result3101.Output.Result {
  23406. errMsgs = append(errMsgs, item.VolaCont)
  23407. }
  23408. c.ServeSuccessJSON(map[string]interface{}{
  23409. "failed_code": -10,
  23410. "msg": errMsgs,
  23411. })
  23412. return
  23413. } else {
  23414. var result string
  23415. var request_log string
  23416. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23417. allTotal = fmt.Sprintf("%.2f", total_two)
  23418. if his.IdCardType == 4 {
  23419. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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, admin_user_id)
  23420. } else {
  23421. 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, admin_user_id)
  23422. }
  23423. var dat map[string]interface{}
  23424. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23425. fmt.Println(dat)
  23426. } else {
  23427. fmt.Println(err)
  23428. }
  23429. saveLog(result, request_log, "2206", "预结算")
  23430. //userJSONBytes, _ := json.Marshal(dat)
  23431. //
  23432. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23433. // utils.ErrorLog("解析失败:%v", err)
  23434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23435. // return
  23436. //}
  23437. userJSONBytes, _ := json.Marshal(dat)
  23438. if miConfig.Code == "H15049901371" {
  23439. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23440. utils.ErrorLog("解析失败:%v", err)
  23441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23442. return
  23443. }
  23444. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23445. res.Output = resSeven10265.Output
  23446. res.ErrMsg = resSeven10265.ErrMsg
  23447. res.Cainfo = resSeven10265.Cainfo
  23448. res.WarnMsg = resSeven10265.WarnMsg
  23449. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23450. res.Infcode = infocode
  23451. } else {
  23452. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23453. utils.ErrorLog("解析失败:%v", err)
  23454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23455. return
  23456. }
  23457. }
  23458. }
  23459. } else {
  23460. c.ServeSuccessJSON(map[string]interface{}{
  23461. "failed_code": -10,
  23462. "msg": result3101.ErrMsg,
  23463. })
  23464. return
  23465. }
  23466. } else {
  23467. var result string
  23468. var request_log string
  23469. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23470. allTotal = fmt.Sprintf("%.2f", total_two)
  23471. if his.IdCardType == 4 {
  23472. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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, admin_user_id)
  23473. } else {
  23474. 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, admin_user_id)
  23475. }
  23476. var dat map[string]interface{}
  23477. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23478. fmt.Println(dat)
  23479. } else {
  23480. fmt.Println(err)
  23481. }
  23482. saveLog(result, request_log, "2206", "预结算")
  23483. //userJSONBytes, _ := json.Marshal(dat)
  23484. //
  23485. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23486. // utils.ErrorLog("解析失败:%v", err)
  23487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23488. // return
  23489. //}
  23490. userJSONBytes, _ := json.Marshal(dat)
  23491. if miConfig.Code == "H15049901371" {
  23492. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23493. utils.ErrorLog("解析失败:%v", err)
  23494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23495. return
  23496. }
  23497. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23498. res.Output = resSeven10265.Output
  23499. res.ErrMsg = resSeven10265.ErrMsg
  23500. res.Cainfo = resSeven10265.Cainfo
  23501. res.WarnMsg = resSeven10265.WarnMsg
  23502. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23503. res.Infcode = infocode
  23504. } else {
  23505. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23506. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  23507. utils.ErrorLog("解析失败:%v", err)
  23508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23509. return
  23510. }
  23511. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  23512. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  23513. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  23514. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23515. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  23516. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  23517. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  23518. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23519. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  23520. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23521. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23522. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23523. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23524. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23525. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23526. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  23527. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  23528. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  23529. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  23530. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  23531. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23532. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  23533. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  23534. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  23535. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  23536. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  23537. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  23538. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  23539. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  23540. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23541. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  23542. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  23543. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  23544. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23545. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23546. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23547. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23548. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  23549. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23550. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  23551. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  23552. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  23553. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  23554. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  23555. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  23556. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  23557. res.ErrMsg = gzresSeven10265Two.ErrMsg
  23558. res.Cainfo = gzresSeven10265Two.Cainfo
  23559. res.WarnMsg = gzresSeven10265Two.WarnMsg
  23560. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23561. //res.Infcode = infocode
  23562. } else {
  23563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23564. utils.ErrorLog("解析失败:%v", err)
  23565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23566. return
  23567. }
  23568. }
  23569. }
  23570. }
  23571. }
  23572. utils.ErrorLog("解析失败:%v", res.Infcode)
  23573. if res.Infcode == -1 {
  23574. errlog := &models.HisOrderError{
  23575. UserOrgId: adminUser.CurrentOrgId,
  23576. Ctime: time.Now().Unix(),
  23577. Mtime: time.Now().Unix(),
  23578. Number: chrg_bchno,
  23579. ErrMsg: res.ErrMsg,
  23580. Status: 1,
  23581. PatientId: id,
  23582. RecordTime: recordDateTime,
  23583. Stage: 20,
  23584. }
  23585. service.CreateErrMsgLog(errlog)
  23586. c.ServeSuccessJSON(map[string]interface{}{
  23587. "failed_code": -10,
  23588. "msg": res.ErrMsg,
  23589. })
  23590. return
  23591. }
  23592. if res.Infcode != 0 {
  23593. errlog := &models.HisOrderError{
  23594. UserOrgId: adminUser.CurrentOrgId,
  23595. Ctime: time.Now().Unix(),
  23596. Mtime: time.Now().Unix(),
  23597. Number: chrg_bchno,
  23598. ErrMsg: res.ErrMsg,
  23599. Status: 1,
  23600. PatientId: id,
  23601. RecordTime: recordDateTime,
  23602. Stage: 20,
  23603. }
  23604. service.CreateErrMsgLog(errlog)
  23605. c.ServeSuccessJSON(map[string]interface{}{
  23606. "failed_code": -10,
  23607. "msg": res.ErrMsg,
  23608. })
  23609. return
  23610. } else {
  23611. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  23612. order.OrderStatus = 1
  23613. order.IsPre = 1
  23614. order.Status = 1
  23615. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  23616. order.SetlId = res.Output.Setlinfo.SetlID
  23617. order.PsnNo = res.Output.Setlinfo.PsnNo
  23618. order.PsnName = res.Output.Setlinfo.PsnName
  23619. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  23620. order.Certno = res.Output.Setlinfo.Certno
  23621. order.Gend = res.Output.Setlinfo.Gend
  23622. order.Naty = res.Output.Setlinfo.Naty
  23623. order.Age = res.Output.Setlinfo.Age
  23624. order.Insutype = res.Output.Setlinfo.Insutype
  23625. order.PsnType = res.Output.Setlinfo.PsnType
  23626. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  23627. order.SetlTime = res.Output.Setlinfo.SetlTime
  23628. order.AcctUsedFlag = acct_used_flag
  23629. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  23630. if res.Output.Setlinfo.MedType == "140101" {
  23631. order.MedType = "14"
  23632. } else {
  23633. if res.Output.Setlinfo.MedType == "110104" {
  23634. order.MedType = "11"
  23635. } else {
  23636. order.MedType = res.Output.Setlinfo.MedType
  23637. }
  23638. }
  23639. if res.Output.Setlinfo.MedType == "992102" {
  23640. order.MedType = "992102"
  23641. }
  23642. if res.Output.Setlinfo.MedType == "140104" {
  23643. order.MedType = "140104"
  23644. }
  23645. if res.Output.Setlinfo.MedType == "14" {
  23646. order.MedType = "14"
  23647. }
  23648. if reg_type == 1112 {
  23649. order.MedType = "1112"
  23650. }
  23651. if reg_type == 1111 {
  23652. order.MedType = "1111"
  23653. }
  23654. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  23655. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  23656. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  23657. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  23658. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  23659. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  23660. order.HifpPay = res.Output.Setlinfo.HifpPay
  23661. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  23662. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  23663. order.HifesPay = res.Output.Setlinfo.HifesPay
  23664. order.HifobPay = res.Output.Setlinfo.HifobPay
  23665. order.MafPay = res.Output.Setlinfo.MafPay
  23666. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  23667. order.OthPay = res.Output.Setlinfo.OthPay
  23668. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  23669. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  23670. order.AcctPay = res.Output.Setlinfo.AcctPay
  23671. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  23672. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  23673. order.Balc = res.Output.Setlinfo.Balc
  23674. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  23675. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  23676. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  23677. order.ClrWay = res.Output.Setlinfo.ClrWay
  23678. order.Creator = order.Creator
  23679. order.Modify = roles.AdminUserId
  23680. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  23681. //detailStr := string(setlDetail)
  23682. //order.SetlDetail = detailStr
  23683. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  23684. err = service.UpDateOrder(order)
  23685. if err == nil {
  23686. c.ServeSuccessJSON(map[string]interface{}{
  23687. "msg": "预结算成功",
  23688. })
  23689. } else {
  23690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  23691. return
  23692. }
  23693. }
  23694. } else {
  23695. adminUser := c.GetAdminUserInfo()
  23696. errlog := &models.HisOrderError{
  23697. UserOrgId: adminUser.CurrentOrgId,
  23698. Ctime: time.Now().Unix(),
  23699. Mtime: time.Now().Unix(),
  23700. ErrMsg: res.ErrMsg,
  23701. Status: 1,
  23702. PatientId: id,
  23703. RecordTime: recordDateTime,
  23704. Stage: 4,
  23705. }
  23706. service.CreateErrMsgLog(errlog)
  23707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  23708. return
  23709. }
  23710. } else {
  23711. if miConfig.MdtrtareaAdmvs == "150499" {
  23712. order := &models.HisOrder{
  23713. UserOrgId: adminUser.CurrentOrgId,
  23714. HisPatientId: his.ID,
  23715. PatientId: his.PatientId,
  23716. SettleAccountsDate: recordDateTime,
  23717. Ctime: time.Now().Unix(),
  23718. Mtime: time.Now().Unix(),
  23719. MdtrtId: his.Number,
  23720. PsnNo: his.PsnNo,
  23721. MedType: strconv.FormatInt(reg_type, 10),
  23722. Status: 1,
  23723. Number: chrg_bchno,
  23724. Infcode: res.Infcode,
  23725. WarnMsg: res.WarnMsg,
  23726. Cainfo: res.Cainfo,
  23727. ErrMsg: res.ErrMsg,
  23728. RespondTime: res.RefmsgTime,
  23729. InfRefmsgid: res.InfRefmsgid,
  23730. OrderStatus: 1,
  23731. IsMedicineInsurance: 1,
  23732. SettleType: settle_accounts_type,
  23733. SettleStartTime: start_time,
  23734. SettleEndTime: end_time,
  23735. Creator: roles.AdminUserId,
  23736. Modify: roles.AdminUserId,
  23737. PType: 2,
  23738. Diagnosis: diagnosis_id,
  23739. }
  23740. err = service.CreateOrder(order)
  23741. if err != nil {
  23742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23743. return
  23744. }
  23745. }
  23746. adminUser := c.GetAdminUserInfo()
  23747. errlog := &models.HisOrderError{
  23748. UserOrgId: adminUser.CurrentOrgId,
  23749. Ctime: time.Now().Unix(),
  23750. Mtime: time.Now().Unix(),
  23751. ErrMsg: res.ErrMsg,
  23752. Status: 1,
  23753. PatientId: id,
  23754. RecordTime: recordDateTime,
  23755. Stage: 4,
  23756. }
  23757. service.CreateErrMsgLog(errlog)
  23758. c.ServeSuccessJSON(map[string]interface{}{
  23759. "failed_code": -10,
  23760. "msg": res.ErrMsg,
  23761. })
  23762. return
  23763. }
  23764. }
  23765. }
  23766. }
  23767. // 退款
  23768. func (c *HisApiController) Refund() {
  23769. order_id, _ := c.GetInt64("order_id")
  23770. admin_user_id, _ := c.GetInt64("admin_user_id")
  23771. adminUser := c.GetAdminUserInfo()
  23772. var order models.HisOrder
  23773. order, _ = service.GetHisOrderByID(order_id)
  23774. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23775. if order.ID == 0 {
  23776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23777. return
  23778. }
  23779. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23780. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23781. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23782. if config.IsOpen == 1 { //对接了医保,走医保流程
  23783. var res ResultSixteen
  23784. var ahres ResultSevenAH
  23785. var resSixteen10265 ResultSixteen10265
  23786. var resSixteen10265Two ResultSixteen10265Two
  23787. var gz ResultgzSixteen10265Two
  23788. var src_resquest string
  23789. var result string
  23790. if miConfig.MdtrtareaAdmvs == "421300" {
  23791. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23792. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23793. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23794. resp3, requestErr3 := http.Get(api3)
  23795. if requestErr3 != nil {
  23796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23797. return
  23798. }
  23799. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23800. if ioErr3 != nil {
  23801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23803. return
  23804. }
  23805. var respJSON3 map[string]interface{}
  23806. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23809. return
  23810. }
  23811. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23812. userJSONBytes3, _ := json.Marshal(respJSON3)
  23813. fmt.Println("log")
  23814. fmt.Println(string(userJSONBytes3))
  23815. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23816. utils.ErrorLog("解析失败:%v", err)
  23817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23818. return
  23819. }
  23820. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23821. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23822. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23823. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23824. resp3, requestErr3 := http.Get(api3)
  23825. if requestErr3 != nil {
  23826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23827. return
  23828. }
  23829. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23830. if ioErr3 != nil {
  23831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23833. return
  23834. }
  23835. var respJSON3 map[string]interface{}
  23836. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23839. return
  23840. }
  23841. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23842. userJSONBytes3, _ := json.Marshal(respJSON3)
  23843. fmt.Println("log")
  23844. fmt.Println(string(userJSONBytes3))
  23845. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23846. utils.ErrorLog("解析失败:%v", err)
  23847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23848. return
  23849. }
  23850. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23851. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23852. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23853. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23854. resp3, requestErr3 := http.Get(api3)
  23855. if requestErr3 != nil {
  23856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23857. return
  23858. }
  23859. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23860. if ioErr3 != nil {
  23861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23863. return
  23864. }
  23865. var respJSON3 map[string]interface{}
  23866. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23869. return
  23870. }
  23871. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23872. userJSONBytes3, _ := json.Marshal(respJSON3)
  23873. fmt.Println("log")
  23874. fmt.Println(string(userJSONBytes3))
  23875. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23876. utils.ErrorLog("解析失败:%v", err)
  23877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23878. return
  23879. }
  23880. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23881. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23882. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23883. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23884. resp3, requestErr3 := http.Get(api3)
  23885. if requestErr3 != nil {
  23886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23887. return
  23888. }
  23889. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23890. if ioErr3 != nil {
  23891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23893. return
  23894. }
  23895. var respJSON3 map[string]interface{}
  23896. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23899. return
  23900. }
  23901. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23902. userJSONBytes3, _ := json.Marshal(respJSON3)
  23903. fmt.Println("log")
  23904. fmt.Println(string(userJSONBytes3))
  23905. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23906. utils.ErrorLog("解析失败:%v", err)
  23907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23908. return
  23909. }
  23910. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23911. var api3 string
  23912. if miConfig.MdtrtareaAdmvs == "320921" {
  23913. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23914. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23915. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23916. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23917. } else {
  23918. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23919. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23920. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23921. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23922. }
  23923. resp3, requestErr3 := http.Get(api3)
  23924. if requestErr3 != nil {
  23925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23926. return
  23927. }
  23928. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23929. if ioErr3 != nil {
  23930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23932. return
  23933. }
  23934. var respJSON3 map[string]interface{}
  23935. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23938. return
  23939. }
  23940. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23941. userJSONBytes3, _ := json.Marshal(respJSON3)
  23942. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23943. utils.ErrorLog("解析失败:%v", err)
  23944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23945. return
  23946. }
  23947. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23948. res.Output = resSixteen10265.Output
  23949. res.ErrMsg = resSixteen10265.ErrMsg
  23950. res.Cainfo = resSixteen10265.Cainfo
  23951. res.WarnMsg = resSixteen10265.WarnMsg
  23952. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23953. res.Infcode = infocode
  23954. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23955. var api3 string
  23956. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  23957. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23958. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23959. resp3, requestErr3 := http.Get(api3)
  23960. if requestErr3 != nil {
  23961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23962. return
  23963. }
  23964. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23965. if ioErr3 != nil {
  23966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23968. return
  23969. }
  23970. var respJSON3 map[string]interface{}
  23971. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23974. return
  23975. }
  23976. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23977. userJSONBytes3, _ := json.Marshal(respJSON3)
  23978. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23979. utils.ErrorLog("解析失败:%v", err)
  23980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23981. return
  23982. }
  23983. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23984. res.Output = resSixteen10265.Output
  23985. res.ErrMsg = resSixteen10265.ErrMsg
  23986. res.Cainfo = resSixteen10265.Cainfo
  23987. res.WarnMsg = resSixteen10265.WarnMsg
  23988. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23989. res.Infcode = infocode
  23990. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23991. result, src_resquest, _ = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  23992. var dat map[string]interface{}
  23993. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23994. fmt.Println(dat)
  23995. } else {
  23996. fmt.Println(err)
  23997. }
  23998. saveLog(result, src_resquest, "2208", "退费")
  23999. userJSONBytes, _ := json.Marshal(dat)
  24000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24001. utils.ErrorLog("解析失败:%v", err)
  24002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24003. return
  24004. }
  24005. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24006. result, src_resquest = service.Jxyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.AccessKey, "")
  24007. var dat map[string]interface{}
  24008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24009. fmt.Println(dat)
  24010. } else {
  24011. fmt.Println(err)
  24012. }
  24013. saveLog(result, src_resquest, "2208", "退费")
  24014. userJSONBytes, _ := json.Marshal(dat)
  24015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24016. utils.ErrorLog("解析失败:%v", err)
  24017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24018. return
  24019. }
  24020. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24021. var api3 string
  24022. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  24023. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24024. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24025. resp3, requestErr3 := http.Get(api3)
  24026. if requestErr3 != nil {
  24027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24028. return
  24029. }
  24030. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24031. if ioErr3 != nil {
  24032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24034. return
  24035. }
  24036. var respJSON3 map[string]interface{}
  24037. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24040. return
  24041. }
  24042. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24043. if status == "0" {
  24044. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24045. c.ServeSuccessJSON(map[string]interface{}{
  24046. "failed_code": -10,
  24047. "msg": err_msg,
  24048. })
  24049. return
  24050. }
  24051. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24052. userJSONBytes3, _ := json.Marshal(respJSON3)
  24053. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24054. // utils.ErrorLog("解析失败:%v", err)
  24055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24056. // return
  24057. //}
  24058. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  24059. utils.ErrorLog("解析失败:%v", err)
  24060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24061. return
  24062. }
  24063. res.InfRefmsgid = ahres.InfRefmsgid
  24064. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  24065. // 创建对应的Time类型
  24066. t := time.UnixMilli(timestamp)
  24067. // 格式化成指定的日期字符串
  24068. str := t.Format("2006-01-02 15:04:05")
  24069. res.Output.Setlinfo.SetlTime = str
  24070. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  24071. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  24072. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24073. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  24074. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  24075. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  24076. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24077. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  24078. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  24079. //
  24080. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  24081. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  24082. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  24083. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24084. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  24085. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  24086. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  24087. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  24088. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  24089. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  24090. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24091. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  24092. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  24093. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  24094. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  24095. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  24096. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  24097. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  24098. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  24099. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  24100. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  24101. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  24102. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  24103. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  24104. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  24105. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  24106. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  24107. //res.Output.Setldetail = ahres.Output.Setldetail
  24108. res.ErrMsg = ahres.ErrMsg
  24109. res.Cainfo = ahres.Cainfo
  24110. res.WarnMsg = ahres.WarnMsg
  24111. res.Infcode = ahres.Infcode
  24112. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24113. result, src_resquest = service.Hnyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.AccessKey, "")
  24114. var dat map[string]interface{}
  24115. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24116. fmt.Println(dat)
  24117. } else {
  24118. fmt.Println(err)
  24119. }
  24120. saveLog(result, src_resquest, "2208", "退费")
  24121. userJSONBytes, _ := json.Marshal(dat)
  24122. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24123. utils.ErrorLog("解析失败:%v", err)
  24124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24125. return
  24126. }
  24127. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24128. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  24129. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24130. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24131. resp3, requestErr3 := http.Get(api3)
  24132. if requestErr3 != nil {
  24133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24134. return
  24135. }
  24136. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24137. if ioErr3 != nil {
  24138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24140. return
  24141. }
  24142. var respJSON3 map[string]interface{}
  24143. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24146. return
  24147. }
  24148. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24149. userJSONBytes3, _ := json.Marshal(respJSON3)
  24150. fmt.Println("log")
  24151. fmt.Println(string(userJSONBytes3))
  24152. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24153. utils.ErrorLog("解析失败:%v", err)
  24154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24155. return
  24156. }
  24157. } else {
  24158. if miConfig.Code == "H15049901371" {
  24159. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id)
  24160. var dat map[string]interface{}
  24161. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24162. fmt.Println(dat)
  24163. } else {
  24164. fmt.Println(err)
  24165. }
  24166. saveLog(result, src_resquest, "2208", "退费")
  24167. userJSONBytes, _ := json.Marshal(dat)
  24168. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  24169. utils.ErrorLog("解析失败:%v", err)
  24170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24171. return
  24172. }
  24173. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24174. res.Output = resSixteen10265.Output
  24175. res.ErrMsg = resSixteen10265.ErrMsg
  24176. res.Cainfo = resSixteen10265.Cainfo
  24177. res.WarnMsg = resSixteen10265.WarnMsg
  24178. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24179. res.Infcode = infocode
  24180. } else {
  24181. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id)
  24182. var dat map[string]interface{}
  24183. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24184. fmt.Println(dat)
  24185. } else {
  24186. fmt.Println(err)
  24187. }
  24188. saveLog(result, src_resquest, "2208", "退费")
  24189. userJSONBytes, _ := json.Marshal(dat)
  24190. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24191. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  24192. utils.ErrorLog("解析失败:%v", err)
  24193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24194. return
  24195. }
  24196. res.Infcode = gz.Infcode
  24197. } else {
  24198. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24199. utils.ErrorLog("解析失败:%v", err)
  24200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24201. return
  24202. }
  24203. }
  24204. }
  24205. }
  24206. if res.Infcode == 0 {
  24207. var res2 ResultSix
  24208. var resSix10265 ResultSix10265
  24209. if miConfig.MdtrtareaAdmvs == "421300" {
  24210. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24211. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24212. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24213. resp3, requestErr3 := http.Get(api3)
  24214. if requestErr3 != nil {
  24215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24216. return
  24217. }
  24218. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24219. if ioErr3 != nil {
  24220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24222. return
  24223. }
  24224. var respJSON3 map[string]interface{}
  24225. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24228. return
  24229. }
  24230. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24231. userJSONBytes3, _ := json.Marshal(respJSON3)
  24232. fmt.Println("log")
  24233. fmt.Println(string(userJSONBytes3))
  24234. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24235. utils.ErrorLog("解析失败:%v", err)
  24236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24237. return
  24238. }
  24239. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24240. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24241. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24242. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24243. resp3, requestErr3 := http.Get(api3)
  24244. if requestErr3 != nil {
  24245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24246. return
  24247. }
  24248. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24249. if ioErr3 != nil {
  24250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24252. return
  24253. }
  24254. var respJSON3 map[string]interface{}
  24255. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24258. return
  24259. }
  24260. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24261. userJSONBytes3, _ := json.Marshal(respJSON3)
  24262. fmt.Println("log")
  24263. fmt.Println(string(userJSONBytes3))
  24264. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24265. utils.ErrorLog("解析失败:%v", err)
  24266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24267. return
  24268. }
  24269. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24270. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24271. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24272. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24273. resp3, requestErr3 := http.Get(api3)
  24274. if requestErr3 != nil {
  24275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24276. return
  24277. }
  24278. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24279. if ioErr3 != nil {
  24280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24282. return
  24283. }
  24284. var respJSON3 map[string]interface{}
  24285. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24288. return
  24289. }
  24290. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24291. userJSONBytes3, _ := json.Marshal(respJSON3)
  24292. fmt.Println("log")
  24293. fmt.Println(string(userJSONBytes3))
  24294. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24295. utils.ErrorLog("解析失败:%v", err)
  24296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24297. return
  24298. }
  24299. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24300. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24301. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24302. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24303. resp3, requestErr3 := http.Get(api3)
  24304. if requestErr3 != nil {
  24305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24306. return
  24307. }
  24308. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24309. if ioErr3 != nil {
  24310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24312. return
  24313. }
  24314. var respJSON3 map[string]interface{}
  24315. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24318. return
  24319. }
  24320. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24321. userJSONBytes3, _ := json.Marshal(respJSON3)
  24322. fmt.Println("log")
  24323. fmt.Println(string(userJSONBytes3))
  24324. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24325. utils.ErrorLog("解析失败:%v", err)
  24326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24327. return
  24328. }
  24329. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24330. var api3 string
  24331. if miConfig.MdtrtareaAdmvs == "320921" {
  24332. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24333. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24334. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24335. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24336. } else {
  24337. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24338. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24339. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24340. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24341. }
  24342. resp3, requestErr3 := http.Get(api3)
  24343. if requestErr3 != nil {
  24344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24345. return
  24346. }
  24347. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24348. if ioErr3 != nil {
  24349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24351. return
  24352. }
  24353. var respJSON3 map[string]interface{}
  24354. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24357. return
  24358. }
  24359. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24360. userJSONBytes3, _ := json.Marshal(respJSON3)
  24361. fmt.Println("log")
  24362. fmt.Println(string(userJSONBytes3))
  24363. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24364. utils.ErrorLog("解析失败:%v", err)
  24365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24366. return
  24367. }
  24368. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24369. res2.Output = resSix10265.Output
  24370. res2.ErrMsg = resSix10265.ErrMsg
  24371. res2.Cainfo = resSix10265.Cainfo
  24372. res2.WarnMsg = resSix10265.WarnMsg
  24373. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24374. res2.Infcode = infocode
  24375. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24376. var api3 string
  24377. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  24378. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24379. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24380. resp3, requestErr3 := http.Get(api3)
  24381. if requestErr3 != nil {
  24382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24383. return
  24384. }
  24385. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24386. if ioErr3 != nil {
  24387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24389. return
  24390. }
  24391. var respJSON3 map[string]interface{}
  24392. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24395. return
  24396. }
  24397. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24398. userJSONBytes3, _ := json.Marshal(respJSON3)
  24399. fmt.Println("log")
  24400. fmt.Println(string(userJSONBytes3))
  24401. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24402. utils.ErrorLog("解析失败:%v", err)
  24403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24404. return
  24405. }
  24406. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24407. res2.Output = resSix10265.Output
  24408. res2.ErrMsg = resSix10265.ErrMsg
  24409. res2.Cainfo = resSix10265.Cainfo
  24410. res2.WarnMsg = resSix10265.WarnMsg
  24411. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24412. res2.Infcode = infocode
  24413. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24414. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  24415. var dat map[string]interface{}
  24416. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24417. fmt.Println(dat)
  24418. } else {
  24419. fmt.Println(err)
  24420. }
  24421. saveLog(result2, src_request, "2205", "撤销明细")
  24422. userJSONBytes, _ := json.Marshal(dat)
  24423. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24424. utils.ErrorLog("解析失败:%v", err)
  24425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24426. return
  24427. }
  24428. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24429. result2, src_request := service.Jxyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  24430. var dat map[string]interface{}
  24431. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24432. fmt.Println(dat)
  24433. } else {
  24434. fmt.Println(err)
  24435. }
  24436. saveLog(result2, src_request, "2205", "撤销明细")
  24437. userJSONBytes, _ := json.Marshal(dat)
  24438. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24439. utils.ErrorLog("解析失败:%v", err)
  24440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24441. return
  24442. }
  24443. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24444. var api3 string
  24445. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  24446. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24447. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24448. resp3, requestErr3 := http.Get(api3)
  24449. if requestErr3 != nil {
  24450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24451. return
  24452. }
  24453. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24454. if ioErr3 != nil {
  24455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24457. return
  24458. }
  24459. var respJSON3 map[string]interface{}
  24460. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24463. return
  24464. }
  24465. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24466. if status == "0" {
  24467. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24468. c.ServeSuccessJSON(map[string]interface{}{
  24469. "failed_code": -10,
  24470. "msg": err_msg,
  24471. })
  24472. return
  24473. }
  24474. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24475. userJSONBytes3, _ := json.Marshal(respJSON3)
  24476. fmt.Println("log")
  24477. fmt.Println(string(userJSONBytes3))
  24478. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24479. utils.ErrorLog("解析失败:%v", err)
  24480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24481. return
  24482. }
  24483. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24484. result2, src_request := service.Hnyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  24485. var dat map[string]interface{}
  24486. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24487. fmt.Println(dat)
  24488. } else {
  24489. fmt.Println(err)
  24490. }
  24491. saveLog(result2, src_request, "2205", "撤销明细")
  24492. userJSONBytes, _ := json.Marshal(dat)
  24493. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24494. utils.ErrorLog("解析失败:%v", err)
  24495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24496. return
  24497. }
  24498. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24499. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  24500. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24501. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24502. resp3, requestErr3 := http.Get(api3)
  24503. if requestErr3 != nil {
  24504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24505. return
  24506. }
  24507. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24508. if ioErr3 != nil {
  24509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24511. return
  24512. }
  24513. var respJSON3 map[string]interface{}
  24514. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24517. return
  24518. }
  24519. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24520. userJSONBytes3, _ := json.Marshal(respJSON3)
  24521. fmt.Println("log")
  24522. fmt.Println(string(userJSONBytes3))
  24523. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24524. utils.ErrorLog("解析失败:%v", err)
  24525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24526. return
  24527. }
  24528. } else {
  24529. if miConfig.Code == "H15049901371" {
  24530. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, admin_user_id)
  24531. var dat map[string]interface{}
  24532. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24533. fmt.Println(dat)
  24534. } else {
  24535. fmt.Println(err)
  24536. }
  24537. saveLog(result2, src_request, "2205", "撤销明细")
  24538. userJSONBytes, _ := json.Marshal(dat)
  24539. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  24540. utils.ErrorLog("解析失败:%v", err)
  24541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24542. return
  24543. }
  24544. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24545. res2.Output = resSix10265.Output
  24546. res2.ErrMsg = resSix10265.ErrMsg
  24547. res2.Cainfo = resSix10265.Cainfo
  24548. res2.WarnMsg = resSix10265.WarnMsg
  24549. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24550. res2.Infcode = infocode
  24551. } else {
  24552. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24553. res2.Infcode = 0
  24554. } else {
  24555. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, admin_user_id)
  24556. var dat map[string]interface{}
  24557. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24558. fmt.Println(dat)
  24559. } else {
  24560. fmt.Println(err)
  24561. }
  24562. saveLog(result2, src_request, "2205", "撤销明细")
  24563. userJSONBytes, _ := json.Marshal(dat)
  24564. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24565. utils.ErrorLog("解析失败:%v", err)
  24566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24567. return
  24568. }
  24569. }
  24570. }
  24571. }
  24572. if res2.Infcode == -1 {
  24573. c.ServeSuccessJSON(map[string]interface{}{
  24574. "failed_code": -10,
  24575. "msg": res2.ErrMsg,
  24576. })
  24577. return
  24578. }
  24579. if res2.Infcode == 0 {
  24580. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  24581. if err == nil {
  24582. //当押金不为零时产生退费记录
  24583. if order.Decimal != 0 {
  24584. tmp := strconv.FormatInt(order.ID, 10)
  24585. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  24586. if err != nil {
  24587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24588. return
  24589. }
  24590. }
  24591. c.ServeSuccessJSON(map[string]interface{}{
  24592. "msg": "退费成功",
  24593. })
  24594. } else {
  24595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24596. return
  24597. }
  24598. } else {
  24599. c.ServeSuccessJSON(map[string]interface{}{
  24600. "failed_code": -10,
  24601. "msg": res2.ErrMsg,
  24602. })
  24603. }
  24604. } else {
  24605. c.ServeSuccessJSON(map[string]interface{}{
  24606. "failed_code": -10,
  24607. "msg": res.ErrMsg,
  24608. })
  24609. }
  24610. }
  24611. }
  24612. func (c *HisApiController) RefundNumber() {
  24613. record_time := c.GetString("record_time")
  24614. //patient_id, _ := c.GetInt64("patient_id")
  24615. admin_user_id, _ := c.GetInt64("admin_user_id")
  24616. his_patient_id, _ := c.GetInt64("id")
  24617. timeLayout := "2006-01-02"
  24618. loc, _ := time.LoadLocation("Local")
  24619. adminUser := c.GetAdminUserInfo()
  24620. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24621. fmt.Println(err)
  24622. if err != nil {
  24623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24624. return
  24625. }
  24626. recordDateTime := theTime.Unix()
  24627. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24628. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  24629. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24630. //order, _ := service.GetHisOrderByID(order_id)
  24631. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24632. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24633. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24634. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  24635. if count > 0 {
  24636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  24637. return
  24638. }
  24639. if config.IsOpen == 1 { //对接了医保,走医保流程
  24640. var res2 ResultSix
  24641. var res3 GZResultSix
  24642. var resSix10265 ResultSix10265
  24643. if miConfig.MdtrtareaAdmvs == "421300" {
  24644. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24645. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24646. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24647. resp3, requestErr3 := http.Get(api3)
  24648. if requestErr3 != nil {
  24649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24650. return
  24651. }
  24652. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24653. if ioErr3 != nil {
  24654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24656. return
  24657. }
  24658. var respJSON3 map[string]interface{}
  24659. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24662. return
  24663. }
  24664. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24665. userJSONBytes3, _ := json.Marshal(respJSON3)
  24666. fmt.Println("log")
  24667. fmt.Println(string(userJSONBytes3))
  24668. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24669. utils.ErrorLog("解析失败:%v", err)
  24670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24671. return
  24672. }
  24673. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24674. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24675. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24676. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24677. resp3, requestErr3 := http.Get(api3)
  24678. if requestErr3 != nil {
  24679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24680. return
  24681. }
  24682. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24683. if ioErr3 != nil {
  24684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24686. return
  24687. }
  24688. var respJSON3 map[string]interface{}
  24689. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24692. return
  24693. }
  24694. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24695. userJSONBytes3, _ := json.Marshal(respJSON3)
  24696. fmt.Println("log")
  24697. fmt.Println(string(userJSONBytes3))
  24698. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24699. utils.ErrorLog("解析失败:%v", err)
  24700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24701. return
  24702. }
  24703. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24704. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24705. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24706. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24707. resp3, requestErr3 := http.Get(api3)
  24708. if requestErr3 != nil {
  24709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24710. return
  24711. }
  24712. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24713. if ioErr3 != nil {
  24714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24716. return
  24717. }
  24718. var respJSON3 map[string]interface{}
  24719. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24722. return
  24723. }
  24724. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24725. userJSONBytes3, _ := json.Marshal(respJSON3)
  24726. fmt.Println("log")
  24727. fmt.Println(string(userJSONBytes3))
  24728. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24729. utils.ErrorLog("解析失败:%v", err)
  24730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24731. return
  24732. }
  24733. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24734. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24735. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24736. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24737. resp3, requestErr3 := http.Get(api3)
  24738. if requestErr3 != nil {
  24739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24740. return
  24741. }
  24742. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24743. if ioErr3 != nil {
  24744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24746. return
  24747. }
  24748. var respJSON3 map[string]interface{}
  24749. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24752. return
  24753. }
  24754. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24755. userJSONBytes3, _ := json.Marshal(respJSON3)
  24756. fmt.Println("log")
  24757. fmt.Println(string(userJSONBytes3))
  24758. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24759. utils.ErrorLog("解析失败:%v", err)
  24760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24761. return
  24762. }
  24763. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24764. var api3 string
  24765. if miConfig.MdtrtareaAdmvs == "320921" {
  24766. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24767. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24768. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24769. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24770. } else {
  24771. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24772. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24773. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24774. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24775. }
  24776. resp3, requestErr3 := http.Get(api3)
  24777. if requestErr3 != nil {
  24778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24779. return
  24780. }
  24781. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24782. if ioErr3 != nil {
  24783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24785. return
  24786. }
  24787. var respJSON3 map[string]interface{}
  24788. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24791. return
  24792. }
  24793. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24794. userJSONBytes3, _ := json.Marshal(respJSON3)
  24795. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24796. utils.ErrorLog("解析失败:%v", err)
  24797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24798. return
  24799. }
  24800. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24801. res2.Output = resSix10265.Output
  24802. res2.ErrMsg = resSix10265.ErrMsg
  24803. res2.Cainfo = resSix10265.Cainfo
  24804. res2.WarnMsg = resSix10265.WarnMsg
  24805. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24806. res2.Infcode = infocode
  24807. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24808. var api3 string
  24809. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  24810. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24811. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24812. resp3, requestErr3 := http.Get(api3)
  24813. if requestErr3 != nil {
  24814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24815. return
  24816. }
  24817. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24818. if ioErr3 != nil {
  24819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24821. return
  24822. }
  24823. var respJSON3 map[string]interface{}
  24824. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24827. return
  24828. }
  24829. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24830. userJSONBytes3, _ := json.Marshal(respJSON3)
  24831. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24832. utils.ErrorLog("解析失败:%v", err)
  24833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24834. return
  24835. }
  24836. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24837. res2.Output = resSix10265.Output
  24838. res2.ErrMsg = resSix10265.ErrMsg
  24839. res2.Cainfo = resSix10265.Cainfo
  24840. res2.WarnMsg = resSix10265.WarnMsg
  24841. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24842. res2.Infcode = infocode
  24843. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24844. result, request, _ := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  24845. var dat map[string]interface{}
  24846. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24847. fmt.Println(dat)
  24848. } else {
  24849. fmt.Println(err)
  24850. }
  24851. saveLog(result, request, "2202", "退号")
  24852. userJSONBytes, _ := json.Marshal(dat)
  24853. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24854. utils.ErrorLog("解析失败:%v", err)
  24855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24856. return
  24857. }
  24858. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24859. result, request := service.Jxyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  24860. var dat map[string]interface{}
  24861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24862. fmt.Println(dat)
  24863. } else {
  24864. fmt.Println(err)
  24865. }
  24866. saveLog(result, request, "2202", "退号")
  24867. userJSONBytes, _ := json.Marshal(dat)
  24868. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24869. utils.ErrorLog("解析失败:%v", err)
  24870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24871. return
  24872. }
  24873. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24874. var api3 string
  24875. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  24876. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24877. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24878. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24879. resp3, requestErr3 := http.Get(api3)
  24880. if requestErr3 != nil {
  24881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24882. return
  24883. }
  24884. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24885. if ioErr3 != nil {
  24886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24888. return
  24889. }
  24890. var respJSON3 map[string]interface{}
  24891. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24894. return
  24895. }
  24896. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24897. if status == "0" {
  24898. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24899. c.ServeSuccessJSON(map[string]interface{}{
  24900. "failed_code": -10,
  24901. "msg": err_msg,
  24902. })
  24903. return
  24904. }
  24905. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24906. userJSONBytes3, _ := json.Marshal(respJSON3)
  24907. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24908. utils.ErrorLog("解析失败:%v", err)
  24909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24910. return
  24911. }
  24912. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  24913. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24914. result, request := service.Hnyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  24915. var dat map[string]interface{}
  24916. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24917. fmt.Println(dat)
  24918. } else {
  24919. fmt.Println(err)
  24920. }
  24921. saveLog(result, request, "2202", "退号")
  24922. userJSONBytes, _ := json.Marshal(dat)
  24923. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24924. utils.ErrorLog("解析失败:%v", err)
  24925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24926. return
  24927. }
  24928. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24929. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  24930. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24931. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24932. resp3, requestErr3 := http.Get(api3)
  24933. if requestErr3 != nil {
  24934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24935. return
  24936. }
  24937. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24938. if ioErr3 != nil {
  24939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24941. return
  24942. }
  24943. var respJSON3 map[string]interface{}
  24944. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24947. return
  24948. }
  24949. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24950. userJSONBytes3, _ := json.Marshal(respJSON3)
  24951. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24952. utils.ErrorLog("解析失败:%v", err)
  24953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24954. return
  24955. }
  24956. } else {
  24957. var api3 string
  24958. if miConfig.Code == "H15049901371" {
  24959. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  24960. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24961. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24962. } else {
  24963. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  24964. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24965. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24966. }
  24967. resp3, requestErr3 := http.Get(api3)
  24968. if requestErr3 != nil {
  24969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24970. return
  24971. }
  24972. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24973. if ioErr3 != nil {
  24974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24976. return
  24977. }
  24978. var respJSON3 map[string]interface{}
  24979. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24982. return
  24983. }
  24984. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24985. userJSONBytes3, _ := json.Marshal(respJSON3)
  24986. if miConfig.Code == "H15049901371" {
  24987. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24988. utils.ErrorLog("解析失败:%v", err)
  24989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24990. return
  24991. }
  24992. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24993. res2.Output = resSix10265.Output
  24994. res2.ErrMsg = resSix10265.ErrMsg
  24995. res2.Cainfo = resSix10265.Cainfo
  24996. res2.WarnMsg = resSix10265.WarnMsg
  24997. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24998. res2.Infcode = infocode
  24999. } else {
  25000. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25001. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  25002. utils.ErrorLog("解析失败:%v", err)
  25003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25004. return
  25005. }
  25006. res2.Infcode = res3.Infcode
  25007. } else {
  25008. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25009. utils.ErrorLog("解析失败:%v", err)
  25010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25011. return
  25012. }
  25013. }
  25014. }
  25015. }
  25016. if res2.Infcode == -1 {
  25017. utils.ErrorLog("解析失败:%v", res2.Infcode)
  25018. c.ServeSuccessJSON(map[string]interface{}{
  25019. "failed_code": -10,
  25020. "msg": res2.ErrMsg,
  25021. })
  25022. return
  25023. }
  25024. if res2.Infcode == 0 {
  25025. if err == nil {
  25026. c.ServeSuccessJSON(map[string]interface{}{
  25027. "msg": "退号成功",
  25028. })
  25029. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  25030. } else {
  25031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25032. return
  25033. }
  25034. }
  25035. } else {
  25036. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  25037. //if err == nil {
  25038. // c.ServeSuccessJSON(map[string]interface{}{
  25039. // "msg": "退费成功",
  25040. // })
  25041. //} else {
  25042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25043. // return
  25044. //}
  25045. }
  25046. }
  25047. func (c *HisApiController) RefundDetail() {
  25048. order_id, _ := c.GetInt64("order_id")
  25049. admin_user_id, _ := c.GetInt64("admin_user_id")
  25050. //his_patient_id, _ := c.GetInt64("his_patient_id")
  25051. number := c.GetString("number")
  25052. record_time := c.GetString("record_time")
  25053. patient_id, _ := c.GetInt64("patient_id")
  25054. //med_type, _ := c.GetInt64("med_type")
  25055. timeLayout := "2006-01-02"
  25056. loc, _ := time.LoadLocation("Local")
  25057. adminUser := c.GetAdminUserInfo()
  25058. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25059. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25060. fmt.Println(err)
  25061. if err != nil {
  25062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25063. return
  25064. }
  25065. recordDateTime := theTime.Unix()
  25066. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25067. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  25068. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25069. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25070. var order models.HisOrder
  25071. order, _ = service.GetHisOrderByID(order_id)
  25072. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25073. if config.IsOpen == 1 { //对接了医保,走医保流程
  25074. var res2 ResultSix
  25075. if miConfig.MdtrtareaAdmvs == "421300" {
  25076. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25077. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25078. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25079. resp3, requestErr3 := http.Get(api3)
  25080. if requestErr3 != nil {
  25081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25082. return
  25083. }
  25084. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25085. if ioErr3 != nil {
  25086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25088. return
  25089. }
  25090. var respJSON3 map[string]interface{}
  25091. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25094. return
  25095. }
  25096. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25097. userJSONBytes3, _ := json.Marshal(respJSON3)
  25098. fmt.Println("log")
  25099. fmt.Println(string(userJSONBytes3))
  25100. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25101. utils.ErrorLog("解析失败:%v", err)
  25102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25103. return
  25104. }
  25105. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25106. if err == nil {
  25107. c.ServeSuccessJSON(map[string]interface{}{
  25108. "msg": "撤销明细成功",
  25109. })
  25110. return
  25111. } else {
  25112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25113. return
  25114. }
  25115. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25116. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25117. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25118. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25119. resp3, requestErr3 := http.Get(api3)
  25120. if requestErr3 != nil {
  25121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25122. return
  25123. }
  25124. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25125. if ioErr3 != nil {
  25126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25128. return
  25129. }
  25130. var respJSON3 map[string]interface{}
  25131. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25134. return
  25135. }
  25136. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25137. userJSONBytes3, _ := json.Marshal(respJSON3)
  25138. fmt.Println("log")
  25139. fmt.Println(string(userJSONBytes3))
  25140. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25141. utils.ErrorLog("解析失败:%v", err)
  25142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25143. return
  25144. }
  25145. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25146. if err == nil {
  25147. c.ServeSuccessJSON(map[string]interface{}{
  25148. "msg": "撤销明细成功",
  25149. })
  25150. return
  25151. } else {
  25152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25153. return
  25154. }
  25155. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25156. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25157. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25158. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25159. resp3, requestErr3 := http.Get(api3)
  25160. if requestErr3 != nil {
  25161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25162. return
  25163. }
  25164. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25165. if ioErr3 != nil {
  25166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25168. return
  25169. }
  25170. var respJSON3 map[string]interface{}
  25171. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25174. return
  25175. }
  25176. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25177. userJSONBytes3, _ := json.Marshal(respJSON3)
  25178. fmt.Println("log")
  25179. fmt.Println(string(userJSONBytes3))
  25180. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25181. utils.ErrorLog("解析失败:%v", err)
  25182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25183. return
  25184. }
  25185. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25186. if err == nil {
  25187. c.ServeSuccessJSON(map[string]interface{}{
  25188. "msg": "撤销明细成功",
  25189. })
  25190. return
  25191. } else {
  25192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25193. return
  25194. }
  25195. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25196. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25197. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25198. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25199. resp3, requestErr3 := http.Get(api3)
  25200. if requestErr3 != nil {
  25201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25202. return
  25203. }
  25204. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25205. if ioErr3 != nil {
  25206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25208. return
  25209. }
  25210. var respJSON3 map[string]interface{}
  25211. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25214. return
  25215. }
  25216. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25217. userJSONBytes3, _ := json.Marshal(respJSON3)
  25218. fmt.Println("log")
  25219. fmt.Println(string(userJSONBytes3))
  25220. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25221. utils.ErrorLog("解析失败:%v", err)
  25222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25223. return
  25224. }
  25225. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25226. if err == nil {
  25227. c.ServeSuccessJSON(map[string]interface{}{
  25228. "msg": "撤销明细成功",
  25229. })
  25230. return
  25231. } else {
  25232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25233. return
  25234. }
  25235. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25236. var resSix10265 ResultSix10265
  25237. var api3 string
  25238. if miConfig.MdtrtareaAdmvs == "320921" {
  25239. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25240. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25241. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25242. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25243. } else {
  25244. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25245. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25246. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25247. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25248. }
  25249. resp3, requestErr3 := http.Get(api3)
  25250. utils.ErrorLog("接口: %v", requestErr3)
  25251. if requestErr3 != nil {
  25252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25253. return
  25254. }
  25255. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25256. if ioErr3 != nil {
  25257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25259. return
  25260. }
  25261. var respJSON3 map[string]interface{}
  25262. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25265. return
  25266. }
  25267. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25268. userJSONBytes3, _ := json.Marshal(respJSON3)
  25269. fmt.Println("log")
  25270. fmt.Println(string(userJSONBytes3))
  25271. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25272. utils.ErrorLog("解析失败:%v", err)
  25273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25274. return
  25275. }
  25276. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25277. res2.Output = resSix10265.Output
  25278. res2.ErrMsg = resSix10265.ErrMsg
  25279. res2.Cainfo = resSix10265.Cainfo
  25280. res2.WarnMsg = resSix10265.WarnMsg
  25281. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25282. res2.Infcode = infocode
  25283. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25284. if err == nil {
  25285. c.ServeSuccessJSON(map[string]interface{}{
  25286. "msg": "撤销明细成功",
  25287. })
  25288. return
  25289. } else {
  25290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25291. return
  25292. }
  25293. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25294. var api3 string
  25295. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  25296. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25297. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25298. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25299. resp3, requestErr3 := http.Get(api3)
  25300. utils.ErrorLog("接口: %v", requestErr3)
  25301. if requestErr3 != nil {
  25302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25303. return
  25304. }
  25305. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25306. if ioErr3 != nil {
  25307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25309. return
  25310. }
  25311. var respJSON3 map[string]interface{}
  25312. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25315. return
  25316. }
  25317. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25318. if status == "0" {
  25319. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25320. c.ServeSuccessJSON(map[string]interface{}{
  25321. "failed_code": -10,
  25322. "msg": err_msg,
  25323. })
  25324. return
  25325. }
  25326. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25327. userJSONBytes3, _ := json.Marshal(respJSON3)
  25328. fmt.Println("log")
  25329. fmt.Println(string(userJSONBytes3))
  25330. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25331. utils.ErrorLog("解析失败:%v", err)
  25332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25333. return
  25334. }
  25335. fmt.Println(res2.Infcode)
  25336. if res2.Infcode == -1 {
  25337. c.ServeSuccessJSON(map[string]interface{}{
  25338. "failed_code": -10,
  25339. "msg": res2.ErrMsg,
  25340. })
  25341. return
  25342. }
  25343. if res2.Infcode == 0 {
  25344. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25345. if err == nil {
  25346. c.ServeSuccessJSON(map[string]interface{}{
  25347. "msg": "撤销明细成功",
  25348. })
  25349. return
  25350. } else {
  25351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25352. return
  25353. }
  25354. } else {
  25355. c.ServeSuccessJSON(map[string]interface{}{
  25356. "failed_code": -10,
  25357. "msg": res2.ErrMsg,
  25358. })
  25359. }
  25360. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25361. if err == nil {
  25362. c.ServeSuccessJSON(map[string]interface{}{
  25363. "msg": "撤销明细成功",
  25364. })
  25365. return
  25366. } else {
  25367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25368. return
  25369. }
  25370. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25371. var resSix10265 ResultSix10265
  25372. var api3 string
  25373. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  25374. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25375. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25376. resp3, requestErr3 := http.Get(api3)
  25377. if requestErr3 != nil {
  25378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25379. return
  25380. }
  25381. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25382. if ioErr3 != nil {
  25383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25385. return
  25386. }
  25387. var respJSON3 map[string]interface{}
  25388. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25391. return
  25392. }
  25393. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25394. userJSONBytes3, _ := json.Marshal(respJSON3)
  25395. fmt.Println("log")
  25396. fmt.Println(string(userJSONBytes3))
  25397. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25398. utils.ErrorLog("解析失败:%v", err)
  25399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25400. return
  25401. }
  25402. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25403. res2.Output = resSix10265.Output
  25404. res2.ErrMsg = resSix10265.ErrMsg
  25405. res2.Cainfo = resSix10265.Cainfo
  25406. res2.WarnMsg = resSix10265.WarnMsg
  25407. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25408. res2.Infcode = infocode
  25409. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25410. if err == nil {
  25411. c.ServeSuccessJSON(map[string]interface{}{
  25412. "msg": "撤销明细成功",
  25413. })
  25414. return
  25415. } else {
  25416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25417. return
  25418. }
  25419. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25420. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  25421. var dat map[string]interface{}
  25422. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25423. fmt.Println(dat)
  25424. } else {
  25425. fmt.Println(err)
  25426. }
  25427. saveLog(result2, src_request, "2205", "撤销明细")
  25428. userJSONBytes, _ := json.Marshal(dat)
  25429. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25430. utils.ErrorLog("解析失败:%v", err)
  25431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25432. return
  25433. }
  25434. if res2.Infcode == 0 {
  25435. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25436. if err == nil {
  25437. c.ServeSuccessJSON(map[string]interface{}{
  25438. "msg": "撤销明细成功",
  25439. })
  25440. return
  25441. } else {
  25442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25443. return
  25444. }
  25445. } else {
  25446. c.ServeSuccessJSON(map[string]interface{}{
  25447. "failed_code": -10,
  25448. "msg": res2.ErrMsg,
  25449. })
  25450. }
  25451. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25452. result2, src_request := service.Jxyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  25453. var dat map[string]interface{}
  25454. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25455. fmt.Println(dat)
  25456. } else {
  25457. fmt.Println(err)
  25458. }
  25459. saveLog(result2, src_request, "2205", "撤销明细")
  25460. userJSONBytes, _ := json.Marshal(dat)
  25461. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25462. utils.ErrorLog("解析失败:%v", err)
  25463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25464. return
  25465. }
  25466. if res2.Infcode == 0 {
  25467. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25468. if err == nil {
  25469. c.ServeSuccessJSON(map[string]interface{}{
  25470. "msg": "撤销明细成功",
  25471. })
  25472. return
  25473. } else {
  25474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25475. return
  25476. }
  25477. } else {
  25478. c.ServeSuccessJSON(map[string]interface{}{
  25479. "failed_code": -10,
  25480. "msg": res2.ErrMsg,
  25481. })
  25482. }
  25483. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25484. result2, src_request := service.Hnyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  25485. var dat map[string]interface{}
  25486. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25487. fmt.Println(dat)
  25488. } else {
  25489. fmt.Println(err)
  25490. }
  25491. saveLog(result2, src_request, "2205", "撤销明细")
  25492. userJSONBytes, _ := json.Marshal(dat)
  25493. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25494. utils.ErrorLog("解析失败:%v", err)
  25495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25496. return
  25497. }
  25498. if res2.Infcode == 0 {
  25499. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25500. if err == nil {
  25501. c.ServeSuccessJSON(map[string]interface{}{
  25502. "msg": "撤销明细成功",
  25503. })
  25504. return
  25505. } else {
  25506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25507. return
  25508. }
  25509. } else {
  25510. c.ServeSuccessJSON(map[string]interface{}{
  25511. "failed_code": -10,
  25512. "msg": res2.ErrMsg,
  25513. })
  25514. }
  25515. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25516. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  25517. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25518. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25519. resp2, requestErr2 := http.Get(api2)
  25520. if requestErr2 != nil {
  25521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25522. return
  25523. }
  25524. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25525. if ioErr2 != nil {
  25526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25528. return
  25529. }
  25530. var respJSON2 map[string]interface{}
  25531. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25534. return
  25535. }
  25536. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25537. userJSONBytes3, _ := json.Marshal(respJSON2)
  25538. fmt.Println("log")
  25539. fmt.Println(string(userJSONBytes3))
  25540. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25541. utils.ErrorLog("解析失败:%v", err)
  25542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25543. return
  25544. }
  25545. if res2.Infcode == 0 {
  25546. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25547. if err == nil {
  25548. c.ServeSuccessJSON(map[string]interface{}{
  25549. "msg": "撤销明细成功",
  25550. })
  25551. return
  25552. } else {
  25553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25554. return
  25555. }
  25556. } else {
  25557. c.ServeSuccessJSON(map[string]interface{}{
  25558. "failed_code": -10,
  25559. "msg": res2.ErrMsg,
  25560. })
  25561. }
  25562. } else {
  25563. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  25564. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25565. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25566. resp2, requestErr2 := http.Get(api2)
  25567. if requestErr2 != nil {
  25568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25569. return
  25570. }
  25571. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25572. if ioErr2 != nil {
  25573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25575. return
  25576. }
  25577. var respJSON2 map[string]interface{}
  25578. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25581. return
  25582. }
  25583. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25584. if err == nil {
  25585. c.ServeSuccessJSON(map[string]interface{}{
  25586. "msg": "撤销明细成功",
  25587. })
  25588. return
  25589. } else {
  25590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25591. return
  25592. }
  25593. }
  25594. } else {
  25595. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25596. if err == nil {
  25597. c.ServeSuccessJSON(map[string]interface{}{
  25598. "msg": "退费成功",
  25599. })
  25600. } else {
  25601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25602. return
  25603. }
  25604. }
  25605. }
  25606. // 对账
  25607. func (c *HisApiController) GetCheckAccount() {
  25608. start_time := c.GetString("start_time")
  25609. end_time := c.GetString("end_time")
  25610. insutype := c.GetString("insutype")
  25611. clr_type := c.GetString("clr_type")
  25612. clr_org := c.GetString("clr_optins")
  25613. admin_user_id, _ := c.GetInt64("admin_user_id")
  25614. adminUser := c.GetAdminUserInfo()
  25615. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25616. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25617. if len(clr_org) == 0 {
  25618. clr_org = miConfig.InsuplcAdmdvs
  25619. }
  25620. timeLayout := "2006-01-02"
  25621. loc, _ := time.LoadLocation("Local")
  25622. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25623. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25624. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25625. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25626. fixmedins_setl_cnt := int64(len(orders))
  25627. var medfee_sumamt float64
  25628. var acct_pay float64
  25629. var fund_pay_sumamt float64
  25630. for _, item := range orders {
  25631. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25632. acct_pay = acct_pay + item.AcctPay
  25633. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25634. }
  25635. var user_name string
  25636. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25637. if role.ID == 0 {
  25638. user_name = "xxx"
  25639. } else {
  25640. user_name = role.UserName
  25641. }
  25642. var res ResultEight
  25643. var res10188 ResultEightFor10188
  25644. if config.IsOpen == 1 {
  25645. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25646. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  25647. "insutype=" + insutype +
  25648. "&clr_type=" + clr_type +
  25649. "&setl_optins=" + clr_org +
  25650. "&stmt_begndate=" + start_time +
  25651. "&stm_enddate=" + end_time +
  25652. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25653. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25654. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25655. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25656. "&fixmedins_code=" + miConfig.Code +
  25657. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25658. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25659. "&secret_key=" + miConfig.SecretKey +
  25660. "&org_name=" + miConfig.OrgName +
  25661. "&doctor=" + user_name +
  25662. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25663. fmt.Println(api)
  25664. resp, requestErr := http.Get(api)
  25665. if requestErr != nil {
  25666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25667. return
  25668. }
  25669. body, ioErr := ioutil.ReadAll(resp.Body)
  25670. fmt.Println(body)
  25671. if ioErr != nil {
  25672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25674. return
  25675. }
  25676. var respJSON map[string]interface{}
  25677. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25680. return
  25681. }
  25682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25683. userJSONBytes, _ := json.Marshal(respJSON)
  25684. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25685. utils.ErrorLog("解析失败:%v", err)
  25686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25687. return
  25688. }
  25689. res.InfRefmsgid = res10188.InfRefmsgid
  25690. res.Output = res10188.Output
  25691. res.ErrMsg = res10188.ErrMsg
  25692. res.Cainfo = res10188.Cainfo
  25693. res.WarnMsg = res10188.WarnMsg
  25694. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25695. res.Infcode = infocode
  25696. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25697. if clr_type != "9903" {
  25698. clr_type = "99" // 就诊 ID(来自2201接口返回)
  25699. }
  25700. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  25701. "insutype=" + insutype +
  25702. "&clr_type=" + clr_type +
  25703. "&setl_optins=" + clr_org +
  25704. "&stmt_begndate=" + start_time +
  25705. "&stm_enddate=" + end_time +
  25706. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25707. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25708. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25709. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25710. "&fixmedins_code=" + miConfig.Code +
  25711. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25712. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25713. "&secret_key=" + miConfig.SecretKey +
  25714. "&org_name=" + miConfig.OrgName +
  25715. "&doctor=" + user_name
  25716. resp, requestErr := http.Get(api)
  25717. if requestErr != nil {
  25718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25719. return
  25720. }
  25721. body, ioErr := ioutil.ReadAll(resp.Body)
  25722. if ioErr != nil {
  25723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25725. return
  25726. }
  25727. var respJSON map[string]interface{}
  25728. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25731. return
  25732. }
  25733. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25734. result, _ := json.Marshal(respJSON)
  25735. fmt.Println("log")
  25736. fmt.Println(string(result))
  25737. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  25738. utils.ErrorLog("解析失败:%v", err)
  25739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25740. return
  25741. }
  25742. res.InfRefmsgid = res10188.InfRefmsgid
  25743. res.Output = res10188.Output
  25744. res.ErrMsg = res10188.ErrMsg
  25745. res.Cainfo = res10188.Cainfo
  25746. res.WarnMsg = res10188.WarnMsg
  25747. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25748. res.Infcode = infocode
  25749. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25750. var baseParams models.BaseParams
  25751. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25752. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25753. baseParams.SecretKey = miConfig.SecretKey
  25754. baseParams.OrgName = miConfig.OrgName
  25755. baseParams.FixmedinsCode = miConfig.Code
  25756. baseParams.EncKey = miConfig.EncKey
  25757. baseParams.AppSecret = miConfig.AppSecret
  25758. baseParams.SignKey = miConfig.SignKey
  25759. baseParams.AppID = miConfig.Code
  25760. baseParams.Doctor = role.UserName
  25761. baseParams.RequestUrl = miConfig.Url
  25762. businessParams := models.BusinessParams{
  25763. Insutype: insutype,
  25764. ClrType: clr_type,
  25765. SetlOptins: clr_org,
  25766. StmtBegndate: start_time,
  25767. StmtEnddate: end_time,
  25768. MedfeeSumamt: medfee_sumamt,
  25769. FundPaySumamt: fund_pay_sumamt,
  25770. AcctPay: acct_pay,
  25771. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25772. }
  25773. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  25774. fmt.Println(requestLog)
  25775. fmt.Println(result)
  25776. fmt.Println(err_msg)
  25777. var dat map[string]interface{}
  25778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25779. fmt.Println(dat)
  25780. } else {
  25781. fmt.Println(err)
  25782. }
  25783. userJSONBytes, _ := json.Marshal(dat)
  25784. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25785. utils.ErrorLog("解析失败:%v", err)
  25786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25787. return
  25788. }
  25789. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25790. var baseParams models.BaseParams
  25791. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25792. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25793. baseParams.SecretKey = miConfig.SecretKey
  25794. baseParams.OrgName = miConfig.OrgName
  25795. baseParams.FixmedinsCode = miConfig.Code
  25796. baseParams.EncKey = miConfig.EncKey
  25797. baseParams.AppSecret = miConfig.AppSecret
  25798. baseParams.SignKey = miConfig.SignKey
  25799. baseParams.AppID = miConfig.Code
  25800. baseParams.Doctor = role.UserName
  25801. baseParams.RequestUrl = miConfig.Url
  25802. baseParams.AccessKey = miConfig.AccessKey
  25803. businessParams := models.BusinessParams{
  25804. Insutype: insutype,
  25805. ClrType: clr_type,
  25806. SetlOptins: "430822",
  25807. StmtBegndate: start_time,
  25808. StmtEnddate: end_time,
  25809. MedfeeSumamt: medfee_sumamt,
  25810. FundPaySumamt: fund_pay_sumamt,
  25811. AcctPay: acct_pay,
  25812. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25813. }
  25814. result, requestLog := service.Hnyb3201(businessParams.FixmedinsSetlCnt, businessParams.AcctPay, businessParams.FundPaySumamt, businessParams.MedfeeSumamt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.SetlOptins, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, baseParams.Cainfo)
  25815. fmt.Println(requestLog)
  25816. fmt.Println(result)
  25817. var dat map[string]interface{}
  25818. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25819. fmt.Println(dat)
  25820. } else {
  25821. fmt.Println(err)
  25822. }
  25823. userJSONBytes, _ := json.Marshal(dat)
  25824. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25825. utils.ErrorLog("解析失败:%v", err)
  25826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25827. return
  25828. }
  25829. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25830. var baseParams models.BaseParams
  25831. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25832. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25833. baseParams.SecretKey = miConfig.SecretKey
  25834. baseParams.OrgName = miConfig.OrgName
  25835. baseParams.FixmedinsCode = miConfig.Code
  25836. baseParams.EncKey = miConfig.EncKey
  25837. baseParams.AppSecret = miConfig.AppSecret
  25838. baseParams.SignKey = miConfig.SignKey
  25839. baseParams.AppID = miConfig.Code
  25840. baseParams.Doctor = role.UserName
  25841. baseParams.RequestUrl = miConfig.Url
  25842. businessParams := models.BusinessParams{
  25843. Insutype: insutype,
  25844. ClrType: clr_type,
  25845. SetlOptins: clr_org,
  25846. StmtBegndate: start_time,
  25847. StmtEnddate: end_time,
  25848. MedfeeSumamt: medfee_sumamt,
  25849. FundPaySumamt: fund_pay_sumamt,
  25850. AcctPay: acct_pay,
  25851. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25852. }
  25853. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  25854. fmt.Println(requestLog)
  25855. fmt.Println(result)
  25856. fmt.Println(err_msg)
  25857. var dat map[string]interface{}
  25858. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25859. fmt.Println(dat)
  25860. } else {
  25861. fmt.Println(err)
  25862. }
  25863. userJSONBytes, _ := json.Marshal(dat)
  25864. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25865. utils.ErrorLog("解析失败:%v", err)
  25866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25867. return
  25868. }
  25869. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25870. if len(clr_type) == 0 {
  25871. clr_type = "11"
  25872. }
  25873. api := miConfig.Url + "gdyb/ten?" +
  25874. "insutype=" + insutype +
  25875. "&clr_type=" + clr_type +
  25876. "&setl_optins=" + clr_org +
  25877. "&stmt_begndate=" + start_time +
  25878. "&stm_enddate=" + end_time +
  25879. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25880. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25881. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25882. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25883. "&fixmedins_code=" + miConfig.Code +
  25884. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25885. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25886. "&secret_key=" + miConfig.SecretKey +
  25887. "&org_name=" + miConfig.OrgName +
  25888. "&doctor=" + user_name
  25889. fmt.Println(api)
  25890. resp, requestErr := http.Get(api)
  25891. if requestErr != nil {
  25892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25893. return
  25894. }
  25895. body, ioErr := ioutil.ReadAll(resp.Body)
  25896. fmt.Println(body)
  25897. if ioErr != nil {
  25898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25900. return
  25901. }
  25902. var respJSON map[string]interface{}
  25903. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25906. return
  25907. }
  25908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25909. userJSONBytes, _ := json.Marshal(respJSON)
  25910. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25911. utils.ErrorLog("解析失败:%v", err)
  25912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25913. return
  25914. }
  25915. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25916. var baseParams models.BaseParams
  25917. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25918. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25919. baseParams.SecretKey = miConfig.SecretKey
  25920. baseParams.OrgName = miConfig.OrgName
  25921. baseParams.FixmedinsCode = miConfig.Code
  25922. baseParams.EncKey = miConfig.EncKey
  25923. baseParams.AppSecret = miConfig.AppSecret
  25924. baseParams.SignKey = miConfig.SignKey
  25925. baseParams.AppID = miConfig.Code
  25926. baseParams.Doctor = role.UserName
  25927. baseParams.RequestUrl = miConfig.Url
  25928. if clr_type == "9903" {
  25929. clr_type = "9901"
  25930. }
  25931. businessParams := models.BusinessParams{
  25932. Insutype: insutype,
  25933. ClrType: clr_type,
  25934. SetlOptins: "360302",
  25935. StmtBegndate: start_time,
  25936. StmtEnddate: end_time,
  25937. MedfeeSumamt: 0,
  25938. FundPaySumamt: 0,
  25939. AcctPay: 0,
  25940. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25941. }
  25942. result, requestLog := service.Jxyb3201(businessParams.FixmedinsSetlCnt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, miConfig.AccessKey, miConfig.SecretKey, fmt.Sprintf("%.2f", medfee_sumamt), fmt.Sprintf("%.2f", fund_pay_sumamt), fmt.Sprintf("%.2f", acct_pay))
  25943. fmt.Println(requestLog)
  25944. fmt.Println(result)
  25945. var dat map[string]interface{}
  25946. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25947. fmt.Println(dat)
  25948. } else {
  25949. fmt.Println(err)
  25950. }
  25951. userJSONBytes, _ := json.Marshal(dat)
  25952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25953. utils.ErrorLog("解析失败:%v", err)
  25954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25955. return
  25956. }
  25957. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25958. var api string
  25959. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  25960. "&clr_type=" + clr_type +
  25961. "&setl_optins=" + clr_org +
  25962. "&stmt_begndate=" + start_time +
  25963. "&stm_enddate=" + end_time +
  25964. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25965. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25966. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25967. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25968. "&fixmedins_code=" + miConfig.Code +
  25969. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25970. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25971. "&secret_key=" + miConfig.SecretKey +
  25972. "&org_name=" + miConfig.OrgName +
  25973. "&doctor=" + user_name + "&url=" + miConfig.Url
  25974. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25975. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25976. resp, requestErr := http.Get(api)
  25977. if requestErr != nil {
  25978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25979. return
  25980. }
  25981. body, ioErr := ioutil.ReadAll(resp.Body)
  25982. if ioErr != nil {
  25983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25985. return
  25986. }
  25987. var respJSON map[string]interface{}
  25988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25991. return
  25992. }
  25993. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25994. if status == "0" {
  25995. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25996. c.ServeSuccessJSON(map[string]interface{}{
  25997. "failed_code": -10,
  25998. "msg": err_msg,
  25999. })
  26000. return
  26001. }
  26002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26003. userJSONBytes, _ := json.Marshal(respJSON)
  26004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26005. utils.ErrorLog("解析失败:%v", err)
  26006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26007. return
  26008. }
  26009. } else {
  26010. if len(clr_type) == 0 {
  26011. clr_type = "11"
  26012. }
  26013. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26014. "insutype=" + insutype +
  26015. "&clr_type=" + clr_type +
  26016. "&setl_optins=" + clr_org +
  26017. "&stmt_begndate=" + start_time +
  26018. "&stm_enddate=" + end_time +
  26019. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26020. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26021. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26022. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26023. "&fixmedins_code=" + miConfig.Code +
  26024. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26025. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26026. "&secret_key=" + miConfig.SecretKey +
  26027. "&org_name=" + miConfig.OrgName +
  26028. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  26029. fmt.Println(api)
  26030. resp, requestErr := http.Get(api)
  26031. if requestErr != nil {
  26032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26033. return
  26034. }
  26035. body, ioErr := ioutil.ReadAll(resp.Body)
  26036. fmt.Println(body)
  26037. if ioErr != nil {
  26038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26040. return
  26041. }
  26042. var respJSON map[string]interface{}
  26043. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26046. return
  26047. }
  26048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26049. userJSONBytes, _ := json.Marshal(respJSON)
  26050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26051. utils.ErrorLog("解析失败:%v", err)
  26052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26053. return
  26054. }
  26055. }
  26056. if res.Infcode == 0 {
  26057. if res.Output.Stmtinfo.StmtRslt == "0" {
  26058. micc := &models.MedicalInsuranceCostCompare{
  26059. StartTime: startime.Unix(),
  26060. EndTime: endtime.Unix(),
  26061. Insutype: insutype,
  26062. CheckType: 1,
  26063. Num: fixmedins_setl_cnt,
  26064. Mtime: time.Now().Unix(),
  26065. Status: 1,
  26066. UserOrgId: adminUser.CurrentOrgId,
  26067. CostTotal: medfee_sumamt,
  26068. FuncTotal: fund_pay_sumamt,
  26069. PsnPay: acct_pay,
  26070. Creator: admin_user_id,
  26071. Ctime: time.Now().Unix(),
  26072. ClrType: clr_type,
  26073. }
  26074. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  26075. if err == nil {
  26076. c.ServeSuccessJSON(map[string]interface{}{
  26077. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26078. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26079. })
  26080. } else {
  26081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26082. }
  26083. } else {
  26084. c.ServeSuccessJSON(map[string]interface{}{
  26085. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26086. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26087. })
  26088. }
  26089. } else {
  26090. c.ServeSuccessJSON(map[string]interface{}{
  26091. "failed_code": -10,
  26092. "msg": res.ErrMsg,
  26093. })
  26094. }
  26095. }
  26096. }
  26097. func (c *HisApiController) Check310() {
  26098. adminUser := c.GetAdminUserInfo()
  26099. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26100. var user_name string
  26101. user_name = "高慧裕"
  26102. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26103. "insutype=" + "310" +
  26104. "&clr_type=" + "" +
  26105. "&setl_optins=" + "441202" +
  26106. "&stmt_begndate=" + "2022-03-01" +
  26107. "&stm_enddate=" + "2022-03-31" +
  26108. "&medfee_sumamt=" + "194930.12" +
  26109. "&fund_pay_sumamt=" + "188741.46" +
  26110. "&acct_pay=" + "0" +
  26111. "&fixmedins_setl_cnt=" + "452" +
  26112. "&fixmedins_code=" + miConfig.Code +
  26113. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26114. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26115. "&secret_key=" + miConfig.SecretKey +
  26116. "&org_name=" + miConfig.OrgName +
  26117. "&doctor=" + user_name
  26118. fmt.Println(api)
  26119. resp, requestErr := http.Get(api)
  26120. if requestErr != nil {
  26121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26122. return
  26123. }
  26124. body, ioErr := ioutil.ReadAll(resp.Body)
  26125. fmt.Println(body)
  26126. if ioErr != nil {
  26127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26129. return
  26130. }
  26131. var respJSON map[string]interface{}
  26132. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26135. return
  26136. }
  26137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26138. userJSONBytes, _ := json.Marshal(respJSON)
  26139. var res ResultEight
  26140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26141. utils.ErrorLog("解析失败:%v", err)
  26142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26143. return
  26144. }
  26145. }
  26146. func (c *HisApiController) Check390() {
  26147. adminUser := c.GetAdminUserInfo()
  26148. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26149. var user_name string
  26150. user_name = "高慧裕"
  26151. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26152. "insutype=" + "390" +
  26153. "&clr_type=" + "" +
  26154. "&setl_optins=" + "441202" +
  26155. "&stmt_begndate=" + "2022-03-01" +
  26156. "&stm_enddate=" + "2022-03-31" +
  26157. "&medfee_sumamt=" + "1068448.89" +
  26158. "&fund_pay_sumamt=" + "1014677.62" +
  26159. "&acct_pay=" + "0" +
  26160. "&fixmedins_setl_cnt=" + "1950" +
  26161. "&fixmedins_code=" + miConfig.Code +
  26162. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26163. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26164. "&secret_key=" + miConfig.SecretKey +
  26165. "&org_name=" + miConfig.OrgName +
  26166. "&doctor=" + user_name
  26167. fmt.Println(api)
  26168. resp, requestErr := http.Get(api)
  26169. if requestErr != nil {
  26170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26171. return
  26172. }
  26173. body, ioErr := ioutil.ReadAll(resp.Body)
  26174. fmt.Println(body)
  26175. if ioErr != nil {
  26176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26178. return
  26179. }
  26180. var respJSON map[string]interface{}
  26181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26184. return
  26185. }
  26186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26187. userJSONBytes, _ := json.Marshal(respJSON)
  26188. var res ResultEight
  26189. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26190. utils.ErrorLog("解析失败:%v", err)
  26191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26192. return
  26193. }
  26194. }
  26195. // 对账明细
  26196. func (c *HisApiController) GetCheckDetailAccount() {
  26197. start_time := c.GetString("start_time")
  26198. end_time := c.GetString("end_time")
  26199. admin_user_id, _ := c.GetInt64("admin_user_id")
  26200. adminUser := c.GetAdminUserInfo()
  26201. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26202. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26203. timeLayout := "2006-01-02"
  26204. loc, _ := time.LoadLocation("Local")
  26205. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  26206. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  26207. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  26208. rand.Seed(time.Now().UnixNano())
  26209. num := rand.Intn(30000)
  26210. Mkdir(miConfig.OrgName)
  26211. file := strconv.FormatInt(int64(num), 10)
  26212. file_name := file + ".txt"
  26213. zip_name := file + ".zip"
  26214. zip_path := miConfig.OrgName + "/" + zip_name
  26215. file_path := miConfig.OrgName + "/" + file_name
  26216. decimal.DivisionPrecision = 2
  26217. var medfee_sumamt float64
  26218. var psn_cash_pay float64
  26219. var fund_pay_sumamt float64
  26220. fixmedins_setl_cnt := int64(len(orders))
  26221. for _, item := range orders {
  26222. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  26223. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  26224. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  26225. }
  26226. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  26227. defer f.Close()
  26228. if err != nil {
  26229. fmt.Println(err.Error())
  26230. } else {
  26231. for _, item := range orders {
  26232. var refd_setl_flag string
  26233. if item.OrderStatus == 2 {
  26234. refd_setl_flag = "0"
  26235. var str string
  26236. str = item.SetlId + " " +
  26237. item.MdtrtId + " " +
  26238. item.PsnNo + " " +
  26239. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26240. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26241. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  26242. _, err = f.Write([]byte(str))
  26243. }
  26244. if item.OrderStatus == 3 {
  26245. var str string
  26246. str = item.SetlId + " " +
  26247. item.MdtrtId + " " +
  26248. item.PsnNo + " " +
  26249. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26250. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26251. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  26252. _, err = f.Write([]byte(str))
  26253. var str2 string
  26254. str2 = item.SetlId + " " +
  26255. item.MdtrtId + " " +
  26256. item.PsnNo + " " +
  26257. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  26258. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  26259. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  26260. _, err = f.Write([]byte(str2))
  26261. }
  26262. }
  26263. }
  26264. Zip(file_path, zip_path)
  26265. fmt.Println(ReadFile(zip_path))
  26266. fmt.Println(string(ReadFile(zip_path)))
  26267. if config.IsOpen == 1 {
  26268. var user_name string
  26269. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26270. if role.ID == 0 {
  26271. user_name = "管理员"
  26272. } else {
  26273. user_name = role.UserName
  26274. }
  26275. baseParams := models.BaseParams{
  26276. SecretKey: miConfig.SecretKey,
  26277. FixmedinsCode: miConfig.Code,
  26278. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26279. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26280. OrgName: miConfig.OrgName,
  26281. Doctor: user_name,
  26282. }
  26283. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  26284. var dat map[string]interface{}
  26285. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26286. fmt.Println(dat)
  26287. } else {
  26288. fmt.Println(err)
  26289. }
  26290. userJSONBytes, _ := json.Marshal(dat)
  26291. var res ResultNine
  26292. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26293. utils.ErrorLog("解析失败:%v", err)
  26294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26295. return
  26296. }
  26297. if res.Infcode == 0 {
  26298. fileNo := res.Output.FileQuryNo
  26299. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  26300. "file_qury_no=" + fileNo +
  26301. "&setl_optins=" + "定点医保中心" +
  26302. "&stmt_begndate=" + start_time +
  26303. "&stm_enddate=" + end_time +
  26304. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26305. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26306. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  26307. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26308. "&fixmedins_code=" + miConfig.Code +
  26309. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26310. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26311. "&secret_key=" + miConfig.SecretKey +
  26312. "&org_name=" + miConfig.OrgName +
  26313. "&doctor=" + user_name
  26314. resp, requestErr := http.Get(api)
  26315. if requestErr != nil {
  26316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26317. return
  26318. }
  26319. body, ioErr := ioutil.ReadAll(resp.Body)
  26320. if ioErr != nil {
  26321. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26323. return
  26324. }
  26325. var respJSON map[string]interface{}
  26326. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26329. return
  26330. }
  26331. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26332. userJSONBytes, _ := json.Marshal(respJSON)
  26333. var res ResultTen
  26334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26335. utils.ErrorLog("解析失败:%v", err)
  26336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26337. return
  26338. }
  26339. if res.Infcode == 0 {
  26340. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  26341. micc := &models.MedicalInsuranceCostCompare{
  26342. StartTime: startime.Unix(),
  26343. EndTime: endtime.Unix(),
  26344. Insutype: "0",
  26345. CheckType: 2,
  26346. Num: fixmedins_setl_cnt,
  26347. Mtime: time.Now().Unix(),
  26348. Status: 1,
  26349. UserOrgId: adminUser.CurrentOrgId,
  26350. CostTotal: medfee_sumamt,
  26351. FuncTotal: fund_pay_sumamt,
  26352. PsnPay: psn_cash_pay,
  26353. Creator: admin_user_id,
  26354. Ctime: time.Now().Unix(),
  26355. }
  26356. service.CreateMedicalInsuranceCostCompareRecord(micc)
  26357. c.ServeSuccessJSON(map[string]interface{}{
  26358. "msg": "明细对账成功",
  26359. })
  26360. }
  26361. } else {
  26362. }
  26363. }
  26364. }
  26365. type CustomOrderInfo struct {
  26366. Name string
  26367. Spec string
  26368. Unit string
  26369. Count float64
  26370. Price float64
  26371. Total float64
  26372. }
  26373. func (c *HisApiController) GetBatchSettleAccounts() {
  26374. admin_user_id, _ := c.GetInt64("admin_user_id")
  26375. order_ids := c.GetString("order_ids")
  26376. order_ids_arr := strings.Split(order_ids, ",")
  26377. data3 := []map[string]interface{}{}
  26378. for _, item := range order_ids_arr {
  26379. id, _ := strconv.ParseInt(item, 10, 64)
  26380. order_id := id
  26381. adminUser := c.GetAdminUserInfo()
  26382. order, _ := service.GetHisOrderByID(order_id)
  26383. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26384. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26385. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26386. orderInfos = append(orderInfos, orderInfos_two...)
  26387. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26388. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26389. var diagnosis_ids []string
  26390. if his.ID > 0 {
  26391. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26392. } else {
  26393. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26394. }
  26395. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26396. var dia_config []*models.HisXtDiagnoseConfig
  26397. var name string
  26398. for _, item := range diagnosis_ids {
  26399. id, _ := strconv.ParseInt(item, 10, 64)
  26400. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26401. dia_config = append(dia_config, &diagnosisConfig)
  26402. if len(name) == 0 {
  26403. name = diagnosisConfig.ClassName
  26404. }
  26405. //} else {
  26406. // name = name + "," + diagnosisConfig.ClassName
  26407. //}
  26408. }
  26409. var bedCostTotal float64 = 0 //床位总费
  26410. var bedCostSelfTotal float64 = 0 //床位自费
  26411. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26412. var bedSelfTotal float64 = 0 //床位部分项目自费
  26413. var bedInscpTotal float64 = 0 //床位部分项目自费
  26414. var operationCostTotal float64 = 0 //手术费
  26415. var operationCostSelfTotal float64 = 0 //手术费
  26416. var operationCostPartSelfTotal float64 = 0 //手术费
  26417. var operationSelfTotal float64 = 0 //床位部分项目自费
  26418. var operationInscpTotal float64 = 0 //床位部分项目自费
  26419. var otherCostTotal float64 = 0 //其他费用
  26420. var otherCostSelfTotal float64 = 0 //其他费用
  26421. var otherCostPartSelfTotal float64 = 0 //其他费用
  26422. var otherSelfTotal float64 = 0 //床位部分项目自费
  26423. var otherInscpTotal float64 = 0 //床位部分项目自费
  26424. var materialCostTotal float64 = 0 //材料费
  26425. var materialCostSelfTotal float64 = 0 //材料费
  26426. var materialCostPartSelfTotal float64 = 0 //材料费
  26427. var materialSelfTotal float64 = 0 //床位部分项目自费
  26428. var materialInscpTotal float64 = 0 //床位部分项目自费
  26429. var westernMedicineCostTotal float64 = 0 //西药费
  26430. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26431. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26432. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26433. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26434. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26435. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26436. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26437. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26438. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26439. var checkCostTotal float64 = 0 //检查费
  26440. var checkCostSelfTotal float64 = 0 //检查费
  26441. var checkCostPartSelfTotal float64 = 0 //检查费
  26442. var checkSelfTotal float64 = 0 //床位部分项目自费
  26443. var checkInscpTotal float64 = 0 //床位部分项目自费
  26444. var laboratoryCostTotal float64 = 0 //化验费
  26445. var laboratoryCostSelfTotal float64 = 0 //化验费
  26446. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26447. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26448. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26449. var treatCostTotal float64 = 0 //治疗费用
  26450. var treatCostSelfTotal float64 = 0 //治疗费用
  26451. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26452. var treatSelfTotal float64 = 0 //床位部分项目自费
  26453. var treatInscpTotal float64 = 0 //床位部分项目自费
  26454. decimal.DivisionPrecision = 2
  26455. for _, item := range orderInfos {
  26456. if item.MedChrgitmType == "01" { //床位费
  26457. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26458. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26459. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26460. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26461. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26462. }
  26463. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26464. if item.MedChrgitmType == "03" { //检查费
  26465. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26466. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26467. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26468. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26469. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26470. }
  26471. } else {
  26472. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26473. fmt.Println("------------")
  26474. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26475. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26476. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26477. }
  26478. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26479. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26480. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26481. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26482. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26483. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26484. }
  26485. }
  26486. if item.MedChrgitmType == "04" { //化验费
  26487. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26488. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26489. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26490. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26491. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26492. }
  26493. if item.MedChrgitmType == "05" { //治疗费
  26494. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26495. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26496. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26497. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26498. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26499. }
  26500. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26501. fmt.Println("------------")
  26502. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26503. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26504. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26505. }
  26506. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26507. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26508. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26509. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26510. }
  26511. //if item.MedChrgitmType == "06" { //手术费
  26512. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26513. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26514. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26515. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26516. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26517. //
  26518. //}
  26519. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26520. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26521. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26522. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26523. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26524. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26525. }
  26526. if item.MedChrgitmType == "09" { //西药费
  26527. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26528. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26529. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26530. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26531. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26532. }
  26533. if item.MedChrgitmType == "11" { //中成费
  26534. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26535. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26536. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26537. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26538. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26539. }
  26540. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26541. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26542. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26543. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26544. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26545. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26546. }
  26547. }
  26548. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26549. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26550. var user_name string
  26551. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26552. if role.ID == 0 {
  26553. user_name = "管理员"
  26554. } else {
  26555. user_name = role.UserName
  26556. }
  26557. baseParams := models.BaseParams{
  26558. SecretKey: miConfig.SecretKey,
  26559. FixmedinsCode: miConfig.Code,
  26560. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26561. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26562. OrgName: miConfig.OrgName,
  26563. Doctor: user_name,
  26564. RequestUrl: miConfig.Url,
  26565. AccessKey: miConfig.AccessKey,
  26566. }
  26567. businessParams := models.BusinessParams{
  26568. PsnNo: order.PsnNo,
  26569. MdtrtId: order.MdtrtId,
  26570. SetlId: order.SetlId,
  26571. }
  26572. var res ResultEleven
  26573. var resEleven10265 ResultEleven10265
  26574. if config.IsOpen == 1 {
  26575. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  26576. result := service.Gdyb5203(baseParams, businessParams)
  26577. service.Gdyb5204(baseParams, businessParams)
  26578. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  26579. var dat map[string]interface{}
  26580. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26581. fmt.Println(dat)
  26582. } else {
  26583. fmt.Println(err)
  26584. }
  26585. userJSONBytes, _ := json.Marshal(dat)
  26586. if miConfig.Code == "H15049901371" {
  26587. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  26588. utils.ErrorLog("解析失败:%v", err)
  26589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26590. return
  26591. }
  26592. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26593. res.Output = resEleven10265.Output
  26594. res.ErrMsg = resEleven10265.ErrMsg
  26595. res.Cainfo = resEleven10265.Cainfo
  26596. res.WarnMsg = resEleven10265.WarnMsg
  26597. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26598. res.Infcode = infocode
  26599. } else {
  26600. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26601. utils.ErrorLog("解析失败:%v", err)
  26602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26603. return
  26604. }
  26605. }
  26606. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26607. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  26608. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  26609. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26610. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  26611. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26612. var doctor_name string
  26613. if roles.ID == 0 {
  26614. doctor_name = "管理员"
  26615. } else {
  26616. doctor_name = roles.UserName
  26617. }
  26618. yiliao_leibie := ""
  26619. switch order.MedType {
  26620. case "11":
  26621. yiliao_leibie = "普通门诊"
  26622. break
  26623. case "12":
  26624. yiliao_leibie = "门诊挂号"
  26625. break
  26626. case "13":
  26627. yiliao_leibie = "急诊"
  26628. break
  26629. case "14":
  26630. yiliao_leibie = "门诊特殊病"
  26631. break
  26632. case "15":
  26633. yiliao_leibie = "门诊统筹"
  26634. break
  26635. case "16":
  26636. yiliao_leibie = "门诊慢性病"
  26637. break
  26638. case "21":
  26639. yiliao_leibie = "普通住院"
  26640. break
  26641. }
  26642. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26643. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  26644. if res.Infcode == 0 {
  26645. data2 := map[string]interface{}{
  26646. "diagnosis": name,
  26647. "order_infos": orderInfos,
  26648. "number": order.MdtrtId,
  26649. "date": order.SettleAccountsDate,
  26650. "charge_admin": charge_admin,
  26651. "printor_admin": printor_admin,
  26652. "info": res.Output.Setlinfo,
  26653. "order": order,
  26654. "bedCostTotal": bedCostTotal,
  26655. "bedCostSelfTotal": bedCostSelfTotal,
  26656. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26657. "bedSelfTotal": bedSelfTotal,
  26658. "bedInscpTotal": bedInscpTotal,
  26659. "operationCostTotal": operationCostTotal,
  26660. "operationCostSelfTotal": operationCostSelfTotal,
  26661. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26662. "operationSelfTotal": operationSelfTotal,
  26663. "operationInscpTotal": operationInscpTotal,
  26664. "otherCostTotal": otherCostTotal,
  26665. "otherCostSelfTotal": otherCostSelfTotal,
  26666. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26667. "otherSelfTotal": otherSelfTotal,
  26668. "otherInscpTotal": otherInscpTotal,
  26669. "materialCostTotal": materialCostTotal,
  26670. "materialCostSelfTotal": materialCostSelfTotal,
  26671. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26672. "materialSelfTotal": materialSelfTotal,
  26673. "materialInscpTotal": materialInscpTotal,
  26674. "westernMedicineCostTotal": westernMedicineCostTotal,
  26675. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26676. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26677. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26678. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26679. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26680. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26681. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26682. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26683. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26684. "checkCostTotal": checkCostTotal,
  26685. "checkCostSelfTotal": checkCostSelfTotal,
  26686. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26687. "checkSelfTotal": checkSelfTotal,
  26688. "checkInscpTotal": checkInscpTotal,
  26689. "laboratoryCostTotal": laboratoryCostTotal,
  26690. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26691. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26692. "laboratorySelfTotal": laboratorySelfTotal,
  26693. "laboratoryInscpTotal": laboratoryInscpTotal,
  26694. "treatCostTotal": treatCostTotal,
  26695. "treatCostSelfTotal": treatCostSelfTotal,
  26696. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26697. "treatSelfTotal": treatSelfTotal,
  26698. "treatInscpTotal": treatInscpTotal,
  26699. "doctor_info": doctor_info,
  26700. "doctor_code": adminRole_two.DoctorCode,
  26701. "doctor_name": doctor_name,
  26702. "health_card_no": order.PsnNo,
  26703. "department": departments.Name,
  26704. "yiliao_leibie": yiliao_leibie,
  26705. "after_money": order.AccountPrice,
  26706. "patient": patient,
  26707. "org_name": miConfig.OrgName,
  26708. "org_code": miConfig.Code,
  26709. "order_number": order.Number,
  26710. "his_hospital": his_hospital,
  26711. "his": his,
  26712. "dia_config": dia_config,
  26713. "psn_cash_pay": order.PsnCashPay,
  26714. //"check_order_info": cus_slice,
  26715. }
  26716. data3 = append(data3, data2)
  26717. }
  26718. }
  26719. }
  26720. c.ServeSuccessJSON(map[string]interface{}{
  26721. "infos": data3,
  26722. })
  26723. }
  26724. func (c *HisApiController) GetSettleAccounts() {
  26725. //id, _ := c.GetInt64("id")
  26726. //record_time := c.GetString("record_time")
  26727. order_id, _ := c.GetInt64("order_id")
  26728. admin_user_id, _ := c.GetInt64("admin_user_id")
  26729. //timeLayout := "2006-01-02"
  26730. //loc, _ := time.LoadLocation("Local")
  26731. //
  26732. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26733. //if err != nil {
  26734. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26735. // return
  26736. //}Hbyb5203
  26737. //recordDateTime := theTime.Unix()
  26738. adminUser := c.GetAdminUserInfo()
  26739. order, _ := service.GetHisOrderByID(order_id)
  26740. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26741. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26742. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26743. orderInfos = append(orderInfos, orderInfos_two...)
  26744. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26745. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26746. var diagnosis_ids []string
  26747. if his.ID > 0 {
  26748. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26749. } else {
  26750. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26751. }
  26752. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26753. var dia_config []*models.HisXtDiagnoseConfig
  26754. var name string
  26755. for _, item := range diagnosis_ids {
  26756. id, _ := strconv.ParseInt(item, 10, 64)
  26757. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26758. dia_config = append(dia_config, &diagnosisConfig)
  26759. if len(name) == 0 {
  26760. name = diagnosisConfig.ClassName
  26761. } else {
  26762. name = name + "," + diagnosisConfig.ClassName
  26763. }
  26764. }
  26765. if patient.UserOrgId == 10215 {
  26766. name = "慢性肾功能不全(血透治疗)"
  26767. }
  26768. var bedCostTotal float64 = 0 //床位总费
  26769. var bedCostSelfTotal float64 = 0 //床位自费
  26770. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26771. var bedSelfTotal float64 = 0 //床位部分项目自费
  26772. var bedInscpTotal float64 = 0 //床位部分项目自费
  26773. var operationCostTotal float64 = 0 //手术费
  26774. var operationCostSelfTotal float64 = 0 //手术费
  26775. var operationCostPartSelfTotal float64 = 0 //手术费
  26776. var operationSelfTotal float64 = 0 //床位部分项目自费
  26777. var operationInscpTotal float64 = 0 //床位部分项目自费
  26778. var otherCostTotal float64 = 0 //其他费用
  26779. var otherCostSelfTotal float64 = 0 //其他费用
  26780. var otherCostPartSelfTotal float64 = 0 //其他费用
  26781. var otherSelfTotal float64 = 0 //床位部分项目自费
  26782. var otherInscpTotal float64 = 0 //床位部分项目自费
  26783. var materialCostTotal float64 = 0 //材料费
  26784. var materialCostSelfTotal float64 = 0 //材料费
  26785. var materialCostPartSelfTotal float64 = 0 //材料费
  26786. var materialSelfTotal float64 = 0 //床位部分项目自费
  26787. var materialInscpTotal float64 = 0 //床位部分项目自费
  26788. var westernMedicineCostTotal float64 = 0 //西药费
  26789. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26790. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26791. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26792. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26793. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26794. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26795. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26796. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26797. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26798. var checkCostTotal float64 = 0 //检查费
  26799. var checkCostSelfTotal float64 = 0 //检查费
  26800. var checkCostPartSelfTotal float64 = 0 //检查费
  26801. var checkSelfTotal float64 = 0 //床位部分项目自费
  26802. var checkInscpTotal float64 = 0 //床位部分项目自费
  26803. var laboratoryCostTotal float64 = 0 //化验费
  26804. var laboratoryCostSelfTotal float64 = 0 //化验费
  26805. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26806. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26807. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26808. var treatCostTotal float64 = 0 //治疗费用
  26809. var treatCostSelfTotal float64 = 0 //治疗费用
  26810. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26811. var treatSelfTotal float64 = 0 //床位部分项目自费
  26812. var treatInscpTotal float64 = 0 //床位部分项目自费
  26813. decimal.DivisionPrecision = 2
  26814. for _, item := range orderInfos {
  26815. if item.MedChrgitmType == "01" { //床位费
  26816. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26817. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26818. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26819. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26820. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26821. }
  26822. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26823. if item.MedChrgitmType == "03" { //检查费
  26824. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26825. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26826. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26827. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26828. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26829. }
  26830. } else {
  26831. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26832. fmt.Println("------------")
  26833. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26834. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26835. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26836. }
  26837. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26838. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26839. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26840. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26841. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26842. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26843. }
  26844. }
  26845. if item.MedChrgitmType == "04" { //化验费
  26846. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26847. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26848. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26849. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26850. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26851. }
  26852. if item.MedChrgitmType == "05" { //治疗费
  26853. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26854. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26855. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26856. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26857. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26858. }
  26859. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26860. fmt.Println("------------")
  26861. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26862. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26863. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26864. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26865. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26866. }
  26867. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26868. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26869. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26870. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26871. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26872. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26873. }
  26874. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26875. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26876. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26877. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26878. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26879. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26880. }
  26881. if item.MedChrgitmType == "09" { //西药费
  26882. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26883. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26884. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26885. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26886. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26887. }
  26888. if item.MedChrgitmType == "11" { //中成费
  26889. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26890. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26891. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26892. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26893. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26894. }
  26895. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26896. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26897. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26898. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26899. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26900. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26901. }
  26902. }
  26903. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26904. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26905. var user_name string
  26906. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26907. if role.ID == 0 {
  26908. user_name = "管理员"
  26909. } else {
  26910. user_name = role.UserName
  26911. }
  26912. baseParams := models.BaseParams{
  26913. SecretKey: miConfig.SecretKey,
  26914. FixmedinsCode: miConfig.Code,
  26915. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26916. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26917. OrgName: miConfig.OrgName,
  26918. Doctor: user_name,
  26919. RequestUrl: miConfig.Url,
  26920. AccessKey: miConfig.AccessKey,
  26921. }
  26922. businessParams := models.BusinessParams{
  26923. PsnNo: order.PsnNo,
  26924. MdtrtId: order.MdtrtId,
  26925. SetlId: order.SetlId,
  26926. }
  26927. var res ResultEleven
  26928. var resah ResultElevenah
  26929. var resEleven10265 ResultEleven10265
  26930. if config.IsOpen == 1 {
  26931. if miConfig.MdtrtareaAdmvs == "421300" {
  26932. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26933. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26934. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26935. resp, requestErr := http.Get(api)
  26936. if requestErr != nil {
  26937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26938. return
  26939. }
  26940. body, ioErr := ioutil.ReadAll(resp.Body)
  26941. if ioErr != nil {
  26942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26944. return
  26945. }
  26946. var respJSON map[string]interface{}
  26947. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26950. return
  26951. }
  26952. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26953. result, _ := json.Marshal(respJSON)
  26954. fmt.Println("log")
  26955. fmt.Println(string(result))
  26956. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26957. utils.ErrorLog("解析失败:%v", err)
  26958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26959. return
  26960. }
  26961. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26962. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26963. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26964. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26965. resp, requestErr := http.Get(api)
  26966. if requestErr != nil {
  26967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26968. return
  26969. }
  26970. body, ioErr := ioutil.ReadAll(resp.Body)
  26971. if ioErr != nil {
  26972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26974. return
  26975. }
  26976. var respJSON map[string]interface{}
  26977. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26980. return
  26981. }
  26982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26983. result, _ := json.Marshal(respJSON)
  26984. fmt.Println("log")
  26985. fmt.Println(string(result))
  26986. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26987. utils.ErrorLog("解析失败:%v", err)
  26988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26989. return
  26990. }
  26991. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26992. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26993. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26994. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26995. resp, requestErr := http.Get(api)
  26996. if requestErr != nil {
  26997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26998. return
  26999. }
  27000. body, ioErr := ioutil.ReadAll(resp.Body)
  27001. if ioErr != nil {
  27002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27004. return
  27005. }
  27006. var respJSON map[string]interface{}
  27007. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27010. return
  27011. }
  27012. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27013. result, _ := json.Marshal(respJSON)
  27014. fmt.Println("log")
  27015. fmt.Println(string(result))
  27016. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27017. utils.ErrorLog("解析失败:%v", err)
  27018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27019. return
  27020. }
  27021. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27022. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27023. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27024. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  27025. resp, requestErr := http.Get(api)
  27026. if requestErr != nil {
  27027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27028. return
  27029. }
  27030. body, ioErr := ioutil.ReadAll(resp.Body)
  27031. if ioErr != nil {
  27032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27034. return
  27035. }
  27036. var respJSON map[string]interface{}
  27037. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27040. return
  27041. }
  27042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27043. result, _ := json.Marshal(respJSON)
  27044. fmt.Println("log")
  27045. fmt.Println(string(result))
  27046. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27047. utils.ErrorLog("解析失败:%v", err)
  27048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27049. return
  27050. }
  27051. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27052. var api string
  27053. if miConfig.MdtrtareaAdmvs == "320921" {
  27054. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27055. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27056. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27057. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27058. } else {
  27059. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27060. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27061. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27062. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27063. }
  27064. resp, requestErr := http.Get(api)
  27065. if requestErr != nil {
  27066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27067. return
  27068. }
  27069. body, ioErr := ioutil.ReadAll(resp.Body)
  27070. if ioErr != nil {
  27071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27073. return
  27074. }
  27075. var respJSON map[string]interface{}
  27076. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27079. return
  27080. }
  27081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27082. result, _ := json.Marshal(respJSON)
  27083. fmt.Println("log")
  27084. fmt.Println(string(result))
  27085. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27086. utils.ErrorLog("解析失败:%v", err)
  27087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27088. return
  27089. }
  27090. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27091. res.Output = resEleven10265.Output
  27092. res.ErrMsg = resEleven10265.ErrMsg
  27093. res.Cainfo = resEleven10265.Cainfo
  27094. res.WarnMsg = resEleven10265.WarnMsg
  27095. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27096. res.Infcode = infocode
  27097. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27098. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  27099. saveLog(result, requestLog, "5203", "结算单")
  27100. var dat map[string]interface{}
  27101. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27102. fmt.Println(dat)
  27103. } else {
  27104. fmt.Println(err)
  27105. }
  27106. userJSONBytes, _ := json.Marshal(dat)
  27107. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27108. utils.ErrorLog("解析失败:%v", err)
  27109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27110. return
  27111. }
  27112. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27113. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  27114. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  27115. fmt.Println(result3)
  27116. fmt.Println(requestLog3)
  27117. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  27118. fmt.Println(result2)
  27119. fmt.Println(requestLog2)
  27120. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  27121. saveLog(result, requestLog, "5203", "结算单")
  27122. var dat map[string]interface{}
  27123. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27124. fmt.Println(dat)
  27125. } else {
  27126. fmt.Println(err)
  27127. }
  27128. userJSONBytes, _ := json.Marshal(dat)
  27129. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27130. utils.ErrorLog("解析失败:%v", err)
  27131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27132. return
  27133. }
  27134. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27135. var api string
  27136. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27137. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27138. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27139. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27140. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27141. resp, requestErr := http.Get(api)
  27142. if requestErr != nil {
  27143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27144. return
  27145. }
  27146. body, ioErr := ioutil.ReadAll(resp.Body)
  27147. if ioErr != nil {
  27148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27150. return
  27151. }
  27152. var respJSON map[string]interface{}
  27153. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27156. return
  27157. }
  27158. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27159. if status == "0" {
  27160. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27161. c.ServeSuccessJSON(map[string]interface{}{
  27162. "failed_code": -10,
  27163. "msg": err_msg,
  27164. })
  27165. return
  27166. }
  27167. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27168. result, _ := json.Marshal(respJSON)
  27169. fmt.Println("log")
  27170. fmt.Println(string(result))
  27171. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  27172. utils.ErrorLog("解析失败:%v", err)
  27173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27174. return
  27175. }
  27176. res.InfRefmsgid = resah.InfRefmsgid
  27177. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27178. // 创建对应的Time类型
  27179. t := time.UnixMilli(timestamp)
  27180. // 格式化成指定的日期字符串
  27181. str := t.Format("2006-01-02 15:04:05")
  27182. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27183. // 创建对应的Time类型
  27184. t3 := time.UnixMilli(timestamp2)
  27185. // 格式化成指定的日期字符串
  27186. str2 := t3.Format("2006-01-02 15:04:05")
  27187. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  27188. // 创建对应的Time类型
  27189. t4 := time.UnixMilli(timestamp3)
  27190. // 格式化成指定的日期字符串
  27191. str3 := t4.Format("2006-01-02 15:04:05")
  27192. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  27193. // 创建对应的Time类型
  27194. t5 := time.UnixMilli(timestamp4)
  27195. // 格式化成指定的日期字符串
  27196. str5 := t5.Format("2006-01-02 15:04:05")
  27197. res.Output.Setlinfo.Brdy = str2
  27198. res.Output.Setlinfo.SetlTime = str
  27199. res.Output.Setlinfo.Begndate = str3
  27200. res.Output.Setlinfo.Enddate = str5
  27201. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  27202. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  27203. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  27204. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  27205. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27206. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27207. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  27208. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  27209. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27210. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  27211. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  27212. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  27213. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27214. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  27215. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  27216. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  27217. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  27218. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  27219. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27220. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  27221. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  27222. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27223. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  27224. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  27225. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  27226. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27227. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  27228. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  27229. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  27230. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  27231. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27232. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  27233. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27234. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  27235. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  27236. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  27237. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  27238. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  27239. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  27240. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  27241. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  27242. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  27243. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  27244. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  27245. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  27246. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27247. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  27248. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  27249. //res.Output.Setldetail = resah.Output.Setldetail
  27250. res.ErrMsg = resah.ErrMsg
  27251. res.Cainfo = resah.Cainfo
  27252. res.WarnMsg = resah.WarnMsg
  27253. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27254. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  27255. saveLog(result, requestLog, "5203", "结算单")
  27256. var dat map[string]interface{}
  27257. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27258. fmt.Println(dat)
  27259. } else {
  27260. fmt.Println(err)
  27261. }
  27262. userJSONBytes, _ := json.Marshal(dat)
  27263. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27264. utils.ErrorLog("解析失败:%v", err)
  27265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27266. return
  27267. }
  27268. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27269. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27270. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27271. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27272. resp, requestErr := http.Get(api)
  27273. if requestErr != nil {
  27274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27275. return
  27276. }
  27277. body, ioErr := ioutil.ReadAll(resp.Body)
  27278. if ioErr != nil {
  27279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27281. return
  27282. }
  27283. var respJSON map[string]interface{}
  27284. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27287. return
  27288. }
  27289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27290. result, _ := json.Marshal(respJSON)
  27291. fmt.Println("log")
  27292. fmt.Println(string(result))
  27293. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27294. utils.ErrorLog("解析失败:%v", err)
  27295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27296. return
  27297. }
  27298. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27299. res.Output = resEleven10265.Output
  27300. res.ErrMsg = resEleven10265.ErrMsg
  27301. res.Cainfo = resEleven10265.Cainfo
  27302. res.WarnMsg = resEleven10265.WarnMsg
  27303. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27304. res.Infcode = infocode
  27305. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27306. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27307. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27308. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27309. resp, requestErr := http.Get(api)
  27310. if requestErr != nil {
  27311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27312. return
  27313. }
  27314. body, ioErr := ioutil.ReadAll(resp.Body)
  27315. if ioErr != nil {
  27316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27318. return
  27319. }
  27320. var respJSON map[string]interface{}
  27321. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27324. return
  27325. }
  27326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27327. result, _ := json.Marshal(respJSON)
  27328. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27329. utils.ErrorLog("解析失败:%v", err)
  27330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27331. return
  27332. }
  27333. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27334. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  27335. //return
  27336. } else {
  27337. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27338. if len(his.InsuplcAdmdvs) == 0 {
  27339. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  27340. } else {
  27341. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  27342. }
  27343. result := service.Gdyb5203(baseParams, businessParams)
  27344. //service.Gdyb5204(baseParams, businessParams)
  27345. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  27346. var dat map[string]interface{}
  27347. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27348. fmt.Println(dat)
  27349. } else {
  27350. fmt.Println(err)
  27351. }
  27352. userJSONBytes, _ := json.Marshal(dat)
  27353. if miConfig.Code == "H15049901371" {
  27354. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  27355. utils.ErrorLog("解析失败:%v", err)
  27356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27357. return
  27358. }
  27359. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27360. res.Output = resEleven10265.Output
  27361. res.ErrMsg = resEleven10265.ErrMsg
  27362. res.Cainfo = resEleven10265.Cainfo
  27363. res.WarnMsg = resEleven10265.WarnMsg
  27364. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27365. res.Infcode = infocode
  27366. } else {
  27367. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27368. utils.ErrorLog("解析失败:%v", err)
  27369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27370. return
  27371. }
  27372. }
  27373. }
  27374. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27375. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  27376. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  27377. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27378. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  27379. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27380. var doctor_name string
  27381. if roles.ID == 0 {
  27382. doctor_name = "管理员"
  27383. } else {
  27384. doctor_name = roles.UserName
  27385. }
  27386. yiliao_leibie := ""
  27387. switch order.MedType {
  27388. case "11":
  27389. yiliao_leibie = "普通门诊"
  27390. break
  27391. case "12":
  27392. yiliao_leibie = "门诊挂号"
  27393. break
  27394. case "13":
  27395. yiliao_leibie = "急诊"
  27396. break
  27397. case "14":
  27398. yiliao_leibie = "门诊特殊病"
  27399. break
  27400. case "15":
  27401. yiliao_leibie = "门诊统筹"
  27402. break
  27403. case "16":
  27404. yiliao_leibie = "门诊慢性病"
  27405. break
  27406. case "21":
  27407. yiliao_leibie = "普通住院"
  27408. break
  27409. }
  27410. //var rf []CustomFundPay
  27411. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  27412. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27413. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  27414. if res.Infcode == 0 {
  27415. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  27416. c.ServeSuccessJSON(map[string]interface{}{
  27417. "diagnosis": name,
  27418. "order_infos": orderInfos,
  27419. "number": order.MdtrtId,
  27420. "date": order.SettleAccountsDate,
  27421. "charge_admin": charge_admin,
  27422. "printor_admin": printor_admin,
  27423. "info": res.Output.Setlinfo,
  27424. "order": order,
  27425. "bedCostTotal": bedCostTotal,
  27426. "bedCostSelfTotal": bedCostSelfTotal,
  27427. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27428. "bedSelfTotal": bedSelfTotal,
  27429. "bedInscpTotal": bedInscpTotal,
  27430. "operationCostTotal": operationCostTotal,
  27431. "operationCostSelfTotal": operationCostSelfTotal,
  27432. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27433. "operationSelfTotal": operationSelfTotal,
  27434. "operationInscpTotal": operationInscpTotal,
  27435. "otherCostTotal": otherCostTotal,
  27436. "otherCostSelfTotal": otherCostSelfTotal,
  27437. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27438. "otherSelfTotal": otherSelfTotal,
  27439. "otherInscpTotal": otherInscpTotal,
  27440. "materialCostTotal": materialCostTotal,
  27441. "materialCostSelfTotal": materialCostSelfTotal,
  27442. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27443. "materialSelfTotal": materialSelfTotal,
  27444. "materialInscpTotal": materialInscpTotal,
  27445. "westernMedicineCostTotal": westernMedicineCostTotal,
  27446. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27447. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27448. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27449. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27450. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27451. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27452. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27453. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27454. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27455. "checkCostTotal": checkCostTotal,
  27456. "checkCostSelfTotal": checkCostSelfTotal,
  27457. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27458. "checkSelfTotal": checkSelfTotal,
  27459. "checkInscpTotal": checkInscpTotal,
  27460. "laboratoryCostTotal": laboratoryCostTotal,
  27461. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27462. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27463. "laboratorySelfTotal": laboratorySelfTotal,
  27464. "laboratoryInscpTotal": laboratoryInscpTotal,
  27465. "treatCostTotal": treatCostTotal,
  27466. "treatCostSelfTotal": treatCostSelfTotal,
  27467. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27468. "treatSelfTotal": treatSelfTotal,
  27469. "treatInscpTotal": treatInscpTotal,
  27470. "doctor_info": doctor_info,
  27471. "doctor_code": adminRole_two.DoctorCode,
  27472. "doctor_name": doctor_name,
  27473. "health_card_no": order.PsnNo,
  27474. "department": departments.Name,
  27475. "yiliao_leibie": yiliao_leibie,
  27476. "after_money": order.AccountPrice,
  27477. "patient": patient,
  27478. "org_name": miConfig.OrgName,
  27479. "org_code": miConfig.Code,
  27480. "order_number": order.Number,
  27481. "his_hospital": his_hospital,
  27482. "his": his,
  27483. "dia_config": dia_config,
  27484. "psn_cash_pay": order.PsnCashPay,
  27485. //"funds": rf,
  27486. //"check_order_info": cus_slice,
  27487. })
  27488. } else {
  27489. c.ServeSuccessJSON(map[string]interface{}{
  27490. "diagnosis": name,
  27491. "order_infos": orderInfos,
  27492. "number": order.MdtrtId,
  27493. "date": order.SettleAccountsDate,
  27494. "charge_admin": charge_admin,
  27495. "printor_admin": printor_admin,
  27496. "info": order,
  27497. "order": order,
  27498. "bedCostTotal": bedCostTotal,
  27499. "bedCostSelfTotal": bedCostSelfTotal,
  27500. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27501. "bedSelfTotal": bedSelfTotal,
  27502. "bedInscpTotal": bedInscpTotal,
  27503. "operationCostTotal": operationCostTotal,
  27504. "operationCostSelfTotal": operationCostSelfTotal,
  27505. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27506. "operationSelfTotal": operationSelfTotal,
  27507. "operationInscpTotal": operationInscpTotal,
  27508. "otherCostTotal": otherCostTotal,
  27509. "otherCostSelfTotal": otherCostSelfTotal,
  27510. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27511. "otherSelfTotal": otherSelfTotal,
  27512. "otherInscpTotal": otherInscpTotal,
  27513. "materialCostTotal": materialCostTotal,
  27514. "materialCostSelfTotal": materialCostSelfTotal,
  27515. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27516. "materialSelfTotal": materialSelfTotal,
  27517. "materialInscpTotal": materialInscpTotal,
  27518. "westernMedicineCostTotal": westernMedicineCostTotal,
  27519. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27520. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27521. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27522. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27523. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27524. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27525. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27526. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27527. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27528. "checkCostTotal": checkCostTotal,
  27529. "checkCostSelfTotal": checkCostSelfTotal,
  27530. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27531. "checkSelfTotal": checkSelfTotal,
  27532. "checkInscpTotal": checkInscpTotal,
  27533. "laboratoryCostTotal": laboratoryCostTotal,
  27534. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27535. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27536. "laboratorySelfTotal": laboratorySelfTotal,
  27537. "laboratoryInscpTotal": laboratoryInscpTotal,
  27538. "treatCostTotal": treatCostTotal,
  27539. "treatCostSelfTotal": treatCostSelfTotal,
  27540. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27541. "treatSelfTotal": treatSelfTotal,
  27542. "treatInscpTotal": treatInscpTotal,
  27543. "doctor_info": doctor_info,
  27544. "doctor_code": adminRole_two.DoctorCode,
  27545. "doctor_name": doctor_name,
  27546. "health_card_no": order.PsnNo,
  27547. "department": departments.Name,
  27548. "yiliao_leibie": yiliao_leibie,
  27549. "after_money": order.AccountPrice,
  27550. "patient": patient,
  27551. "org_name": miConfig.OrgName,
  27552. "org_code": miConfig.Code,
  27553. "order_number": order.Number,
  27554. "his_hospital": his_hospital,
  27555. "his": his,
  27556. "dia_config": dia_config,
  27557. "psn_cash_pay": order.PsnCashPay,
  27558. //"funds": rf,
  27559. //"check_order_info": cus_slice,
  27560. })
  27561. }
  27562. }
  27563. }
  27564. }
  27565. //func (c *HisApiController) CheckTreatment() {
  27566. // patient_id, _ := c.GetInt64("patient_id")
  27567. // id_card_no := c.GetString("id_card_no")
  27568. // insutype := c.GetString("insutype")
  27569. // med_type := c.GetString("med_type")
  27570. // admin_user_id, _ := c.GetInt64("admin_user_id")
  27571. //
  27572. // adminUser := c.GetAdminUserInfo()
  27573. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27574. //
  27575. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27576. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27577. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27578. //
  27579. // if miConfig.MdtrtareaAdmvs == "421300" {
  27580. // var res ResultTwo
  27581. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  27582. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27583. // "&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)
  27584. // resp, requestErr := http.Get(api)
  27585. // if requestErr != nil {
  27586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27587. // return
  27588. // }
  27589. //
  27590. // body, ioErr := ioutil.ReadAll(resp.Body)
  27591. // if ioErr != nil {
  27592. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27593. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27594. // return
  27595. // }
  27596. // var respJSON map[string]interface{}
  27597. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27598. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27600. // return
  27601. // }
  27602. //
  27603. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27604. // result, _ := json.Marshal(respJSON)
  27605. //
  27606. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27607. // utils.ErrorLog("解析失败:%v", err)
  27608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27609. // return
  27610. // }
  27611. //
  27612. // if res.Infcode == 0 {
  27613. //
  27614. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  27615. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27616. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  27617. // resp, requestErr := http.Get(api)
  27618. // if requestErr != nil {
  27619. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27620. // return
  27621. // }
  27622. //
  27623. // body, ioErr := ioutil.ReadAll(resp.Body)
  27624. // if ioErr != nil {
  27625. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27627. // return
  27628. // }
  27629. // var respJSON map[string]interface{}
  27630. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27631. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27633. // return
  27634. // }
  27635. // var res Result2001
  27636. //
  27637. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27638. // result2, _ := json.Marshal(respJSON)
  27639. //
  27640. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  27641. // utils.ErrorLog("解析失败:%v", err)
  27642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27643. // return
  27644. // }
  27645. //
  27646. // if res.Infcode == 0 {
  27647. // c.ServeSuccessJSON(map[string]interface{}{
  27648. // "msg": res.Output.Trtinfo,
  27649. // })
  27650. // }
  27651. //
  27652. // } else {
  27653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  27654. // return
  27655. // }
  27656. //
  27657. // } else {
  27658. //
  27659. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  27660. // var dat map[string]interface{}
  27661. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27662. // fmt.Println(dat)
  27663. // } else {
  27664. // fmt.Println(err)
  27665. // }
  27666. // userJSONBytes, _ := json.Marshal(dat)
  27667. // var res ResultTwo
  27668. // var res10265 ResultTwo10265
  27669. // if miConfig.Code == "H15049901371" {
  27670. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27671. // utils.ErrorLog("解析失败:%v", err)
  27672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27673. // return
  27674. // }
  27675. // res.ErrMsg = res10265.ErrMsg
  27676. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27677. // res.Infcode = infocode
  27678. // res.Output = res10265.Output
  27679. // res.InfRefmsgid = res10265.InfRefmsgid
  27680. // } else {
  27681. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27682. // utils.ErrorLog("解析失败:%v", err)
  27683. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27684. // return
  27685. // }
  27686. // }
  27687. //
  27688. // var user_name string
  27689. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  27690. // if role.ID == 0 {
  27691. // user_name = "xxx"
  27692. // } else {
  27693. // user_name = role.UserName
  27694. // }
  27695. //
  27696. // baseParams := models.BaseParams{
  27697. // SecretKey: miConfig.SecretKey,
  27698. // FixmedinsCode: miConfig.Code,
  27699. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27700. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27701. // OrgName: miConfig.OrgName,
  27702. // Doctor: user_name,
  27703. // }
  27704. //
  27705. // if config.IsOpen == 1 {
  27706. // if miConfig.Code == "H15049901371" {
  27707. // if med_type == "14" {
  27708. // if insutype == "390" {
  27709. // med_type = "9933"
  27710. // } else if insutype == "310" {
  27711. // med_type = "990502"
  27712. // }
  27713. // } else if med_type == "11" {
  27714. // med_type = "11"
  27715. // }
  27716. // }
  27717. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  27718. // var dat map[string]interface{}
  27719. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27720. // fmt.Println(dat)
  27721. // } else {
  27722. // fmt.Println(err)
  27723. // }
  27724. // var res Result2001
  27725. // var res10265 Result2001Org10265
  27726. // if miConfig.Code == "H15049901371" {
  27727. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27728. // utils.ErrorLog("解析失败:%v", err)
  27729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27730. // return
  27731. // }
  27732. // res.ErrMsg = res10265.ErrMsg
  27733. // res.Output = res10265.Output
  27734. // res.InfRefmsgid = res10265.InfRefmsgid
  27735. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27736. // res.Infcode = infocode
  27737. // } else {
  27738. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27739. // utils.ErrorLog("解析失败:%v", err)
  27740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27741. // return
  27742. // }
  27743. // }
  27744. // if res.Infcode == 0 {
  27745. // c.ServeSuccessJSON(map[string]interface{}{
  27746. // "msg": res.Output.Trtinfo,
  27747. // })
  27748. // }
  27749. // }
  27750. // }
  27751. //}
  27752. //func (c *HisApiController) PutRecord() {
  27753. // id, _ := c.GetInt64("id")
  27754. // record_time := c.GetString("record_time")
  27755. // timeLayout := "2006-01-02"
  27756. // loc, _ := time.LoadLocation("Local")
  27757. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27758. // if err != nil {
  27759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27760. // return
  27761. // }
  27762. // recordDateTime := theTime.Unix()
  27763. //
  27764. // adminInfo := c.GetAdminUserInfo()
  27765. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  27766. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27767. //
  27768. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27769. //
  27770. // fmt.Println(miConfig.SecretKey)
  27771. //
  27772. // if patient == nil {
  27773. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  27774. // return
  27775. // }
  27776. // if len(patient.IdCardNo) == 0 {
  27777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  27778. // return
  27779. // }
  27780. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  27781. // if config.IsOpen == 1 {
  27782. // 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
  27783. // resp, requestErr := http.Get(api)
  27784. // if requestErr != nil {
  27785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27786. // return
  27787. // }
  27788. // defer resp.Body.Close()
  27789. // body, ioErr := ioutil.ReadAll(resp.Body)
  27790. // if ioErr != nil {
  27791. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27793. // return
  27794. // }
  27795. // var respJSON map[string]interface{}
  27796. //
  27797. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27798. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27799. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27800. // return
  27801. // }
  27802. //
  27803. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27804. // userJSONBytes, _ := json.Marshal(userJSON)
  27805. // var res ResultTwo
  27806. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27807. // utils.ErrorLog("解析失败:%v", err)
  27808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27809. // return
  27810. // }
  27811. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27812. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  27813. // infoStr := string(Iinfos)
  27814. // idetinfoStr := string(Idetinfos)
  27815. //
  27816. // if res.Infcode == 0 {
  27817. // his := models.VMHisPatient{
  27818. // Status: 1,
  27819. // Ctime: time.Now().Unix(),
  27820. // Mtime: time.Now().Unix(),
  27821. // PsnNo: res.Output.Baseinfo.PsnNo,
  27822. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  27823. // Certno: res.Output.Baseinfo.Certno,
  27824. // PsnName: res.Output.Baseinfo.PsnName,
  27825. // Gend: res.Output.Baseinfo.Gend,
  27826. // Naty: res.Output.Baseinfo.Naty,
  27827. // Brdy: res.Output.Baseinfo.Brdy,
  27828. // Age: res.Output.Baseinfo.Age,
  27829. // Iinfo: infoStr,
  27830. // Idetinfo: idetinfoStr,
  27831. // PatientId: patient.ID,
  27832. // RecordDate: theTime.Unix(),
  27833. // UserOrgId: adminInfo.CurrentOrgId,
  27834. // AdminUserId: adminInfo.AdminUser.Id,
  27835. // IsReturn: 1,
  27836. // }
  27837. //
  27838. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  27839. // //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")
  27840. // //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")
  27841. //
  27842. // //var dat map[string]interface{}
  27843. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27844. // // fmt.Println(dat)
  27845. // //} else {
  27846. // // fmt.Println(err)
  27847. // //}
  27848. //
  27849. // var dat2 map[string]interface{}
  27850. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27851. // fmt.Println(dat2)
  27852. // } else {
  27853. // fmt.Println(err)
  27854. // }
  27855. //
  27856. // } else {
  27857. // adminUser := c.GetAdminUserInfo()
  27858. // errlog := &models.HisOrderError{
  27859. // UserOrgId: adminUser.CurrentOrgId,
  27860. // Ctime: time.Now().Unix(),
  27861. // Mtime: time.Now().Unix(),
  27862. // ErrMsg: res.ErrMsg,
  27863. // Status: 1,
  27864. // PatientId: id,
  27865. // RecordTime: recordDateTime,
  27866. // Stage: 1,
  27867. // }
  27868. // service.CreateErrMsgLog(errlog)
  27869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  27870. // return
  27871. // }
  27872. // }
  27873. //
  27874. //}
  27875. //func (c *HisApiController) GetUploadDiag() {
  27876. // id, _ := c.GetInt64("id")
  27877. // record_time := c.GetString("record_time")
  27878. //
  27879. // diagnosis_id, _ := c.GetInt64("diagnosis")
  27880. // sick_type, _ := c.GetInt64("sick_type")
  27881. // reg_type, _ := c.GetInt64("reg_type")
  27882. //
  27883. // timeLayout := "2006-01-02"
  27884. // loc, _ := time.LoadLocation("Local")
  27885. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27886. // if err != nil {
  27887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27888. // return
  27889. // }
  27890. //
  27891. // var patientPrescription models.HisPrescriptionInfo
  27892. // recordDateTime := theTime.Unix()
  27893. // adminInfo := c.GetAdminUserInfo()
  27894. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27895. //
  27896. // if patientPrescription.ID == 0 {
  27897. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27898. // }
  27899. //
  27900. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27901. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27902. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27903. // sickConfig, _ := service.FindSickById(sick_type)
  27904. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27905. //
  27906. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  27907. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  27908. // "&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 +
  27909. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  27910. // resp2, requestErr2 := http.Get(api2)
  27911. // if requestErr2 != nil {
  27912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27913. // return
  27914. // }
  27915. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  27916. // if ioErr2 != nil {
  27917. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  27918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27919. // return
  27920. // }
  27921. // var respJSON2 map[string]interface{}
  27922. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  27923. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27924. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27925. // return
  27926. // }
  27927. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27928. // userJSONBytes2, _ := json.Marshal(respJSON2)
  27929. //
  27930. // var res2 ResultSix
  27931. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27932. // utils.ErrorLog("解析失败:%v", err)
  27933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27934. // return
  27935. // }
  27936. // if res2.Infcode != 0 {
  27937. // adminUser := c.GetAdminUserInfo()
  27938. // errlog := &models.HisOrderError{
  27939. // UserOrgId: adminUser.CurrentOrgId,
  27940. // Ctime: time.Now().Unix(),
  27941. // Mtime: time.Now().Unix(),
  27942. // ErrMsg: res2.ErrMsg,
  27943. // Status: 1,
  27944. // PatientId: id,
  27945. // RecordTime: recordDateTime,
  27946. // Stage: 3,
  27947. // }
  27948. // service.CreateErrMsgLog(errlog)
  27949. //
  27950. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  27951. // return
  27952. // }
  27953. //
  27954. // c.ServeSuccessJSON(map[string]interface{}{
  27955. // "msg": "上传成功",
  27956. // })
  27957. //
  27958. //}
  27959. type QueryResult struct {
  27960. ID int64
  27961. Name string
  27962. Code string
  27963. List_type_code string
  27964. }
  27965. func (c *HisApiController) GetCheckCode() {
  27966. ids_str := c.GetString("ids")
  27967. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27968. ids_arr := strings.Split(ids_str, ",")
  27969. var queryResult []QueryResult
  27970. ids := make([]int64, 0)
  27971. for _, item := range ids_arr {
  27972. id, _ := strconv.ParseInt(item, 10, 64)
  27973. ids = append(ids, id)
  27974. }
  27975. if record_type == 1 {
  27976. drugs, _ := service.GetBatchDrugList(ids)
  27977. for _, item := range drugs {
  27978. result := QueryResult{
  27979. ID: item.ID,
  27980. Name: item.DrugName,
  27981. Code: item.MedicalInsuranceNumber,
  27982. List_type_code: "101",
  27983. }
  27984. queryResult = append(queryResult, result)
  27985. }
  27986. } else if record_type == 2 {
  27987. goods, _ := service.GetBatchGoodInformationList(ids)
  27988. fmt.Println(goods)
  27989. for _, item := range goods {
  27990. result := QueryResult{
  27991. ID: item.ID,
  27992. Name: item.GoodName,
  27993. Code: item.SocialSecurityDirectoryCode,
  27994. List_type_code: "301",
  27995. }
  27996. queryResult = append(queryResult, result)
  27997. }
  27998. } else if record_type == 3 {
  27999. projects, _ := service.GetBathchMyPorjecgList(ids)
  28000. for _, item := range projects {
  28001. result := QueryResult{
  28002. ID: item.ID,
  28003. Name: item.ProjectName,
  28004. Code: item.MedicalCode,
  28005. List_type_code: "201",
  28006. }
  28007. queryResult = append(queryResult, result)
  28008. }
  28009. }
  28010. admin_user_id, _ := c.GetInt64("admin_user_id")
  28011. adminUser := c.GetAdminUserInfo()
  28012. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28013. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28014. var user_name string
  28015. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28016. if role.ID == 0 {
  28017. user_name = "管理员"
  28018. } else {
  28019. user_name = role.UserName
  28020. }
  28021. baseParams := models.BaseParams{
  28022. SecretKey: miConfig.SecretKey,
  28023. FixmedinsCode: miConfig.Code,
  28024. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28025. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28026. OrgName: miConfig.OrgName,
  28027. Doctor: user_name,
  28028. }
  28029. var result string
  28030. if miConfig.MdtrtareaAdmvs == "430800" {
  28031. for _, item := range queryResult {
  28032. if record_type == 1 {
  28033. result, _ = service.Hnyb3301(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2021-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  28034. } else if record_type == 2 {
  28035. fmt.Println(item.Code)
  28036. result, _ = service.Hnyb3301(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2021-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  28037. } else if record_type == 3 {
  28038. result, _ = service.Hnyb3301(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2021-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  28039. }
  28040. var dat map[string]interface{}
  28041. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28042. fmt.Println(dat)
  28043. } else {
  28044. fmt.Println(err)
  28045. }
  28046. userJSONBytes, _ := json.Marshal(dat)
  28047. var res ResultSix
  28048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28049. utils.ErrorLog("解析失败:%v", err)
  28050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28051. return
  28052. }
  28053. if res.Infcode == 0 {
  28054. if record_type == 1 {
  28055. service.UpdateBaseDrugById(item.ID)
  28056. } else if record_type == 2 {
  28057. service.UpdateGoodInformaitonByDetail(item.ID)
  28058. } else if record_type == 3 {
  28059. service.UpdateProjectById(item.ID)
  28060. }
  28061. c.ServeSuccessJSON(map[string]interface{}{
  28062. "failed_code": 0,
  28063. "msg": "目录对照成功",
  28064. })
  28065. } else {
  28066. c.ServeSuccessJSON(map[string]interface{}{
  28067. "failed_code": -10,
  28068. "msg": res.ErrMsg,
  28069. })
  28070. }
  28071. }
  28072. } else {
  28073. for _, item := range queryResult {
  28074. var result string
  28075. if record_type == 1 {
  28076. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28077. } else if record_type == 2 {
  28078. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28079. } else if record_type == 3 {
  28080. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28081. }
  28082. var dat map[string]interface{}
  28083. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28084. fmt.Println(dat)
  28085. } else {
  28086. fmt.Println(err)
  28087. }
  28088. userJSONBytes, _ := json.Marshal(dat)
  28089. var res ResultSix
  28090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28091. utils.ErrorLog("解析失败:%v", err)
  28092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28093. return
  28094. }
  28095. if res.Infcode == 0 {
  28096. if record_type == 1 {
  28097. service.UpdateBaseDrugById(item.ID)
  28098. } else if record_type == 2 {
  28099. service.UpdateGoodInformaitonByDetail(item.ID)
  28100. } else if record_type == 3 {
  28101. service.UpdateProjectById(item.ID)
  28102. }
  28103. c.ServeSuccessJSON(map[string]interface{}{
  28104. "failed_code": 0,
  28105. "msg": "目录对照成功",
  28106. })
  28107. } else {
  28108. c.ServeSuccessJSON(map[string]interface{}{
  28109. "failed_code": -10,
  28110. "msg": res.ErrMsg,
  28111. })
  28112. }
  28113. }
  28114. }
  28115. }
  28116. func (c *HisApiController) UnCheckCode() {
  28117. ids_str := c.GetString("ids")
  28118. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  28119. admin_user_id, _ := c.GetInt64("admin_user_id")
  28120. ids_arr := strings.Split(ids_str, ",")
  28121. var queryResult []QueryResult
  28122. ids := make([]int64, 0)
  28123. for _, item := range ids_arr {
  28124. id, _ := strconv.ParseInt(item, 10, 64)
  28125. ids = append(ids, id)
  28126. }
  28127. if record_type == 1 {
  28128. drugs, _ := service.GetBatchDrugList(ids)
  28129. for _, item := range drugs {
  28130. result := QueryResult{
  28131. ID: item.ID,
  28132. Name: item.DrugName,
  28133. Code: item.MedicalInsuranceNumber,
  28134. List_type_code: "101",
  28135. }
  28136. queryResult = append(queryResult, result)
  28137. }
  28138. } else if record_type == 2 {
  28139. goods, _ := service.GetBatchGoodInformationList(ids)
  28140. for _, item := range goods {
  28141. result := QueryResult{
  28142. ID: item.ID,
  28143. Name: item.GoodName,
  28144. Code: item.SocialSecurityDirectoryCode,
  28145. List_type_code: "301",
  28146. }
  28147. queryResult = append(queryResult, result)
  28148. }
  28149. } else if record_type == 3 {
  28150. projects, _ := service.GetBathchMyPorjecgList(ids)
  28151. for _, item := range projects {
  28152. result := QueryResult{
  28153. ID: item.ID,
  28154. Name: item.ProjectName,
  28155. Code: item.MedicalCode,
  28156. List_type_code: "201",
  28157. }
  28158. queryResult = append(queryResult, result)
  28159. }
  28160. }
  28161. adminUser := c.GetAdminUserInfo()
  28162. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28163. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28164. var user_name string
  28165. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28166. if role.ID == 0 {
  28167. user_name = "xxx"
  28168. } else {
  28169. user_name = role.UserName
  28170. }
  28171. baseParams := &models.BaseParams{
  28172. SecretKey: miConfig.SecretKey,
  28173. FixmedinsCode: miConfig.Code,
  28174. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28175. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28176. OrgName: miConfig.OrgName,
  28177. Doctor: user_name,
  28178. }
  28179. if config.IsOpen == 1 {
  28180. if miConfig.MdtrtareaAdmvs == "430800" {
  28181. for _, item := range queryResult {
  28182. var result string
  28183. if record_type == 1 {
  28184. result, _ = service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2023-08-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  28185. } else if record_type == 2 {
  28186. fmt.Println(item.Code)
  28187. result, _ = service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2023-08-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  28188. } else if record_type == 3 {
  28189. result, _ = service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2023-08-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  28190. }
  28191. var dat map[string]interface{}
  28192. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28193. fmt.Println(dat)
  28194. } else {
  28195. fmt.Println(err)
  28196. }
  28197. userJSONBytes, _ := json.Marshal(dat)
  28198. var res ResultSix
  28199. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28200. utils.ErrorLog("解析失败:%v", err)
  28201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28202. return
  28203. }
  28204. if res.Infcode == 0 {
  28205. if record_type == 1 {
  28206. service.UpdateBaseDrugById(item.ID)
  28207. } else if record_type == 2 {
  28208. service.UpdateGoodInformaitonByDetail(item.ID)
  28209. } else if record_type == 3 {
  28210. service.UpdateProjectById(item.ID)
  28211. }
  28212. c.ServeSuccessJSON(map[string]interface{}{
  28213. "failed_code": 0,
  28214. "msg": "目录对照成功",
  28215. })
  28216. } else {
  28217. c.ServeSuccessJSON(map[string]interface{}{
  28218. "failed_code": -10,
  28219. "msg": res.ErrMsg,
  28220. })
  28221. }
  28222. }
  28223. } else {
  28224. for _, item := range queryResult {
  28225. var result string
  28226. if record_type == 1 {
  28227. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28228. } else if record_type == 2 {
  28229. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28230. } else if record_type == 3 {
  28231. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28232. }
  28233. var dat2 map[string]interface{}
  28234. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  28235. fmt.Println(dat2)
  28236. } else {
  28237. fmt.Println(err)
  28238. }
  28239. userJSONBytes, _ := json.Marshal(dat2)
  28240. var res ResultSix
  28241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28242. utils.ErrorLog("解析失败:%v", err)
  28243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28244. return
  28245. }
  28246. if res.Infcode == 0 {
  28247. if record_type == 1 {
  28248. service.UpdateDrugByIdDetail(item.ID)
  28249. } else if record_type == 2 {
  28250. service.UpdateGoodInfoById(item.ID)
  28251. } else if record_type == 3 {
  28252. service.UpdateMyProjectById(item.ID)
  28253. }
  28254. c.ServeSuccessJSON(map[string]interface{}{
  28255. "failed_code": 0,
  28256. "msg": "撤销目录对照成功",
  28257. })
  28258. } else {
  28259. c.ServeSuccessJSON(map[string]interface{}{
  28260. "failed_code": -10,
  28261. "msg": res.ErrMsg,
  28262. })
  28263. }
  28264. }
  28265. }
  28266. }
  28267. }
  28268. func (c *HisApiController) GetPatientInfo() {
  28269. id_card_no := c.GetString("id_card_no")
  28270. admin_user_id, _ := c.GetInt64("admin_user_id")
  28271. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  28272. if patient.ID == 0 {
  28273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  28274. return
  28275. }
  28276. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  28277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  28278. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  28279. var res ResultTwo
  28280. var res10265 ResultTwo10265
  28281. if config.IsOpen == 1 {
  28282. if miConfig.MdtrtareaAdmvs == "150499" {
  28283. //请求内网数据
  28284. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  28285. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28286. "&insuplc_admdvs=" + "" + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name
  28287. resp, requestErr := http.Get(api)
  28288. if requestErr != nil {
  28289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28290. return
  28291. }
  28292. body, ioErr := ioutil.ReadAll(resp.Body)
  28293. if ioErr != nil {
  28294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28296. return
  28297. }
  28298. var respJSON map[string]interface{}
  28299. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28302. return
  28303. }
  28304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28305. result_byte, _ := json.Marshal(respJSON)
  28306. result := string(result_byte)
  28307. var dat map[string]interface{}
  28308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28309. fmt.Println(dat)
  28310. } else {
  28311. fmt.Println(err)
  28312. }
  28313. userJSONBytes, _ := json.Marshal(dat)
  28314. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28315. utils.ErrorLog("解析失败:%v", err)
  28316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28317. return
  28318. }
  28319. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28320. res.Infcode = Infcode
  28321. res.ErrMsg = res10265.ErrMsg
  28322. res.Output = res10265.Output
  28323. res.InfRefmsgid = res10265.InfRefmsgid
  28324. res.RespondTime = res10265.RespondTime
  28325. res.WarnInfo = res10265.WarnInfo
  28326. } else {
  28327. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  28328. var dat map[string]interface{}
  28329. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28330. fmt.Println(dat)
  28331. } else {
  28332. fmt.Println(err)
  28333. }
  28334. userJSONBytes, _ := json.Marshal(dat)
  28335. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28336. utils.ErrorLog("解析失败:%v", err)
  28337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28338. return
  28339. }
  28340. }
  28341. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28342. // utils.ErrorLog("解析失败:%v", err)
  28343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28344. // return
  28345. //}
  28346. for index, item := range res.Output.Iinfo {
  28347. if item.PsnInsuStas == "2" {
  28348. fmt.Println("--------")
  28349. res.Output.Iinfo[index].Insutype = "300"
  28350. res.Output.Iinfo[index].PsnInsuStas = "1"
  28351. }
  28352. }
  28353. fmt.Println(res.Output.Iinfo)
  28354. if res.Infcode != 0 {
  28355. c.ServeSuccessJSON(map[string]interface{}{
  28356. "failed_code": -10,
  28357. "msg": res.ErrMsg,
  28358. })
  28359. } else {
  28360. c.ServeSuccessJSON(map[string]interface{}{
  28361. "failed_code": 0,
  28362. "info": res,
  28363. })
  28364. }
  28365. }
  28366. }
  28367. func (c *HisApiController) PsnPutOnRecord() {
  28368. record_type, _ := c.GetInt64("type")
  28369. patient_id, _ := c.GetInt64("patient_id")
  28370. admin_user_id, _ := c.GetInt64("admin_user_id")
  28371. start_time := c.GetString("start_time")
  28372. end_time := c.GetString("end_time")
  28373. adminUser := c.GetAdminUserInfo()
  28374. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28375. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28376. var patients []*models.Patients
  28377. if record_type == 1 { //全部备案
  28378. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  28379. patients = append(patients, patient...)
  28380. } else { //单个备案
  28381. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28382. patients = append(patients, patient)
  28383. }
  28384. var user_name string
  28385. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28386. if role.ID == 0 {
  28387. user_name = "xxx"
  28388. } else {
  28389. user_name = role.UserName
  28390. }
  28391. if config.IsOpen == 1 {
  28392. for _, item := range patients {
  28393. 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
  28394. resp, requestErr := http.Get(api)
  28395. if requestErr != nil {
  28396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28397. return
  28398. }
  28399. defer resp.Body.Close()
  28400. body, ioErr := ioutil.ReadAll(resp.Body)
  28401. if ioErr != nil {
  28402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28404. return
  28405. }
  28406. var respJSON map[string]interface{}
  28407. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28410. return
  28411. }
  28412. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28413. userJSONBytes, _ := json.Marshal(userJSON)
  28414. var res ResultTwo
  28415. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28416. utils.ErrorLog("解析失败:%v", err)
  28417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28418. return
  28419. }
  28420. if res.Infcode == 0 {
  28421. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time, admin_user_id)
  28422. var dat map[string]interface{}
  28423. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28424. fmt.Println(dat)
  28425. } else {
  28426. fmt.Println(err)
  28427. }
  28428. userJSONBytes, _ := json.Marshal(dat)
  28429. var res2 ResultThirteen
  28430. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28431. utils.ErrorLog("解析失败:%v", err)
  28432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28433. return
  28434. }
  28435. if res2.Infcode == 0 {
  28436. psnResult := &models.GdybPsnRecord{
  28437. UserOrgId: adminUser.CurrentOrgId,
  28438. PatientId: item.ID,
  28439. PsnNo: res.Output.Baseinfo.PsnNo,
  28440. Ctime: time.Now().Unix(),
  28441. Mtime: time.Now().Unix(),
  28442. Status: 1,
  28443. IsCancel: 1,
  28444. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28445. }
  28446. service.CreatePsnRecord(psnResult)
  28447. } else {
  28448. c.ServeSuccessJSON(map[string]interface{}{
  28449. "failed_code": -10,
  28450. "msg": res2.ErrMsg,
  28451. })
  28452. return
  28453. }
  28454. }
  28455. }
  28456. }
  28457. }
  28458. func (c *HisApiController) PsnUnPutOnRecord() {
  28459. id, _ := c.GetInt64("id")
  28460. //record_type, _ := c.GetInt64("type")
  28461. admin_user_id, _ := c.GetInt64("admin_user_id")
  28462. adminUser := c.GetAdminUserInfo()
  28463. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28464. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28465. var user_name string
  28466. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28467. if role.ID == 0 {
  28468. user_name = "xxx"
  28469. } else {
  28470. user_name = role.UserName
  28471. }
  28472. psn_record, _ := service.GetPsnRecordById(id)
  28473. if psn_record.ID == 0 {
  28474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28475. return
  28476. }
  28477. if config.IsOpen == 1 {
  28478. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28479. var dat map[string]interface{}
  28480. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28481. fmt.Println(dat)
  28482. } else {
  28483. fmt.Println(err)
  28484. }
  28485. userJSONBytes, _ := json.Marshal(dat)
  28486. var res ResultFourteen
  28487. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28488. utils.ErrorLog("解析失败:%v", err)
  28489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28490. return
  28491. }
  28492. if res.Infcode == 0 {
  28493. psn_record.IsCancel = 2
  28494. service.CreatePsnRecord(&psn_record)
  28495. } else {
  28496. c.ServeSuccessJSON(map[string]interface{}{
  28497. "failed_code": -10,
  28498. "msg": res.ErrMsg,
  28499. })
  28500. return
  28501. }
  28502. }
  28503. }
  28504. func (c *HisApiController) PsnPutNCDSOnRecord() {
  28505. patient_id, _ := c.GetInt64("patient_id")
  28506. insutype_two := c.GetString("insutype")
  28507. psn_no := c.GetString("psn_no")
  28508. doctor_id, _ := c.GetInt64("doctor_id")
  28509. sick_id, _ := c.GetInt64("sick_id")
  28510. department_id, _ := c.GetInt64("department_id")
  28511. start_time := c.GetString("start_time")
  28512. end_time := c.GetString("end_time")
  28513. check_time := c.GetString("check_time")
  28514. hospital_code := c.GetString("hospital_code")
  28515. hospital_name := c.GetString("hospital_name")
  28516. adminUser := c.GetAdminUserInfo()
  28517. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28518. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28519. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28520. sick, _ := service.FindSickById(sick_id)
  28521. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28522. if len(hospital_code) == 0 {
  28523. hospital_code = miConfig.Code
  28524. }
  28525. if len(hospital_name) == 0 {
  28526. hospital_name = miConfig.OrgName
  28527. }
  28528. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28529. var res ResultTwo
  28530. var res10265 ResultTwo10265
  28531. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28532. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  28533. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  28534. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28535. "&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
  28536. resp, requestErr := http.Get(api)
  28537. if requestErr != nil {
  28538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28539. return
  28540. }
  28541. body, ioErr := ioutil.ReadAll(resp.Body)
  28542. if ioErr != nil {
  28543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28545. return
  28546. }
  28547. var respJSON map[string]interface{}
  28548. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28551. return
  28552. }
  28553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28554. result, _ := json.Marshal(respJSON)
  28555. fmt.Println("log")
  28556. fmt.Println(string(result))
  28557. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28558. utils.ErrorLog("解析失败:%v", err)
  28559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28560. return
  28561. }
  28562. res.ErrMsg = res10265.ErrMsg
  28563. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28564. res.Infcode = infocode
  28565. res.Output = res10265.Output
  28566. res.InfRefmsgid = res10265.InfRefmsgid
  28567. } else {
  28568. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28569. if miConfig.Code == "H15049901371" {
  28570. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28571. utils.ErrorLog("解析失败:%v", err)
  28572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28573. return
  28574. }
  28575. res.ErrMsg = res10265.ErrMsg
  28576. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28577. res.Infcode = infocode
  28578. res.Output = res10265.Output
  28579. res.InfRefmsgid = res10265.InfRefmsgid
  28580. } else {
  28581. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28582. utils.ErrorLog("解析失败:%v", err)
  28583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28584. return
  28585. }
  28586. }
  28587. }
  28588. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28589. infoStr := string(Iinfos)
  28590. var rf []*ResultFive
  28591. json.Unmarshal([]byte(infoStr), &rf)
  28592. var insuplc_admdvs string
  28593. var insutype string
  28594. var is390 int = 0
  28595. var is310 int = 0
  28596. var insutypes []*ResultFive
  28597. for _, item := range rf {
  28598. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28599. insutypes = append(insutypes, item)
  28600. }
  28601. }
  28602. if len(insutypes) == 1 {
  28603. insutype = insutypes[0].Insutype
  28604. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28605. } else {
  28606. for _, i := range insutypes {
  28607. if i.Insutype == "390" {
  28608. is390 = 1
  28609. }
  28610. if i.Insutype == "310" {
  28611. is310 = 1
  28612. }
  28613. }
  28614. }
  28615. if is390 == 1 {
  28616. insutype = "390"
  28617. }
  28618. if is310 == 1 {
  28619. insutype = "310"
  28620. }
  28621. if len(insutypes) == 2 {
  28622. insutype = insutype_two
  28623. }
  28624. if len(insutypes) == 0 {
  28625. insutype = "310"
  28626. }
  28627. insutype = insutype_two
  28628. fmt.Println(insutype)
  28629. for _, item := range rf {
  28630. fmt.Println(item.Insutype)
  28631. fmt.Println(insutype)
  28632. if item.Insutype == insutype {
  28633. fmt.Println(item.Insutype)
  28634. fmt.Println(insutype)
  28635. insuplc_admdvs = item.InsuplcAdmdvs
  28636. }
  28637. }
  28638. fmt.Println(insuplc_admdvs)
  28639. var res2 ResultThirteen
  28640. var res10265_2 ResultThirteen10265
  28641. if config.IsOpen == 1 {
  28642. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28643. } else {
  28644. if miConfig.MdtrtareaAdmvs == "150499" {
  28645. //
  28646. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  28647. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28648. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  28649. //resp, requestErr := http.Get(api)
  28650. //if requestErr != nil {
  28651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28652. // return
  28653. //}
  28654. //
  28655. //body, ioErr := ioutil.ReadAll(resp.Body)
  28656. //if ioErr != nil {
  28657. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28659. // return
  28660. //}
  28661. //var respJSON map[string]interface{}
  28662. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28663. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28665. // return
  28666. //}
  28667. //
  28668. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28669. //result, _ := json.Marshal(respJSON)
  28670. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  28671. // utils.ErrorLog("解析失败:%v", err)
  28672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28673. // return
  28674. //}
  28675. //infocode = resThree.Infcode
  28676. //result, _ := json.Marshal(respJSON)
  28677. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  28678. // utils.ErrorLog("解析失败:%v", err)
  28679. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28680. // return
  28681. //}
  28682. //
  28683. //resThree.ErrMsg = resThree10265.ErrMsg
  28684. //
  28685. //resThree.Output = resThree10265.Output
  28686. //
  28687. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  28688. //
  28689. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  28690. //
  28691. } else {
  28692. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time, hospital_code, hospital_name)
  28693. var dat map[string]interface{}
  28694. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28695. fmt.Println(dat)
  28696. } else {
  28697. fmt.Println(err)
  28698. }
  28699. userJSONBytes, _ := json.Marshal(dat)
  28700. if miConfig.Code == "H15049901371" {
  28701. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  28702. utils.ErrorLog("解析失败:%v", err)
  28703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28704. return
  28705. }
  28706. res2.ErrMsg = res10265_2.ErrMsg
  28707. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  28708. res2.Infcode = infocode
  28709. res2.Output = res10265_2.Output
  28710. res2.InfRefmsgid = res10265_2.InfRefmsgid
  28711. } else {
  28712. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28713. utils.ErrorLog("解析失败:%v", err)
  28714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28715. return
  28716. }
  28717. }
  28718. }
  28719. }
  28720. if res2.Infcode == 0 {
  28721. psnResult := &models.GdybPsnNcdsRecord{
  28722. UserOrgId: adminUser.CurrentOrgId,
  28723. PatientId: patient.ID,
  28724. PsnNo: psn_no,
  28725. DoctorId: doctor.AdminUserId,
  28726. DepartmentId: department_id,
  28727. SickType: sick_id,
  28728. Insutype: insutype,
  28729. Ctime: time.Now().Unix(),
  28730. Mtime: time.Now().Unix(),
  28731. Status: 1,
  28732. IsCancel: 1,
  28733. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28734. }
  28735. service.CreatePsnNCDSRecord(psnResult)
  28736. c.ServeSuccessJSON(map[string]interface{}{
  28737. "failed_code": 0,
  28738. "msg": "备案成功",
  28739. "result": psnResult,
  28740. })
  28741. } else {
  28742. c.ServeSuccessJSON(map[string]interface{}{
  28743. "failed_code": -10,
  28744. "msg": res2.ErrMsg,
  28745. })
  28746. return
  28747. }
  28748. }
  28749. }
  28750. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  28751. id, _ := c.GetInt64("id")
  28752. admin_user_id, _ := c.GetInt64("admin_user_id")
  28753. adminUser := c.GetAdminUserInfo()
  28754. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28755. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28756. //config, _ := service.Ge(adminUser.CurrentOrgId)
  28757. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  28758. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28759. //var user_name string
  28760. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28761. //if role.ID == 0 {
  28762. // user_name = "xxx"
  28763. //} else {
  28764. // user_name = role.UserName
  28765. //}
  28766. psn_record, _ := service.GetPsnNCDSRecordById(id)
  28767. if psn_record.ID == 0 {
  28768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28769. return
  28770. }
  28771. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28772. var res ResultTwo
  28773. var res10265 ResultTwo10265
  28774. if miConfig.Code == "H15049901371" {
  28775. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28776. utils.ErrorLog("解析失败:%v", err)
  28777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28778. return
  28779. }
  28780. res.ErrMsg = res10265.ErrMsg
  28781. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28782. res.Infcode = infocode
  28783. res.Output = res10265.Output
  28784. res.InfRefmsgid = res10265.InfRefmsgid
  28785. } else {
  28786. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28787. utils.ErrorLog("解析失败:%v", err)
  28788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28789. return
  28790. }
  28791. }
  28792. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28793. infoStr := string(Iinfos)
  28794. var rf []*ResultFive
  28795. json.Unmarshal([]byte(infoStr), &rf)
  28796. var insuplc_admdvs string
  28797. var insutype string
  28798. var is390 int = 0
  28799. var is310 int = 0
  28800. var insutypes []*ResultFive
  28801. for _, item := range rf {
  28802. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28803. insutypes = append(insutypes, item)
  28804. }
  28805. }
  28806. if len(insutypes) == 1 {
  28807. insutype = insutypes[0].Insutype
  28808. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28809. } else {
  28810. for _, i := range insutypes {
  28811. if i.Insutype == "390" {
  28812. is390 = 1
  28813. }
  28814. if i.Insutype == "310" {
  28815. is310 = 1
  28816. }
  28817. }
  28818. }
  28819. if is390 == 1 {
  28820. insutype = "390"
  28821. }
  28822. if is310 == 1 {
  28823. insutype = "310"
  28824. }
  28825. if len(insutypes) == 0 {
  28826. insutype = "310"
  28827. }
  28828. insutype = psn_record.Insutype
  28829. for _, item := range rf {
  28830. if item.Insutype == insutype {
  28831. insuplc_admdvs = item.InsuplcAdmdvs
  28832. }
  28833. }
  28834. if config.IsOpen == 1 {
  28835. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28836. var dat map[string]interface{}
  28837. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28838. fmt.Println(dat)
  28839. } else {
  28840. fmt.Println(err)
  28841. }
  28842. userJSONBytes, _ := json.Marshal(dat)
  28843. var res ResultFourteen
  28844. var res10265 ResultFourteen10265
  28845. if miConfig.Code == "H15049901371" {
  28846. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28847. utils.ErrorLog("解析失败:%v", err)
  28848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28849. return
  28850. }
  28851. res.ErrMsg = res10265.ErrMsg
  28852. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28853. res.Infcode = infocode
  28854. res.Output = res10265.Output
  28855. res.InfRefmsgid = res10265.InfRefmsgid
  28856. } else {
  28857. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28858. utils.ErrorLog("解析失败:%v", err)
  28859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28860. return
  28861. }
  28862. }
  28863. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28864. // utils.ErrorLog("解析失败:%v", err)
  28865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28866. // return
  28867. //}
  28868. if res.Infcode == 0 {
  28869. psn_record.IsCancel = 2
  28870. service.CreatePsnNCDSRecord(&psn_record)
  28871. c.ServeSuccessJSON(map[string]interface{}{
  28872. "failed_code": 0,
  28873. "msg": "撤销备案成功",
  28874. })
  28875. } else {
  28876. c.ServeSuccessJSON(map[string]interface{}{
  28877. "failed_code": -10,
  28878. "msg": res.ErrMsg,
  28879. })
  28880. return
  28881. }
  28882. }
  28883. }
  28884. func (c *HisApiController) TestTest() {
  28885. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  28886. fmt.Println(patient.Iinfo)
  28887. }
  28888. type CustomData struct {
  28889. MsgId string
  28890. PsnNo string
  28891. Info string
  28892. }
  28893. func (c *HisApiController) ReversalData() {
  28894. var customData []*CustomData
  28895. custom := &CustomData{
  28896. MsgId: "H44022900158202103301714472004",
  28897. PsnNo: "44020000001101329945",
  28898. Info: "2207",
  28899. }
  28900. customData = append(customData, custom)
  28901. custom1 := &CustomData{
  28902. MsgId: "H4402290015820210330172057803",
  28903. PsnNo: "44020000001101161813",
  28904. Info: "2207",
  28905. }
  28906. customData = append(customData, custom1)
  28907. custom2 := &CustomData{
  28908. MsgId: "H44022900158202103301705198813",
  28909. PsnNo: "44190000133097375417",
  28910. Info: "2207",
  28911. }
  28912. customData = append(customData, custom2)
  28913. custom3 := &CustomData{
  28914. MsgId: "H44022900158202103301715524756",
  28915. PsnNo: "44020000001100187221",
  28916. Info: "2207",
  28917. }
  28918. customData = append(customData, custom3)
  28919. custom4 := &CustomData{
  28920. MsgId: "H44022900158202103301730376224",
  28921. PsnNo: "44020000001101959155",
  28922. Info: "2207",
  28923. }
  28924. customData = append(customData, custom4)
  28925. custom5 := &CustomData{
  28926. MsgId: "H44022900158202103301748008725",
  28927. PsnNo: "44020000001104246641",
  28928. Info: "2207",
  28929. }
  28930. customData = append(customData, custom5)
  28931. custom6 := &CustomData{
  28932. MsgId: "H44022900158202103301718096755",
  28933. PsnNo: "44020000001102211860",
  28934. Info: "2207",
  28935. }
  28936. customData = append(customData, custom6)
  28937. custom7 := &CustomData{
  28938. MsgId: "H44022900158202103301736551640",
  28939. PsnNo: "44020000001102687718",
  28940. Info: "2207",
  28941. }
  28942. customData = append(customData, custom7)
  28943. custom8 := &CustomData{
  28944. MsgId: "H44022900158202103301743097676",
  28945. PsnNo: "44020000001102127785",
  28946. Info: "2207",
  28947. }
  28948. customData = append(customData, custom8)
  28949. custom9 := &CustomData{
  28950. MsgId: "H44022900158202103301712304203",
  28951. PsnNo: "44020000001101518097",
  28952. Info: "2207",
  28953. }
  28954. customData = append(customData, custom9)
  28955. custom10 := &CustomData{
  28956. MsgId: "H44022900158202103301738448785",
  28957. PsnNo: "44020000001100500813",
  28958. Info: "2207",
  28959. }
  28960. customData = append(customData, custom10)
  28961. custom11 := &CustomData{
  28962. MsgId: "H44022900158202103301732455843",
  28963. PsnNo: "44020000001102690557",
  28964. Info: "2207",
  28965. }
  28966. customData = append(customData, custom11)
  28967. custom12 := &CustomData{
  28968. MsgId: "H44022900158202103301745421708",
  28969. PsnNo: "44020000001102211928",
  28970. Info: "2207",
  28971. }
  28972. customData = append(customData, custom12)
  28973. custom1212 := &CustomData{
  28974. MsgId: "H440229001582021033017351627",
  28975. PsnNo: "44020000001102481733",
  28976. Info: "2207",
  28977. }
  28978. customData = append(customData, custom1212)
  28979. custom13 := &CustomData{
  28980. MsgId: "H44022900158202103301740327951",
  28981. PsnNo: "44020000001103174866",
  28982. Info: "2207",
  28983. }
  28984. customData = append(customData, custom13)
  28985. custom14 := &CustomData{
  28986. MsgId: "H4402290015820210330174922668",
  28987. PsnNo: "44020000001102927272",
  28988. Info: "2207",
  28989. }
  28990. customData = append(customData, custom14)
  28991. custom15 := &CustomData{
  28992. MsgId: "H44022900158202103301752362273",
  28993. PsnNo: "44020000001102942890",
  28994. Info: "2207",
  28995. }
  28996. customData = append(customData, custom15)
  28997. custom16 := &CustomData{
  28998. MsgId: "H44022900158202103301751082917",
  28999. PsnNo: "44020000001101662162",
  29000. Info: "2207",
  29001. }
  29002. customData = append(customData, custom16)
  29003. custom17 := &CustomData{
  29004. MsgId: "H44022900158202103301754147728",
  29005. PsnNo: "44020000000229014511",
  29006. Info: "2207",
  29007. }
  29008. customData = append(customData, custom17)
  29009. adminUser := c.GetAdminUserInfo()
  29010. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29011. for _, item := range customData {
  29012. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29013. fmt.Println(result)
  29014. }
  29015. }
  29016. func (c *HisApiController) GetAllopatry() {
  29017. year := c.GetString("year")
  29018. month := c.GetString("month")
  29019. admin_user_id, _ := c.GetInt64("admin_user_id")
  29020. adminUser := c.GetAdminUserInfo()
  29021. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29022. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29023. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29024. var dat map[string]interface{}
  29025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29026. fmt.Println(dat)
  29027. } else {
  29028. fmt.Println(err)
  29029. }
  29030. userJSONBytes, _ := json.Marshal(dat)
  29031. var res models.Result9001
  29032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29033. utils.ErrorLog("解析失败:%v", err)
  29034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29035. return
  29036. }
  29037. fmt.Println(res.Output.Signinoutb)
  29038. fmt.Println(res.Output.Signinoutb.SignNo)
  29039. fmt.Println(string(userJSONBytes))
  29040. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  29041. var dat3 map[string]interface{}
  29042. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  29043. fmt.Println(dat3)
  29044. } else {
  29045. fmt.Println(err)
  29046. }
  29047. userJSONBytes3, _ := json.Marshal(dat3)
  29048. var res3 models.Result3260
  29049. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  29050. utils.ErrorLog("解析失败:%v", err)
  29051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29052. return
  29053. }
  29054. var curpage int
  29055. var pagesize int = 100
  29056. var start int = 1
  29057. //var stop int
  29058. //pagecount := 10
  29059. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  29060. var res22 []models.Result3260
  29061. for curpage = 1; curpage <= pagecount; curpage++ {
  29062. if curpage == 1 {
  29063. start = 0
  29064. } else {
  29065. start = (curpage-1)*pagesize + 1
  29066. }
  29067. fmt.Println(start)
  29068. //stop = curpage * pagesize
  29069. //if stop > int(res3.Output.Totalrow) {
  29070. // stop =int(res3.Output.Totalrow)
  29071. //}
  29072. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  29073. var dat2 map[string]interface{}
  29074. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29075. fmt.Println(dat)
  29076. } else {
  29077. fmt.Println(err)
  29078. }
  29079. userJSONBytes2, _ := json.Marshal(dat2)
  29080. var res2 models.Result3260
  29081. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29082. utils.ErrorLog("解析失败:%v", err)
  29083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29084. return
  29085. }
  29086. if res2.Infcode == 0 {
  29087. res22 = append(res22, res2)
  29088. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29089. //var dat2 map[string]interface{}
  29090. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  29091. // fmt.Println(dat)
  29092. //} else {
  29093. // fmt.Println(err)
  29094. //}
  29095. //c.ServeSuccessJSON(map[string]interface{}{
  29096. // "list": res2.Output.Data,
  29097. //})
  29098. //continue
  29099. }
  29100. }
  29101. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  29102. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  29103. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  29104. //var dat2 map[string]interface{}
  29105. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29106. // fmt.Println(dat)
  29107. //} else {
  29108. // fmt.Println(err)
  29109. //}
  29110. //userJSONBytes2, _ := json.Marshal(dat2)
  29111. //var res2 models.Result3260
  29112. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29113. // utils.ErrorLog("解析失败:%v", err)
  29114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29115. // return
  29116. //}
  29117. //if res2.Infcode == 0 {
  29118. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29119. // var dat2 map[string]interface{}
  29120. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  29121. // fmt.Println(dat)
  29122. // } else {
  29123. // fmt.Println(err)
  29124. // }
  29125. // c.ServeSuccessJSON(map[string]interface{}{
  29126. // "list": res2.Output.Data,
  29127. // })
  29128. //}
  29129. }
  29130. func (c *HisApiController) ComfirmAllopatry() {
  29131. year := c.GetString("year")
  29132. month := c.GetString("month")
  29133. admin_user_id, _ := c.GetInt64("admin_user_id")
  29134. adminUser := c.GetAdminUserInfo()
  29135. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29136. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29137. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29138. var dat map[string]interface{}
  29139. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29140. fmt.Println(dat)
  29141. } else {
  29142. fmt.Println(err)
  29143. }
  29144. userJSONBytes, _ := json.Marshal(dat)
  29145. var res models.Result9001
  29146. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29147. utils.ErrorLog("解析失败:%v", err)
  29148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29149. return
  29150. }
  29151. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  29152. var dat2 map[string]interface{}
  29153. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29154. fmt.Println(dat)
  29155. } else {
  29156. fmt.Println(err)
  29157. }
  29158. userJSONBytes2, _ := json.Marshal(dat2)
  29159. var res2 models.Result3260
  29160. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29161. utils.ErrorLog("解析失败:%v", err)
  29162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29163. return
  29164. }
  29165. //if res2.Infcode == 0 {
  29166. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29167. // var dat map[string]interface{}
  29168. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29169. // fmt.Println(dat)
  29170. // } else {
  29171. // fmt.Println(err)
  29172. // }
  29173. // userJSONBytes, _ := json.Marshal(dat)
  29174. // var res3 models.Result3261
  29175. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  29176. // utils.ErrorLog("解析失败:%v", err)
  29177. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29178. // return
  29179. // }
  29180. //
  29181. // if res3.Infcode == 0 {
  29182. // record := &models.HisYidiClearRecord{
  29183. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29184. // Ctime: time.Now().Unix(),
  29185. // Mtime: time.Now().Unix(),
  29186. // Status: 1,
  29187. // MsgId: msgId,
  29188. // }
  29189. // service.SaveClearRecord(record)
  29190. // c.ServeSuccessJSON(map[string]interface{}{
  29191. // "msg": "提取成功",
  29192. // })
  29193. // }
  29194. //}
  29195. }
  29196. func (c *HisApiController) RefundAllopatry() {
  29197. year := c.GetString("year")
  29198. month := c.GetString("month")
  29199. //id, _ := c.GetInt64("id")
  29200. admin_user_id, _ := c.GetInt64("admin_user_id")
  29201. adminUser := c.GetAdminUserInfo()
  29202. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29203. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29204. //record, _ := service.GetClearRecordById(id)
  29205. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29206. var dat map[string]interface{}
  29207. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29208. fmt.Println(dat)
  29209. } else {
  29210. fmt.Println(err)
  29211. }
  29212. userJSONBytes, _ := json.Marshal(dat)
  29213. var res models.Result9001
  29214. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29215. utils.ErrorLog("解析失败:%v", err)
  29216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29217. return
  29218. }
  29219. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  29220. var dat2 map[string]interface{}
  29221. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  29222. fmt.Println(dat)
  29223. } else {
  29224. fmt.Println(err)
  29225. }
  29226. userJSONBytes2, _ := json.Marshal(dat2)
  29227. var empty ResultFourteen
  29228. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  29229. utils.ErrorLog("解析失败:%v", err)
  29230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29231. return
  29232. }
  29233. if empty.Infcode == 0 {
  29234. c.ServeSuccessJSON(map[string]interface{}{
  29235. "msg": "撤销成功",
  29236. })
  29237. return
  29238. }
  29239. }
  29240. func (c *HisApiController) ReversalOtherData() {
  29241. var customData []*CustomData
  29242. custom := &CustomData{
  29243. MsgId: "H44022900158202103301714472004",
  29244. PsnNo: "44020000001101329945",
  29245. Info: "2208",
  29246. }
  29247. customData = append(customData, custom)
  29248. custom1 := &CustomData{
  29249. MsgId: "H4402290015820210330172057803",
  29250. PsnNo: "44020000001101161813",
  29251. Info: "2208",
  29252. }
  29253. customData = append(customData, custom1)
  29254. custom2 := &CustomData{
  29255. MsgId: "H44022900158202103301705198813",
  29256. PsnNo: "44190000133097375417",
  29257. Info: "2208",
  29258. }
  29259. customData = append(customData, custom2)
  29260. custom3 := &CustomData{
  29261. MsgId: "H44022900158202103301715524756",
  29262. PsnNo: "44020000001100187221",
  29263. Info: "2208",
  29264. }
  29265. customData = append(customData, custom3)
  29266. custom4 := &CustomData{
  29267. MsgId: "H44022900158202103301730376224",
  29268. PsnNo: "44020000001101959155",
  29269. Info: "2208",
  29270. }
  29271. customData = append(customData, custom4)
  29272. custom5 := &CustomData{
  29273. MsgId: "H44022900158202103301748008725",
  29274. PsnNo: "44020000001104246641",
  29275. Info: "2208",
  29276. }
  29277. customData = append(customData, custom5)
  29278. custom6 := &CustomData{
  29279. MsgId: "H44022900158202103301718096755",
  29280. PsnNo: "44020000001102211860",
  29281. Info: "2208",
  29282. }
  29283. customData = append(customData, custom6)
  29284. custom7 := &CustomData{
  29285. MsgId: "H44022900158202103301736551640",
  29286. PsnNo: "44020000001102687718",
  29287. Info: "2208",
  29288. }
  29289. customData = append(customData, custom7)
  29290. custom8 := &CustomData{
  29291. MsgId: "H44022900158202103301743097676",
  29292. PsnNo: "44020000001102127785",
  29293. Info: "2208",
  29294. }
  29295. customData = append(customData, custom8)
  29296. custom9 := &CustomData{
  29297. MsgId: "H44022900158202103301712304203",
  29298. PsnNo: "44020000001101518097",
  29299. Info: "2208",
  29300. }
  29301. customData = append(customData, custom9)
  29302. custom10 := &CustomData{
  29303. MsgId: "H44022900158202103301738448785",
  29304. PsnNo: "44020000001100500813",
  29305. Info: "2208",
  29306. }
  29307. customData = append(customData, custom10)
  29308. custom11 := &CustomData{
  29309. MsgId: "H44022900158202103301732455843",
  29310. PsnNo: "44020000001102690557",
  29311. Info: "2208",
  29312. }
  29313. customData = append(customData, custom11)
  29314. custom12 := &CustomData{
  29315. MsgId: "H44022900158202103301745421708",
  29316. PsnNo: "44020000001102211928",
  29317. Info: "2208",
  29318. }
  29319. customData = append(customData, custom12)
  29320. custom1212 := &CustomData{
  29321. MsgId: "H440229001582021033017351627",
  29322. PsnNo: "44020000001102481733",
  29323. Info: "2208",
  29324. }
  29325. customData = append(customData, custom1212)
  29326. custom13 := &CustomData{
  29327. MsgId: "H44022900158202103301740327951",
  29328. PsnNo: "44020000001103174866",
  29329. Info: "2208",
  29330. }
  29331. customData = append(customData, custom13)
  29332. custom14 := &CustomData{
  29333. MsgId: "H4402290015820210330174922668",
  29334. PsnNo: "44020000001102927272",
  29335. Info: "2208",
  29336. }
  29337. customData = append(customData, custom14)
  29338. custom15 := &CustomData{
  29339. MsgId: "H44022900158202103301752362273",
  29340. PsnNo: "44020000001102942890",
  29341. Info: "2208",
  29342. }
  29343. customData = append(customData, custom15)
  29344. custom16 := &CustomData{
  29345. MsgId: "H44022900158202103301751082917",
  29346. PsnNo: "44020000001101662162",
  29347. Info: "2208",
  29348. }
  29349. customData = append(customData, custom16)
  29350. custom17 := &CustomData{
  29351. MsgId: "H44022900158202103301754147728",
  29352. PsnNo: "44020000000229014511",
  29353. Info: "2208",
  29354. }
  29355. customData = append(customData, custom17)
  29356. adminUser := c.GetAdminUserInfo()
  29357. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29358. for _, item := range customData {
  29359. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29360. fmt.Println(result)
  29361. }
  29362. }
  29363. func PathExists(path string) (bool, error) {
  29364. _, err := os.Stat(path)
  29365. if err == nil {
  29366. return true, nil
  29367. }
  29368. if os.IsNotExist(err) {
  29369. return false, nil
  29370. }
  29371. return false, err
  29372. }
  29373. // 创建文件夹
  29374. func Mkdir(dir string) {
  29375. // 创建文件夹
  29376. exist, err := PathExists(dir)
  29377. if err != nil {
  29378. fmt.Println(err.Error())
  29379. } else {
  29380. if exist {
  29381. fmt.Println(dir + "文件夹已存在!")
  29382. } else {
  29383. // 文件夹名称,权限
  29384. err := os.Mkdir(dir, os.ModePerm)
  29385. if err != nil {
  29386. fmt.Println(dir+"文件夹创建失败:", err.Error())
  29387. } else {
  29388. fmt.Println(dir + "文件夹创建成功!")
  29389. }
  29390. }
  29391. }
  29392. }
  29393. // 压缩文件
  29394. func Zip(srcFile string, destZip string) error {
  29395. zipfile, err := os.Create(destZip)
  29396. if err != nil {
  29397. return err
  29398. }
  29399. defer zipfile.Close()
  29400. archive := zip.NewWriter(zipfile)
  29401. defer archive.Close()
  29402. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  29403. if err != nil {
  29404. return err
  29405. }
  29406. header, err := zip.FileInfoHeader(info)
  29407. if err != nil {
  29408. return err
  29409. }
  29410. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  29411. // header.Name = path
  29412. if info.IsDir() {
  29413. header.Name += "/"
  29414. } else {
  29415. header.Method = zip.Deflate
  29416. }
  29417. writer, err := archive.CreateHeader(header)
  29418. if err != nil {
  29419. return err
  29420. }
  29421. if !info.IsDir() {
  29422. file, err := os.Open(path)
  29423. if err != nil {
  29424. return err
  29425. }
  29426. defer file.Close()
  29427. _, err = io.Copy(writer, file)
  29428. }
  29429. return err
  29430. })
  29431. return err
  29432. }
  29433. func ReadFile(filePath string) []byte {
  29434. f, err := os.Open(filePath)
  29435. if err != nil {
  29436. fmt.Println("read file fail", err)
  29437. return nil
  29438. }
  29439. defer f.Close()
  29440. fd, err := ioutil.ReadAll(f)
  29441. if err != nil {
  29442. fmt.Println("read to fd fail", err)
  29443. return nil
  29444. }
  29445. return fd
  29446. }
  29447. func saveLogq(result string, request string, infno string, desc string) {
  29448. dir := "日志"
  29449. utils.Mkdir(dir)
  29450. month := time.Unix(1557042972, 0).Format("1")
  29451. year := time.Now().Format("2006")
  29452. month = time.Now().Format("01")
  29453. day := time.Now().Format("02")
  29454. hour := time.Now().Format("15")
  29455. min := time.Now().Format("04")
  29456. sec := time.Now().Format("05")
  29457. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29458. file := year + month + day + "_log"
  29459. file_name := file + ".txt"
  29460. file_path := "日志" + "/" + file_name
  29461. exist, _ := utils.PathExists(file_path)
  29462. if exist { //存在
  29463. fmt.Println("存在")
  29464. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29465. if err != nil {
  29466. fmt.Println("read fail")
  29467. }
  29468. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29469. n, _ := f.Seek(0, 2)
  29470. _, err = f.WriteAt([]byte(content), n)
  29471. } else { //不存在
  29472. fmt.Println("文件不存在,创建文件")
  29473. f, err := os.Create("日志" + "/" + file_name)
  29474. defer f.Close()
  29475. if err != nil {
  29476. } else {
  29477. _, err = f.Write([]byte("记录日志"))
  29478. }
  29479. }
  29480. }
  29481. func saveLog(result string, request string, infno string, desc string) {
  29482. org_id, _ := beego.AppConfig.Int64("org_id")
  29483. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29484. dir := miConfig.OrgName + "日志"
  29485. utils.Mkdir(dir)
  29486. month := time.Unix(1557042972, 0).Format("1")
  29487. year := time.Now().Format("2006")
  29488. month = time.Now().Format("01")
  29489. day := time.Now().Format("02")
  29490. hour := time.Now().Format("15")
  29491. min := time.Now().Format("04")
  29492. sec := time.Now().Format("05")
  29493. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29494. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  29495. file_name := file + ".txt"
  29496. file_path := miConfig.OrgName + "日志" + "/" + file_name
  29497. exist, _ := utils.PathExists(file_path)
  29498. if exist { //存在
  29499. fmt.Println("存在")
  29500. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29501. if err != nil {
  29502. fmt.Println("read fail")
  29503. }
  29504. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29505. n, _ := f.Seek(0, 2)
  29506. _, err = f.WriteAt([]byte(content), n)
  29507. } else { //不存在
  29508. fmt.Println("文件不存在,创建文件")
  29509. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  29510. defer f.Close()
  29511. if err != nil {
  29512. } else {
  29513. _, err = f.Write([]byte("记录日志"))
  29514. }
  29515. }
  29516. }
  29517. type Charset string
  29518. const (
  29519. UTF8 = Charset("UTF-8")
  29520. GB18030 = Charset("GB18030")
  29521. )
  29522. func ConvertToString(src string, srcCode string, tagCode string) string {
  29523. srcCoder := mahonia.NewDecoder(srcCode)
  29524. srcResult := srcCoder.ConvertString(src)
  29525. tagCoder := mahonia.NewDecoder(tagCode)
  29526. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  29527. result := string(cdata)
  29528. return result
  29529. }
  29530. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  29531. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29532. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29533. var token string
  29534. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29535. var api string
  29536. if miConfig.MdtrtareaAdmvs == "320921" {
  29537. api = "http://192.168.2.3:9532/" + "jsyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29538. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  29539. fmt.Println(api)
  29540. } else {
  29541. api = "http://192.168.5.251:9532/" + "jsyb/readcardchargeother?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29542. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  29543. }
  29544. resp, requestErr := http.Get(api)
  29545. if requestErr != nil {
  29546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29547. return ""
  29548. }
  29549. body, ioErr := ioutil.ReadAll(resp.Body)
  29550. if ioErr != nil {
  29551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29553. return ""
  29554. }
  29555. var respJSON map[string]interface{}
  29556. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29559. return ""
  29560. }
  29561. var status string
  29562. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29563. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29564. var res ResultTwo //1101结果
  29565. var res10265 ResultTwo10265 //1101结果
  29566. if status == "0" { //读卡成功
  29567. var card_info string //卡信息
  29568. var busi_card_info string
  29569. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29570. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29571. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29572. fmt.Println(card_info)
  29573. fmt.Println(busi_card_info)
  29574. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29575. result, _ := json.Marshal(respJSON)
  29576. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29577. utils.ErrorLog("解析失败:%v", err)
  29578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29579. return ""
  29580. }
  29581. res.ErrMsg = res10265.ErrMsg
  29582. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29583. res.Infcode = infocode
  29584. res.Output = res10265.Output
  29585. res.InfRefmsgid = res10265.InfRefmsgid
  29586. if res.Infcode == 0 {
  29587. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29588. if err == gorm.ErrRecordNotFound {
  29589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29590. return ""
  29591. } else if err != nil {
  29592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29593. return ""
  29594. } else {
  29595. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29596. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29597. infoStr := string(Iinfos)
  29598. idetinfoStr := string(Idetinfos)
  29599. psn := &models.HisPsn{
  29600. PsnNo: res.Output.Baseinfo.PsnNo,
  29601. PatientId: patient.ID,
  29602. Certno: res.Output.Baseinfo.Certno,
  29603. Gend: res.Output.Baseinfo.Gend,
  29604. Naty: res.Output.Baseinfo.Naty,
  29605. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29606. PsnName: res.Output.Baseinfo.PsnName,
  29607. Idetinfo: idetinfoStr,
  29608. Insuinfo: infoStr,
  29609. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29610. CardInfo: card_info,
  29611. VerifyNumber: token,
  29612. }
  29613. service.CreateHisPsn(psn)
  29614. return token
  29615. }
  29616. }
  29617. } else {
  29618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29619. return ""
  29620. }
  29621. } else { //读卡失败
  29622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29623. return ""
  29624. }
  29625. return token
  29626. }
  29627. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  29628. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29629. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29630. var token string
  29631. var api string
  29632. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29633. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  29634. fmt.Println(api)
  29635. resp, requestErr := http.Get(api)
  29636. if requestErr != nil {
  29637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29638. return ""
  29639. }
  29640. body, ioErr := ioutil.ReadAll(resp.Body)
  29641. if ioErr != nil {
  29642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29644. return ""
  29645. }
  29646. var respJSON map[string]interface{}
  29647. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29650. return ""
  29651. }
  29652. var status string
  29653. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29654. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29655. var res ResultTwo //1101结果
  29656. if status == "1" { //读卡成功
  29657. var card_info string //卡信息
  29658. var busi_card_info string
  29659. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29660. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29661. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29662. fmt.Println(card_info)
  29663. fmt.Println(busi_card_info)
  29664. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29665. result, _ := json.Marshal(respJSON)
  29666. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29667. utils.ErrorLog("解析失败:%v", err)
  29668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29669. return ""
  29670. }
  29671. if res.Infcode == 0 {
  29672. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29673. if err == gorm.ErrRecordNotFound {
  29674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29675. return ""
  29676. } else if err != nil {
  29677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29678. return ""
  29679. } else {
  29680. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29681. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29682. infoStr := string(Iinfos)
  29683. idetinfoStr := string(Idetinfos)
  29684. psn := &models.HisPsn{
  29685. PsnNo: res.Output.Baseinfo.PsnNo,
  29686. PatientId: patient.ID,
  29687. Certno: res.Output.Baseinfo.Certno,
  29688. Gend: res.Output.Baseinfo.Gend,
  29689. Naty: res.Output.Baseinfo.Naty,
  29690. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29691. PsnName: res.Output.Baseinfo.PsnName,
  29692. Idetinfo: idetinfoStr,
  29693. Insuinfo: infoStr,
  29694. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29695. CardInfo: card_info,
  29696. VerifyNumber: token,
  29697. }
  29698. service.CreateHisPsn(psn)
  29699. return token
  29700. }
  29701. }
  29702. } else {
  29703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29704. return ""
  29705. }
  29706. return token
  29707. }
  29708. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  29709. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29710. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29711. var token string
  29712. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29713. var api string
  29714. if miConfig.MdtrtareaAdmvs == "320921" {
  29715. api = "http://192.168.2.3:9532/" + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29716. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  29717. fmt.Println(api)
  29718. } else {
  29719. api = "http://192.168.5.251:9532/" + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29720. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  29721. }
  29722. resp, requestErr := http.Get(api)
  29723. if requestErr != nil {
  29724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29725. return ""
  29726. }
  29727. body, ioErr := ioutil.ReadAll(resp.Body)
  29728. if ioErr != nil {
  29729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29731. return ""
  29732. }
  29733. var respJSON map[string]interface{}
  29734. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29737. return ""
  29738. }
  29739. var status string
  29740. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29741. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29742. var res ResultTwo //1101结果
  29743. var res10265 ResultTwo10265 //1101结果
  29744. if status == "0" { //读卡成功
  29745. var card_info string //卡信息
  29746. var busi_card_info string
  29747. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29748. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29749. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29750. fmt.Println(card_info)
  29751. fmt.Println(busi_card_info)
  29752. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29753. result, _ := json.Marshal(respJSON)
  29754. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29755. utils.ErrorLog("解析失败:%v", err)
  29756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29757. return ""
  29758. }
  29759. res.ErrMsg = res10265.ErrMsg
  29760. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29761. res.Infcode = infocode
  29762. res.Output = res10265.Output
  29763. res.InfRefmsgid = res10265.InfRefmsgid
  29764. if res.Infcode == 0 {
  29765. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29766. if err == gorm.ErrRecordNotFound {
  29767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29768. return ""
  29769. } else if err != nil {
  29770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29771. return ""
  29772. } else {
  29773. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29774. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29775. infoStr := string(Iinfos)
  29776. idetinfoStr := string(Idetinfos)
  29777. psn := &models.HisPsn{
  29778. PsnNo: res.Output.Baseinfo.PsnNo,
  29779. PatientId: patient.ID,
  29780. Certno: res.Output.Baseinfo.Certno,
  29781. Gend: res.Output.Baseinfo.Gend,
  29782. Naty: res.Output.Baseinfo.Naty,
  29783. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29784. PsnName: res.Output.Baseinfo.PsnName,
  29785. Idetinfo: idetinfoStr,
  29786. Insuinfo: infoStr,
  29787. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29788. CardInfo: card_info,
  29789. VerifyNumber: token,
  29790. }
  29791. service.CreateHisPsn(psn)
  29792. return token
  29793. }
  29794. }
  29795. } else {
  29796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29797. return ""
  29798. }
  29799. } else { //读卡失败
  29800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29801. return ""
  29802. }
  29803. return token
  29804. }
  29805. func DeleteExtraSpaceTwo(s string) string {
  29806. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29807. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29808. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29809. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29810. s2 := make([]byte, len(s1)) //定义字符数组切片
  29811. copy(s2, s1) //将字符串复制到切片
  29812. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29813. for len(spc_index) > 0 { //找到适配项
  29814. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29815. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29816. }
  29817. return string(s2)
  29818. }
  29819. func Remove0000(s string) string {
  29820. str := make([]rune, 0, len(s))
  29821. for _, v := range []rune(s) {
  29822. if v == 0 {
  29823. continue
  29824. }
  29825. str = append(str, v)
  29826. }
  29827. return string(str)
  29828. }
  29829. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  29830. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  29831. readCard := DllDef.MustFindProc("EcQuery")
  29832. pCardInfo := make([]byte, 8192)
  29833. pBusiCardInfo := make([]byte, 8192)
  29834. data := make(map[string]interface{})
  29835. //pData := make(map[string]interface{})
  29836. inputData := make(map[string]interface{})
  29837. inputData["orgId"] = code
  29838. inputData["businessType"] = "01101"
  29839. inputData["operatorId"] = operator_id
  29840. inputData["operatorName"] = operator_name
  29841. inputData["officeId"] = "001"
  29842. inputData["officeName"] = "血透室"
  29843. //
  29844. data["data"] = inputData
  29845. data["transType"] = "ec.query"
  29846. data["orgId"] = code
  29847. bytesData, _ := json.Marshal(data)
  29848. pCardInfo = bytesData
  29849. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  29850. fmt.Println(ret2)
  29851. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  29852. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  29853. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  29854. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  29855. if ret2 != 0 {
  29856. return "", ""
  29857. }
  29858. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  29859. }
  29860. func DeleteExtraSpace(s string) string {
  29861. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29862. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29863. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29864. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29865. s2 := make([]byte, len(s1)) //定义字符数组切片
  29866. copy(s2, s1) //将字符串复制到切片
  29867. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29868. for len(spc_index) > 0 { //找到适配项
  29869. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29870. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29871. }
  29872. return string(s2)
  29873. }
  29874. // 对账
  29875. func (c *HisApiController) Post3202() {
  29876. start_time := c.GetString("start_time")
  29877. end_time := c.GetString("end_time")
  29878. //insutype := c.GetString("insutype")
  29879. clr_type := c.GetString("clr_type")
  29880. clr_org := c.GetString("clr_optins")
  29881. admin_user_id, _ := c.GetInt64("admin_user_id")
  29882. adminUser := c.GetAdminUserInfo()
  29883. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29884. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29885. if len(clr_org) == 0 {
  29886. clr_org = miConfig.MdtrtareaAdmvs
  29887. }
  29888. timeLayout := "2006-01-02"
  29889. loc, _ := time.LoadLocation("Local")
  29890. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29891. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29892. var orders []*models.HisOrder
  29893. if clr_org == "421300" {
  29894. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29895. } else {
  29896. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29897. }
  29898. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29899. //fixmedins_setl_cnt := int64(len(orders))
  29900. var medfee_sumamt float64
  29901. var acct_pay float64
  29902. var fund_pay_sumamt float64
  29903. for _, item := range orders {
  29904. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29905. acct_pay = acct_pay + item.AcctPay
  29906. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29907. }
  29908. //var medfee_sumamt_two float64
  29909. //var acct_pay_two float64
  29910. //var fund_pay_sumamt_two float64
  29911. //for _, item := range orders_two {
  29912. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29913. // acct_pay_two = acct_pay_two + item.AcctPay
  29914. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29915. //}
  29916. //var user_name string
  29917. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29918. //if role.ID == 0 {
  29919. // user_name = "xxx"
  29920. //} else {
  29921. // user_name = role.UserName
  29922. //}
  29923. var res ResultSix
  29924. if config.IsOpen == 1 {
  29925. var bps []*models.BusinessParamsTwo
  29926. var bp models.BusinessParamsTwo
  29927. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29928. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29929. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29930. bp.MedfeeSumamt = medfee_sumamt_str
  29931. bp.AcctPay = acct_pay_str
  29932. bp.FundPaySumamt = fund_pay_sumamt_str
  29933. bp.Insutype = ""
  29934. bp.StmtBegndate = start_time
  29935. bp.ClrType = clr_type
  29936. bp.SetlOptins = clr_org
  29937. bp.StmtEnddate = end_time
  29938. bps = append(bps, &bp)
  29939. data := make(map[string]interface{})
  29940. data["bps"] = bps
  29941. data["org_name"] = miConfig.OrgName
  29942. data["doctor"] = role.UserName
  29943. data["fixmedins_code"] = miConfig.Code
  29944. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29945. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29946. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29947. if miConfig.MdtrtareaAdmvs == "421300" {
  29948. client := &http.Client{}
  29949. bytesData, _ := json.Marshal(data)
  29950. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29951. resp, _ := client.Do(req)
  29952. defer resp.Body.Close()
  29953. body, ioErr := ioutil.ReadAll(resp.Body)
  29954. if ioErr != nil {
  29955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29957. return
  29958. }
  29959. var respJSON map[string]interface{}
  29960. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29963. return
  29964. }
  29965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29966. userJSONBytes, _ := json.Marshal(respJSON)
  29967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29968. utils.ErrorLog("解析失败:%v", err)
  29969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29970. return
  29971. }
  29972. }
  29973. if miConfig.MdtrtareaAdmvs == "420200" {
  29974. client := &http.Client{}
  29975. bytesData, _ := json.Marshal(data)
  29976. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29977. resp, _ := client.Do(req)
  29978. defer resp.Body.Close()
  29979. body, ioErr := ioutil.ReadAll(resp.Body)
  29980. if ioErr != nil {
  29981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29983. return
  29984. }
  29985. var respJSON map[string]interface{}
  29986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29989. return
  29990. }
  29991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29992. userJSONBytes, _ := json.Marshal(respJSON)
  29993. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29994. utils.ErrorLog("解析失败:%v", err)
  29995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29996. return
  29997. }
  29998. }
  29999. if miConfig.MdtrtareaAdmvs == "421182" {
  30000. client := &http.Client{}
  30001. bytesData, _ := json.Marshal(data)
  30002. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  30003. resp, _ := client.Do(req)
  30004. defer resp.Body.Close()
  30005. body, ioErr := ioutil.ReadAll(resp.Body)
  30006. if ioErr != nil {
  30007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30009. return
  30010. }
  30011. var respJSON map[string]interface{}
  30012. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30015. return
  30016. }
  30017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30018. userJSONBytes, _ := json.Marshal(respJSON)
  30019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30020. utils.ErrorLog("解析失败:%v", err)
  30021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30022. return
  30023. }
  30024. }
  30025. if res.Infcode == 0 {
  30026. c.ServeSuccessJSON(map[string]interface{}{
  30027. "msg": "发起成功",
  30028. })
  30029. } else {
  30030. c.ServeSuccessJSON(map[string]interface{}{
  30031. "failed_code": -10,
  30032. "msg": res.ErrMsg,
  30033. })
  30034. }
  30035. }
  30036. }
  30037. func (c *HisApiController) Post3202b() {
  30038. start_time := c.GetString("start_time")
  30039. end_time := c.GetString("end_time")
  30040. //insutype := c.GetString("insutype")
  30041. clr_type := c.GetString("clr_type")
  30042. clr_org := c.GetString("clr_optins")
  30043. admin_user_id, _ := c.GetInt64("admin_user_id")
  30044. adminUser := c.GetAdminUserInfo()
  30045. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30046. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30047. if len(clr_org) == 0 {
  30048. clr_org = miConfig.MdtrtareaAdmvs
  30049. }
  30050. timeLayout := "2006-01-02"
  30051. loc, _ := time.LoadLocation("Local")
  30052. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30053. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30054. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30055. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30056. //fixmedins_setl_cnt := int64(len(orders))
  30057. var medfee_sumamt float64
  30058. var acct_pay float64
  30059. var fund_pay_sumamt float64
  30060. for _, item := range orders {
  30061. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30062. acct_pay = acct_pay + item.AcctPay
  30063. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30064. }
  30065. //var medfee_sumamt_two float64
  30066. //var acct_pay_two float64
  30067. //var fund_pay_sumamt_two float64
  30068. //for _, item := range orders_two {
  30069. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  30070. // acct_pay_two = acct_pay_two + item.AcctPay
  30071. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  30072. //}
  30073. //var user_name string
  30074. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30075. //if role.ID == 0 {
  30076. // user_name = "xxx"
  30077. //} else {
  30078. // user_name = role.UserName
  30079. //}
  30080. var res ResultSix
  30081. if config.IsOpen == 1 {
  30082. var bps []*models.BusinessParamsTwo
  30083. var bp models.BusinessParamsTwo
  30084. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30085. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  30086. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  30087. bp.MedfeeSumamt = medfee_sumamt_str
  30088. bp.AcctPay = acct_pay_str
  30089. bp.FundPaySumamt = fund_pay_sumamt_str
  30090. bp.Insutype = "390"
  30091. bp.StmtBegndate = start_time
  30092. bp.ClrType = clr_type
  30093. bp.SetlOptins = clr_org
  30094. bp.StmtEnddate = end_time
  30095. bps = append(bps, &bp)
  30096. data := make(map[string]interface{})
  30097. data["bps"] = bps
  30098. data["org_name"] = miConfig.OrgName
  30099. data["doctor"] = role.UserName
  30100. data["fixmedins_code"] = miConfig.Code
  30101. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30102. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30103. if miConfig.MdtrtareaAdmvs == "421300" {
  30104. client := &http.Client{}
  30105. bytesData, _ := json.Marshal(data)
  30106. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  30107. resp, _ := client.Do(req)
  30108. defer resp.Body.Close()
  30109. body, ioErr := ioutil.ReadAll(resp.Body)
  30110. if ioErr != nil {
  30111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30113. return
  30114. }
  30115. var respJSON map[string]interface{}
  30116. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30119. return
  30120. }
  30121. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30122. userJSONBytes, _ := json.Marshal(respJSON)
  30123. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30124. utils.ErrorLog("解析失败:%v", err)
  30125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30126. return
  30127. }
  30128. }
  30129. if miConfig.MdtrtareaAdmvs == "420200" {
  30130. client := &http.Client{}
  30131. bytesData, _ := json.Marshal(data)
  30132. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  30133. resp, _ := client.Do(req)
  30134. defer resp.Body.Close()
  30135. body, ioErr := ioutil.ReadAll(resp.Body)
  30136. if ioErr != nil {
  30137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30139. return
  30140. }
  30141. var respJSON map[string]interface{}
  30142. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30145. return
  30146. }
  30147. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30148. userJSONBytes, _ := json.Marshal(respJSON)
  30149. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30150. utils.ErrorLog("解析失败:%v", err)
  30151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30152. return
  30153. }
  30154. }
  30155. if miConfig.MdtrtareaAdmvs == "421182" {
  30156. client := &http.Client{}
  30157. bytesData, _ := json.Marshal(data)
  30158. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  30159. resp, _ := client.Do(req)
  30160. defer resp.Body.Close()
  30161. body, ioErr := ioutil.ReadAll(resp.Body)
  30162. if ioErr != nil {
  30163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30165. return
  30166. }
  30167. var respJSON map[string]interface{}
  30168. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30171. return
  30172. }
  30173. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30174. userJSONBytes, _ := json.Marshal(respJSON)
  30175. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30176. utils.ErrorLog("解析失败:%v", err)
  30177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30178. return
  30179. }
  30180. }
  30181. if res.Infcode == 0 {
  30182. c.ServeSuccessJSON(map[string]interface{}{
  30183. "msg": "发起成功",
  30184. })
  30185. } else {
  30186. c.ServeSuccessJSON(map[string]interface{}{
  30187. "failed_code": -10,
  30188. "msg": res.ErrMsg,
  30189. })
  30190. }
  30191. }
  30192. }
  30193. func (c *HisApiController) Post1608() {
  30194. start_time := c.GetString("start_time")
  30195. end_time := c.GetString("end_time")
  30196. admin_user_id, _ := c.GetInt64("admin_user_id")
  30197. adminUser := c.GetAdminUserInfo()
  30198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30199. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30200. timeLayout := "2006-01-02"
  30201. loc, _ := time.LoadLocation("Local")
  30202. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30203. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30204. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30205. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30206. fixmedins_setl_cnt := int64(len(orders))
  30207. var medfee_sumamt float64
  30208. var func_smamt float64
  30209. for _, item := range orders {
  30210. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30211. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  30212. }
  30213. times := strings.Split(start_time, "-")
  30214. time_tows := strings.Split(end_time, "-")
  30215. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30216. var res ResultSix
  30217. if config.IsOpen == 1 {
  30218. //var bps []*models.BusinessParamsTwo
  30219. //var bp models.BusinessParamsTwo
  30220. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30221. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  30222. data := make(map[string]interface{})
  30223. data["org_name"] = miConfig.OrgName
  30224. data["doctor"] = role.UserName
  30225. data["func_smamt"] = func_smamt_str
  30226. data["fixmedins_code"] = miConfig.Code
  30227. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30228. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30229. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  30230. data["medfee_sumamt"] = medfee_sumamt_str
  30231. data["start_time"] = times[0] + times[1] + times[2]
  30232. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  30233. if miConfig.MdtrtareaAdmvs == "421300" {
  30234. client := &http.Client{}
  30235. bytesData, _ := json.Marshal(data)
  30236. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30237. resp, _ := client.Do(req)
  30238. defer resp.Body.Close()
  30239. body, ioErr := ioutil.ReadAll(resp.Body)
  30240. if ioErr != nil {
  30241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30243. return
  30244. }
  30245. var respJSON map[string]interface{}
  30246. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30249. return
  30250. }
  30251. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30252. userJSONBytes, _ := json.Marshal(respJSON)
  30253. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30254. utils.ErrorLog("解析失败:%v", err)
  30255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30256. return
  30257. }
  30258. }
  30259. if miConfig.MdtrtareaAdmvs == "420200" {
  30260. client := &http.Client{}
  30261. bytesData, _ := json.Marshal(data)
  30262. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30263. resp, _ := client.Do(req)
  30264. defer resp.Body.Close()
  30265. body, ioErr := ioutil.ReadAll(resp.Body)
  30266. if ioErr != nil {
  30267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30269. return
  30270. }
  30271. var respJSON map[string]interface{}
  30272. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30275. return
  30276. }
  30277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30278. userJSONBytes, _ := json.Marshal(respJSON)
  30279. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30280. utils.ErrorLog("解析失败:%v", err)
  30281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30282. return
  30283. }
  30284. }
  30285. if miConfig.MdtrtareaAdmvs == "421182" {
  30286. client := &http.Client{}
  30287. bytesData, _ := json.Marshal(data)
  30288. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  30289. resp, _ := client.Do(req)
  30290. defer resp.Body.Close()
  30291. body, ioErr := ioutil.ReadAll(resp.Body)
  30292. if ioErr != nil {
  30293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30295. return
  30296. }
  30297. var respJSON map[string]interface{}
  30298. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30301. return
  30302. }
  30303. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30304. userJSONBytes, _ := json.Marshal(respJSON)
  30305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30306. utils.ErrorLog("解析失败:%v", err)
  30307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30308. return
  30309. }
  30310. }
  30311. if res.Infcode == 0 {
  30312. c.ServeSuccessJSON(map[string]interface{}{
  30313. "msg": "发起成功",
  30314. })
  30315. } else {
  30316. c.ServeSuccessJSON(map[string]interface{}{
  30317. "failed_code": -10,
  30318. "msg": res.ErrMsg,
  30319. })
  30320. }
  30321. }
  30322. }
  30323. // 5.11.1.1【5262】结算信息按时间段查询
  30324. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30325. admin_user_id, _ := c.GetInt64("admin_user_id")
  30326. adminUser := c.GetAdminUserInfo()
  30327. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30328. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30329. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30330. var res Result5262
  30331. if config.IsOpen == 1 {
  30332. if miConfig.MdtrtareaAdmvs == "421300" {
  30333. data := make(map[string]interface{})
  30334. data["bps"] = bp
  30335. data["org_name"] = miConfig.OrgName
  30336. data["doctor"] = role.UserName
  30337. data["fixmedins_code"] = miConfig.Code
  30338. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30339. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30340. data["page"] = strconv.FormatInt(page, 10)
  30341. data["limit"] = strconv.FormatInt(limit, 10)
  30342. fmt.Println(data)
  30343. client := &http.Client{}
  30344. bytesData, _ := json.Marshal(data)
  30345. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30346. resp, _ := client.Do(req)
  30347. defer resp.Body.Close()
  30348. body, ioErr := ioutil.ReadAll(resp.Body)
  30349. if ioErr != nil {
  30350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30352. return
  30353. }
  30354. var respJSON map[string]interface{}
  30355. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30358. return
  30359. }
  30360. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30361. userJSONBytes, _ := json.Marshal(respJSON)
  30362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30363. utils.ErrorLog("解析失败:%v", err)
  30364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30365. return
  30366. }
  30367. }
  30368. if miConfig.MdtrtareaAdmvs == "420200" {
  30369. data := make(map[string]interface{})
  30370. data["bps"] = bp
  30371. data["org_name"] = miConfig.OrgName
  30372. data["doctor"] = role.UserName
  30373. data["fixmedins_code"] = miConfig.Code
  30374. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30375. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30376. data["page"] = strconv.FormatInt(page, 10)
  30377. data["limit"] = strconv.FormatInt(limit, 10)
  30378. fmt.Println(data)
  30379. client := &http.Client{}
  30380. bytesData, _ := json.Marshal(data)
  30381. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30382. resp, _ := client.Do(req)
  30383. defer resp.Body.Close()
  30384. body, ioErr := ioutil.ReadAll(resp.Body)
  30385. if ioErr != nil {
  30386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30388. return
  30389. }
  30390. var respJSON map[string]interface{}
  30391. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30394. return
  30395. }
  30396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30397. userJSONBytes, _ := json.Marshal(respJSON)
  30398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30399. utils.ErrorLog("解析失败:%v", err)
  30400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30401. return
  30402. }
  30403. }
  30404. if miConfig.MdtrtareaAdmvs == "421182" {
  30405. data := make(map[string]interface{})
  30406. data["bps"] = bp
  30407. data["org_name"] = miConfig.OrgName
  30408. data["doctor"] = role.UserName
  30409. data["fixmedins_code"] = miConfig.Code
  30410. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30411. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30412. data["page"] = strconv.FormatInt(page, 10)
  30413. data["limit"] = strconv.FormatInt(limit, 10)
  30414. fmt.Println(data)
  30415. client := &http.Client{}
  30416. bytesData, _ := json.Marshal(data)
  30417. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  30418. resp, _ := client.Do(req)
  30419. defer resp.Body.Close()
  30420. body, ioErr := ioutil.ReadAll(resp.Body)
  30421. if ioErr != nil {
  30422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30424. return
  30425. }
  30426. var respJSON map[string]interface{}
  30427. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30430. return
  30431. }
  30432. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30433. userJSONBytes, _ := json.Marshal(respJSON)
  30434. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30435. utils.ErrorLog("解析失败:%v", err)
  30436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30437. return
  30438. }
  30439. }
  30440. if res.Infcode == 0 {
  30441. c.ServeSuccessJSON(map[string]interface{}{
  30442. "order": res.Output.Result,
  30443. "total": res.Output.PageInfo.RecordCounts,
  30444. })
  30445. } else {
  30446. c.ServeSuccessJSON(map[string]interface{}{
  30447. "failed_code": -10,
  30448. "msg": res.ErrMsg,
  30449. })
  30450. }
  30451. }
  30452. }
  30453. // 5.11.1.2【5267】异地结算信息时间段查询
  30454. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30455. admin_user_id, _ := c.GetInt64("admin_user_id")
  30456. adminUser := c.GetAdminUserInfo()
  30457. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30458. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30459. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30460. var res Result5267
  30461. if config.IsOpen == 1 {
  30462. if miConfig.MdtrtareaAdmvs == "421300" {
  30463. data := make(map[string]interface{})
  30464. data["bps"] = bp
  30465. data["org_name"] = miConfig.OrgName
  30466. data["doctor"] = role.UserName
  30467. data["fixmedins_code"] = miConfig.Code
  30468. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30469. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30470. data["page"] = page
  30471. data["limit"] = limit
  30472. fmt.Println(data)
  30473. client := &http.Client{}
  30474. bytesData, _ := json.Marshal(data)
  30475. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30476. resp, _ := client.Do(req)
  30477. defer resp.Body.Close()
  30478. body, ioErr := ioutil.ReadAll(resp.Body)
  30479. if ioErr != nil {
  30480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30482. return
  30483. }
  30484. var respJSON map[string]interface{}
  30485. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30488. return
  30489. }
  30490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30491. userJSONBytes, _ := json.Marshal(respJSON)
  30492. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30493. utils.ErrorLog("解析失败:%v", err)
  30494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30495. return
  30496. }
  30497. }
  30498. if miConfig.MdtrtareaAdmvs == "420200" {
  30499. data := make(map[string]interface{})
  30500. data["bps"] = bp
  30501. data["org_name"] = miConfig.OrgName
  30502. data["doctor"] = role.UserName
  30503. data["fixmedins_code"] = miConfig.Code
  30504. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30505. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30506. data["page"] = page
  30507. data["limit"] = limit
  30508. fmt.Println(data)
  30509. client := &http.Client{}
  30510. bytesData, _ := json.Marshal(data)
  30511. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30512. resp, _ := client.Do(req)
  30513. defer resp.Body.Close()
  30514. body, ioErr := ioutil.ReadAll(resp.Body)
  30515. if ioErr != nil {
  30516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30518. return
  30519. }
  30520. var respJSON map[string]interface{}
  30521. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30524. return
  30525. }
  30526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30527. userJSONBytes, _ := json.Marshal(respJSON)
  30528. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30529. utils.ErrorLog("解析失败:%v", err)
  30530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30531. return
  30532. }
  30533. }
  30534. if miConfig.MdtrtareaAdmvs == "421182" {
  30535. data := make(map[string]interface{})
  30536. data["bps"] = bp
  30537. data["org_name"] = miConfig.OrgName
  30538. data["doctor"] = role.UserName
  30539. data["fixmedins_code"] = miConfig.Code
  30540. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30541. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30542. data["page"] = page
  30543. data["limit"] = limit
  30544. fmt.Println(data)
  30545. client := &http.Client{}
  30546. bytesData, _ := json.Marshal(data)
  30547. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  30548. resp, _ := client.Do(req)
  30549. defer resp.Body.Close()
  30550. body, ioErr := ioutil.ReadAll(resp.Body)
  30551. if ioErr != nil {
  30552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30554. return
  30555. }
  30556. var respJSON map[string]interface{}
  30557. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30560. return
  30561. }
  30562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30563. userJSONBytes, _ := json.Marshal(respJSON)
  30564. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30565. utils.ErrorLog("解析失败:%v", err)
  30566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30567. return
  30568. }
  30569. }
  30570. if res.Infcode == 0 {
  30571. c.ServeSuccessJSON(map[string]interface{}{
  30572. "order": res.Output.Result,
  30573. "total": res.Output.PageInfo.RecordCounts,
  30574. })
  30575. } else {
  30576. c.ServeSuccessJSON(map[string]interface{}{
  30577. "failed_code": -10,
  30578. "msg": res.ErrMsg,
  30579. })
  30580. }
  30581. }
  30582. }
  30583. func (c *HisApiController) Post3501() {
  30584. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30585. data := make(map[string]interface{})
  30586. var struct3501s []models.Struct3501
  30587. var struct3501 models.Struct3501
  30588. struct3501.OrgName = miConfig.OrgName
  30589. struct3501.AccessKey = miConfig.AccessKey
  30590. struct3501.RequestUrl = miConfig.Url
  30591. struct3501.SecretKey = miConfig.SecretKey
  30592. struct3501.ManuDate = "2022-08-17"
  30593. struct3501.FixmedinsBchno = ""
  30594. struct3501.ManuLotnum = ""
  30595. struct3501.RxFlag = "0"
  30596. struct3501.ExpyEnd = "2022-08-17"
  30597. struct3501.Invdate = "2022-08-17"
  30598. struct3501.InvCnt = "20.25"
  30599. struct3501.Memo = ""
  30600. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30601. struct3501.FixmedinsHilistId = miConfig.Code
  30602. struct3501.FixmedinsHilistName = miConfig.OrgName
  30603. struct3501s = append(struct3501s, struct3501)
  30604. data["struct_3501s"] = struct3501s
  30605. client := &http.Client{}
  30606. bytesData, _ := json.Marshal(data)
  30607. var req *http.Request
  30608. if miConfig.MdtrtareaAdmvs == "320921" {
  30609. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30610. } else {
  30611. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30612. }
  30613. resp, _ := client.Do(req)
  30614. defer resp.Body.Close()
  30615. body, ioErr := ioutil.ReadAll(resp.Body)
  30616. if ioErr != nil {
  30617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30619. return
  30620. }
  30621. var respJSON map[string]interface{}
  30622. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30625. return
  30626. }
  30627. var res ResultSix
  30628. var resSix10265 ResultSix10265 //1101结果
  30629. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30630. result, _ := json.Marshal(respJSON)
  30631. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30632. utils.ErrorLog("解析失败:%v", err)
  30633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30634. return
  30635. }
  30636. res.InfRefmsgid = resSix10265.InfRefmsgid
  30637. res.Output = resSix10265.Output
  30638. res.ErrMsg = resSix10265.ErrMsg
  30639. res.Cainfo = resSix10265.Cainfo
  30640. res.WarnMsg = resSix10265.WarnMsg
  30641. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30642. res.Infcode = infocode
  30643. if infocode == 0 {
  30644. c.ServeSuccessJSON(map[string]interface{}{
  30645. "msg": "上传成功",
  30646. })
  30647. return
  30648. } else {
  30649. c.ServeSuccessJSON(map[string]interface{}{
  30650. "failed_code": -10,
  30651. "msg": res.ErrMsg,
  30652. })
  30653. return
  30654. }
  30655. }
  30656. func (c *HisApiController) Post3502() {
  30657. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30658. data := make(map[string]interface{})
  30659. var struct3502s []models.Struct3502
  30660. var struct3502 models.Struct3502
  30661. struct3502.OrgName = miConfig.OrgName
  30662. struct3502.AccessKey = miConfig.AccessKey
  30663. struct3502.RequestUrl = miConfig.Url
  30664. struct3502.SecretKey = miConfig.SecretKey
  30665. struct3502.ManuDate = "2022-08-15"
  30666. struct3502.FixmedinsBchno = ""
  30667. struct3502.ManuLotnum = ""
  30668. struct3502.RxFlag = "0"
  30669. struct3502.ExpyEnd = "2022-08-15"
  30670. struct3502.Invdate = "2022-08-15"
  30671. struct3502.InvCnt = "20.25"
  30672. struct3502.Memo = ""
  30673. struct3502.MedListCodg = "XB01ABD056B002020200517"
  30674. struct3502.FixmedinsHilistId = miConfig.Code
  30675. struct3502.FixmedinsHilistName = miConfig.OrgName
  30676. struct3502s = append(struct3502s, struct3502)
  30677. data["struct_3502s"] = struct3502s
  30678. client := &http.Client{}
  30679. bytesData, _ := json.Marshal(data)
  30680. var req *http.Request
  30681. if miConfig.MdtrtareaAdmvs == "320921" {
  30682. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30683. } else {
  30684. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30685. }
  30686. resp, _ := client.Do(req)
  30687. defer resp.Body.Close()
  30688. body, ioErr := ioutil.ReadAll(resp.Body)
  30689. if ioErr != nil {
  30690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30692. return
  30693. }
  30694. var respJSON map[string]interface{}
  30695. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30698. return
  30699. }
  30700. var res ResultSix
  30701. var resSix10265 ResultSix10265 //1101结果
  30702. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30703. result, _ := json.Marshal(respJSON)
  30704. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30705. utils.ErrorLog("解析失败:%v", err)
  30706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30707. return
  30708. }
  30709. res.InfRefmsgid = resSix10265.InfRefmsgid
  30710. res.Output = resSix10265.Output
  30711. res.ErrMsg = resSix10265.ErrMsg
  30712. res.Cainfo = resSix10265.Cainfo
  30713. res.WarnMsg = resSix10265.WarnMsg
  30714. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30715. res.Infcode = infocode
  30716. if infocode == 0 {
  30717. c.ServeSuccessJSON(map[string]interface{}{
  30718. "msg": "上传成功",
  30719. })
  30720. return
  30721. } else {
  30722. c.ServeSuccessJSON(map[string]interface{}{
  30723. "failed_code": -10,
  30724. "msg": res.ErrMsg,
  30725. })
  30726. return
  30727. }
  30728. }
  30729. func (c *HisApiController) Post3503() {
  30730. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30731. data := make(map[string]interface{})
  30732. var struct3501s []models.Struct3501
  30733. var struct3501 models.Struct3501
  30734. struct3501.OrgName = miConfig.OrgName
  30735. struct3501.AccessKey = miConfig.AccessKey
  30736. struct3501.RequestUrl = miConfig.Url
  30737. struct3501.SecretKey = miConfig.SecretKey
  30738. struct3501.ManuDate = "2022-08-15"
  30739. struct3501.FixmedinsBchno = ""
  30740. struct3501.ManuLotnum = ""
  30741. struct3501.RxFlag = "0"
  30742. struct3501.ExpyEnd = "2022-08-15"
  30743. struct3501.Invdate = "2022-08-15"
  30744. struct3501.InvCnt = "20.25"
  30745. struct3501.Memo = ""
  30746. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30747. struct3501.FixmedinsHilistId = miConfig.Code
  30748. struct3501.FixmedinsHilistName = miConfig.OrgName
  30749. struct3501s = append(struct3501s, struct3501)
  30750. data["struct_3501s"] = struct3501s
  30751. client := &http.Client{}
  30752. bytesData, _ := json.Marshal(data)
  30753. var req *http.Request
  30754. if miConfig.MdtrtareaAdmvs == "320921" {
  30755. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30756. } else {
  30757. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30758. }
  30759. resp, _ := client.Do(req)
  30760. defer resp.Body.Close()
  30761. body, ioErr := ioutil.ReadAll(resp.Body)
  30762. if ioErr != nil {
  30763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30765. return
  30766. }
  30767. var respJSON map[string]interface{}
  30768. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30771. return
  30772. }
  30773. var res ResultSix
  30774. var resSix10265 ResultSix10265 //1101结果
  30775. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30776. result, _ := json.Marshal(respJSON)
  30777. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30778. utils.ErrorLog("解析失败:%v", err)
  30779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30780. return
  30781. }
  30782. res.InfRefmsgid = resSix10265.InfRefmsgid
  30783. res.Output = resSix10265.Output
  30784. res.ErrMsg = resSix10265.ErrMsg
  30785. res.Cainfo = resSix10265.Cainfo
  30786. res.WarnMsg = resSix10265.WarnMsg
  30787. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30788. res.Infcode = infocode
  30789. if infocode == 0 {
  30790. c.ServeSuccessJSON(map[string]interface{}{
  30791. "msg": "上传成功",
  30792. })
  30793. return
  30794. } else {
  30795. c.ServeSuccessJSON(map[string]interface{}{
  30796. "failed_code": -10,
  30797. "msg": res.ErrMsg,
  30798. })
  30799. return
  30800. }
  30801. }
  30802. func (c *HisApiController) Post3504() {
  30803. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30804. data := make(map[string]interface{})
  30805. var struct3501s []models.Struct3501
  30806. var struct3501 models.Struct3501
  30807. struct3501.OrgName = miConfig.OrgName
  30808. struct3501.AccessKey = miConfig.AccessKey
  30809. struct3501.RequestUrl = miConfig.Url
  30810. struct3501.SecretKey = miConfig.SecretKey
  30811. struct3501.ManuDate = "2022-08-15"
  30812. struct3501.FixmedinsBchno = ""
  30813. struct3501.ManuLotnum = ""
  30814. struct3501.RxFlag = "0"
  30815. struct3501.ExpyEnd = "2022-08-15"
  30816. struct3501.Invdate = "2022-08-15"
  30817. struct3501.InvCnt = "20.25"
  30818. struct3501.Memo = ""
  30819. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30820. struct3501.FixmedinsHilistId = miConfig.Code
  30821. struct3501.FixmedinsHilistName = miConfig.OrgName
  30822. struct3501s = append(struct3501s, struct3501)
  30823. data["struct_3501s"] = struct3501s
  30824. client := &http.Client{}
  30825. bytesData, _ := json.Marshal(data)
  30826. var req *http.Request
  30827. if miConfig.MdtrtareaAdmvs == "320921" {
  30828. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30829. } else {
  30830. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30831. }
  30832. resp, _ := client.Do(req)
  30833. defer resp.Body.Close()
  30834. body, ioErr := ioutil.ReadAll(resp.Body)
  30835. if ioErr != nil {
  30836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30838. return
  30839. }
  30840. var respJSON map[string]interface{}
  30841. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30844. return
  30845. }
  30846. var res ResultSix
  30847. var resSix10265 ResultSix10265 //1101结果
  30848. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30849. result, _ := json.Marshal(respJSON)
  30850. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30851. utils.ErrorLog("解析失败:%v", err)
  30852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30853. return
  30854. }
  30855. res.InfRefmsgid = resSix10265.InfRefmsgid
  30856. res.Output = resSix10265.Output
  30857. res.ErrMsg = resSix10265.ErrMsg
  30858. res.Cainfo = resSix10265.Cainfo
  30859. res.WarnMsg = resSix10265.WarnMsg
  30860. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30861. res.Infcode = infocode
  30862. if infocode == 0 {
  30863. c.ServeSuccessJSON(map[string]interface{}{
  30864. "msg": "上传成功",
  30865. })
  30866. return
  30867. } else {
  30868. c.ServeSuccessJSON(map[string]interface{}{
  30869. "failed_code": -10,
  30870. "msg": res.ErrMsg,
  30871. })
  30872. return
  30873. }
  30874. }
  30875. func (c *HisApiController) Post3505() {
  30876. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30877. data := make(map[string]interface{})
  30878. var struct3501s []models.Struct3501
  30879. var struct3501 models.Struct3501
  30880. struct3501.OrgName = miConfig.OrgName
  30881. struct3501.AccessKey = miConfig.AccessKey
  30882. struct3501.RequestUrl = miConfig.Url
  30883. struct3501.SecretKey = miConfig.SecretKey
  30884. struct3501.ManuDate = "2022-08-15"
  30885. struct3501.FixmedinsBchno = ""
  30886. struct3501.ManuLotnum = ""
  30887. struct3501.RxFlag = "0"
  30888. struct3501.ExpyEnd = "2022-08-15"
  30889. struct3501.Invdate = "2022-08-15"
  30890. struct3501.InvCnt = "20.25"
  30891. struct3501.Memo = ""
  30892. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30893. struct3501.FixmedinsHilistId = miConfig.Code
  30894. struct3501.FixmedinsHilistName = miConfig.OrgName
  30895. struct3501s = append(struct3501s, struct3501)
  30896. data["struct_3501s"] = struct3501s
  30897. client := &http.Client{}
  30898. bytesData, _ := json.Marshal(data)
  30899. var req *http.Request
  30900. if miConfig.MdtrtareaAdmvs == "320921" {
  30901. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30902. } else {
  30903. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30904. }
  30905. resp, _ := client.Do(req)
  30906. defer resp.Body.Close()
  30907. body, ioErr := ioutil.ReadAll(resp.Body)
  30908. if ioErr != nil {
  30909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30911. return
  30912. }
  30913. var respJSON map[string]interface{}
  30914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30917. return
  30918. }
  30919. var res ResultSix
  30920. var resSix10265 ResultSix10265 //1101结果
  30921. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30922. result, _ := json.Marshal(respJSON)
  30923. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30924. utils.ErrorLog("解析失败:%v", err)
  30925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30926. return
  30927. }
  30928. res.InfRefmsgid = resSix10265.InfRefmsgid
  30929. res.Output = resSix10265.Output
  30930. res.ErrMsg = resSix10265.ErrMsg
  30931. res.Cainfo = resSix10265.Cainfo
  30932. res.WarnMsg = resSix10265.WarnMsg
  30933. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30934. res.Infcode = infocode
  30935. if infocode == 0 {
  30936. c.ServeSuccessJSON(map[string]interface{}{
  30937. "msg": "上传成功",
  30938. })
  30939. return
  30940. } else {
  30941. c.ServeSuccessJSON(map[string]interface{}{
  30942. "failed_code": -10,
  30943. "msg": res.ErrMsg,
  30944. })
  30945. return
  30946. }
  30947. }
  30948. func (c *HisApiController) Post3506() {
  30949. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30950. data := make(map[string]interface{})
  30951. var struct3501s []models.Struct3501
  30952. var struct3501 models.Struct3501
  30953. struct3501.OrgName = miConfig.OrgName
  30954. struct3501.AccessKey = miConfig.AccessKey
  30955. struct3501.RequestUrl = miConfig.Url
  30956. struct3501.SecretKey = miConfig.SecretKey
  30957. struct3501.ManuDate = "2022-08-15"
  30958. struct3501.FixmedinsBchno = ""
  30959. struct3501.ManuLotnum = ""
  30960. struct3501.RxFlag = "0"
  30961. struct3501.ExpyEnd = "2022-08-15"
  30962. struct3501.Invdate = "2022-08-15"
  30963. struct3501.InvCnt = "20.25"
  30964. struct3501.Memo = ""
  30965. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30966. struct3501.FixmedinsHilistId = miConfig.Code
  30967. struct3501.FixmedinsHilistName = miConfig.OrgName
  30968. struct3501s = append(struct3501s, struct3501)
  30969. data["struct_3501s"] = struct3501s
  30970. client := &http.Client{}
  30971. bytesData, _ := json.Marshal(data)
  30972. var req *http.Request
  30973. if miConfig.MdtrtareaAdmvs == "320921" {
  30974. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30975. } else {
  30976. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30977. }
  30978. resp, _ := client.Do(req)
  30979. defer resp.Body.Close()
  30980. body, ioErr := ioutil.ReadAll(resp.Body)
  30981. if ioErr != nil {
  30982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30984. return
  30985. }
  30986. var respJSON map[string]interface{}
  30987. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30990. return
  30991. }
  30992. var res ResultSix
  30993. var resSix10265 ResultSix10265 //1101结果
  30994. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30995. result, _ := json.Marshal(respJSON)
  30996. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30997. utils.ErrorLog("解析失败:%v", err)
  30998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30999. return
  31000. }
  31001. res.InfRefmsgid = resSix10265.InfRefmsgid
  31002. res.Output = resSix10265.Output
  31003. res.ErrMsg = resSix10265.ErrMsg
  31004. res.Cainfo = resSix10265.Cainfo
  31005. res.WarnMsg = resSix10265.WarnMsg
  31006. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31007. res.Infcode = infocode
  31008. if infocode == 0 {
  31009. c.ServeSuccessJSON(map[string]interface{}{
  31010. "msg": "上传成功",
  31011. })
  31012. return
  31013. } else {
  31014. c.ServeSuccessJSON(map[string]interface{}{
  31015. "failed_code": -10,
  31016. "msg": res.ErrMsg,
  31017. })
  31018. return
  31019. }
  31020. }
  31021. func (c *HisApiController) Post3507() {
  31022. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31023. data := make(map[string]interface{})
  31024. var struct3501s []models.Struct3501
  31025. var struct3501 models.Struct3501
  31026. struct3501.OrgName = miConfig.OrgName
  31027. struct3501.AccessKey = miConfig.AccessKey
  31028. struct3501.RequestUrl = miConfig.Url
  31029. struct3501.SecretKey = miConfig.SecretKey
  31030. struct3501.ManuDate = "2022-08-15"
  31031. struct3501.FixmedinsBchno = ""
  31032. struct3501.ManuLotnum = ""
  31033. struct3501.RxFlag = "0"
  31034. struct3501.ExpyEnd = "2022-08-15"
  31035. struct3501.Invdate = "2022-08-15"
  31036. struct3501.InvCnt = "20.25"
  31037. struct3501.Memo = ""
  31038. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31039. struct3501.FixmedinsHilistId = miConfig.Code
  31040. struct3501.FixmedinsHilistName = miConfig.OrgName
  31041. struct3501s = append(struct3501s, struct3501)
  31042. data["struct_3501s"] = struct3501s
  31043. client := &http.Client{}
  31044. bytesData, _ := json.Marshal(data)
  31045. var req *http.Request
  31046. if miConfig.MdtrtareaAdmvs == "320921" {
  31047. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31048. } else {
  31049. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31050. }
  31051. resp, _ := client.Do(req)
  31052. defer resp.Body.Close()
  31053. body, ioErr := ioutil.ReadAll(resp.Body)
  31054. if ioErr != nil {
  31055. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31057. return
  31058. }
  31059. var respJSON map[string]interface{}
  31060. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31063. return
  31064. }
  31065. var res ResultSix
  31066. var resSix10265 ResultSix10265 //1101结果
  31067. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31068. result, _ := json.Marshal(respJSON)
  31069. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31070. utils.ErrorLog("解析失败:%v", err)
  31071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31072. return
  31073. }
  31074. res.InfRefmsgid = resSix10265.InfRefmsgid
  31075. res.Output = resSix10265.Output
  31076. res.ErrMsg = resSix10265.ErrMsg
  31077. res.Cainfo = resSix10265.Cainfo
  31078. res.WarnMsg = resSix10265.WarnMsg
  31079. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31080. res.Infcode = infocode
  31081. if infocode == 0 {
  31082. c.ServeSuccessJSON(map[string]interface{}{
  31083. "msg": "上传成功",
  31084. })
  31085. return
  31086. } else {
  31087. c.ServeSuccessJSON(map[string]interface{}{
  31088. "failed_code": -10,
  31089. "msg": res.ErrMsg,
  31090. })
  31091. return
  31092. }
  31093. }
  31094. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31095. // WebSocket服务器地址
  31096. serverURL := "ws://127.0.0.1:8899"
  31097. // 解析WebSocket服务器地址
  31098. u, err := url.Parse(serverURL)
  31099. if err != nil {
  31100. }
  31101. // 建立WebSocket连接
  31102. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31103. if err != nil {
  31104. }
  31105. defer conn.Close()
  31106. input2 := make(map[string]interface{})
  31107. input := make(map[string]interface{})
  31108. inputData := make(map[string]interface{})
  31109. inputData["orgId"] = code
  31110. inputData["businessType"] = "01101"
  31111. inputData["operatorId"] = operator_id
  31112. inputData["operatorName"] = operator_name
  31113. inputData["officeId"] = "001"
  31114. inputData["officeName"] = "血透室"
  31115. inputData["deviceType"] = ""
  31116. input["data"] = inputData
  31117. input["orgId"] = code
  31118. input["transType"] = "ec.query"
  31119. //if md == ""
  31120. if md[:4] == "4403" {
  31121. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31122. } else if md[:4] == "4401" {
  31123. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31124. } else {
  31125. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31126. }
  31127. input2["indata"] = input
  31128. fmt.Println(input2)
  31129. bytesData, _ := json.Marshal(input2)
  31130. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31131. if err != nil {
  31132. fmt.Println(err)
  31133. }
  31134. // 接收消息
  31135. _, receivedMessage, err := conn.ReadMessage()
  31136. if err != nil {
  31137. fmt.Println(err)
  31138. }
  31139. return "", string(receivedMessage)
  31140. }
  31141. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  31142. // WebSocket服务器地址
  31143. serverURL := "ws://127.0.0.1:8899"
  31144. // 解析WebSocket服务器地址
  31145. u, err := url.Parse(serverURL)
  31146. if err != nil {
  31147. }
  31148. // 建立WebSocket连接
  31149. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31150. if err != nil {
  31151. }
  31152. defer conn.Close()
  31153. input2 := make(map[string]interface{})
  31154. input := make(map[string]interface{})
  31155. inputData := make(map[string]interface{})
  31156. inputData["orgId"] = code
  31157. inputData["businessType"] = "01103"
  31158. inputData["operatorId"] = operator_id
  31159. inputData["operatorName"] = operator_name
  31160. inputData["officeId"] = "001"
  31161. inputData["officeName"] = "血透室"
  31162. inputData["deviceType"] = ""
  31163. input["data"] = inputData
  31164. input["orgId"] = code
  31165. input["transType"] = "ec.query"
  31166. //if md ==
  31167. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  31168. input2["indata"] = input
  31169. fmt.Println(input2)
  31170. bytesData, _ := json.Marshal(input2)
  31171. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31172. if err != nil {
  31173. fmt.Println(err)
  31174. }
  31175. // 接收消息
  31176. _, receivedMessage, err := conn.ReadMessage()
  31177. if err != nil {
  31178. fmt.Println(err)
  31179. }
  31180. return "", string(receivedMessage)
  31181. }
  31182. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31183. // WebSocket服务器地址
  31184. serverURL := "ws://127.0.0.1:8899"
  31185. // 解析WebSocket服务器地址
  31186. u, err := url.Parse(serverURL)
  31187. if err != nil {
  31188. }
  31189. // 建立WebSocket连接
  31190. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31191. if err != nil {
  31192. }
  31193. defer conn.Close()
  31194. input2 := make(map[string]interface{})
  31195. input := make(map[string]interface{})
  31196. inputData := make(map[string]interface{})
  31197. inputData["orgId"] = code
  31198. inputData["businessType"] = "01101"
  31199. inputData["operatorId"] = operator_id
  31200. inputData["operatorName"] = operator_name
  31201. inputData["officeId"] = "001"
  31202. inputData["officeName"] = "血透室"
  31203. inputData["deviceType"] = ""
  31204. input["data"] = inputData
  31205. input["orgId"] = code
  31206. input["transType"] = "ec.query"
  31207. //if md == ""
  31208. if md[:4] == "4403" {
  31209. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31210. } else if md[:4] == "4401" {
  31211. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31212. } else {
  31213. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31214. }
  31215. input2["indata"] = input
  31216. fmt.Println(input2)
  31217. bytesData, _ := json.Marshal(input2)
  31218. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31219. if err != nil {
  31220. fmt.Println(err)
  31221. }
  31222. // 接收消息
  31223. _, receivedMessage, err := conn.ReadMessage()
  31224. if err != nil {
  31225. fmt.Println(err)
  31226. }
  31227. return "", string(receivedMessage)
  31228. }
  31229. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  31230. // WebSocket服务器地址
  31231. serverURL := "ws://127.0.0.1:8899"
  31232. // 解析WebSocket服务器地址
  31233. u, err := url.Parse(serverURL)
  31234. if err != nil {
  31235. }
  31236. // 建立WebSocket连接
  31237. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31238. if err != nil {
  31239. }
  31240. defer conn.Close()
  31241. input2 := make(map[string]interface{})
  31242. input := make(map[string]interface{})
  31243. inputData := make(map[string]interface{})
  31244. inputData["orgId"] = code
  31245. inputData["businessType"] = "01301"
  31246. inputData["operatorId"] = operator_id
  31247. inputData["operatorName"] = operator_name
  31248. inputData["officeId"] = "001"
  31249. inputData["officeName"] = "血透室"
  31250. inputData["deviceType"] = ""
  31251. input["data"] = inputData
  31252. input["orgId"] = code
  31253. input["transType"] = "ec.query"
  31254. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31255. input2["indata"] = input
  31256. bytesData, _ := json.Marshal(input2)
  31257. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31258. if err != nil {
  31259. fmt.Println(err)
  31260. }
  31261. // 接收消息
  31262. _, receivedMessage, err := conn.ReadMessage()
  31263. if err != nil {
  31264. fmt.Println(err)
  31265. }
  31266. return "", string(receivedMessage)
  31267. }
  31268. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  31269. newArr = make([]string, 0)
  31270. for i := 0; i < len(arr); i++ {
  31271. repeat := false
  31272. for j := i + 1; j < len(arr); j++ {
  31273. if arr[i] == arr[j] {
  31274. repeat = true
  31275. break
  31276. }
  31277. }
  31278. if !repeat {
  31279. newArr = append(newArr, arr[i])
  31280. }
  31281. }
  31282. return
  31283. }
  31284. func getBirthdateAndAge(idNumber string) (string, int, error) {
  31285. if len(idNumber) != 18 {
  31286. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  31287. }
  31288. // 提取出生日期
  31289. year, err := strconv.Atoi(idNumber[6:10])
  31290. if err != nil {
  31291. return "", 0, err
  31292. }
  31293. month, err := strconv.Atoi(idNumber[10:12])
  31294. if err != nil {
  31295. return "", 0, err
  31296. }
  31297. day, err := strconv.Atoi(idNumber[12:14])
  31298. if err != nil {
  31299. return "", 0, err
  31300. }
  31301. // 格式化生日字符串
  31302. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  31303. birthdateFormatted := birthdate.Format("2006-01-02")
  31304. // 计算年龄
  31305. today := time.Now()
  31306. age := today.Year() - birthdate.Year()
  31307. if today.YearDay() < birthdate.YearDay() {
  31308. age--
  31309. }
  31310. return birthdateFormatted, age, nil
  31311. }