his_api_controller.go 1.7MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. "github.com/go-ole/go-ole"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  42. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  43. //上传就诊信息-上传明细-结算
  44. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  45. //查询
  46. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  47. //对总账
  48. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  49. //对明细
  50. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  51. //退费,退明细
  52. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  53. //退号
  54. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  55. //退明细
  56. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  57. //上传就诊信息-上传明细-预结算
  58. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  59. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  60. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  61. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  62. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  63. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  64. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  65. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  66. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  67. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  68. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  69. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  70. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  71. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  72. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  73. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  74. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  75. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  76. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  81. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  82. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  83. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  84. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  85. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  86. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  87. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  88. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  89. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  90. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  91. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  92. //beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  93. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  94. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  95. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  96. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  97. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  98. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  99. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  100. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  101. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  102. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  103. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  107. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  108. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  109. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  110. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  111. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  112. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  113. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  114. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  115. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  116. beego.Router("/api/CFYLJG012", &HisApiController{}, "get:GetCFYLJG12")
  117. beego.Router("/api/CFYLJG013", &HisApiController{}, "get:GetCFYLJG13")
  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/3103", &HisApiController{}, "get:Get3103")
  137. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  138. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  139. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  140. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  141. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  142. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  143. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  144. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  145. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  146. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  147. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  148. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  149. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  150. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  151. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  152. //库盘和变更
  153. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  154. //删除库盘和变更
  155. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  156. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  157. //药品变更
  158. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  159. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  160. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  161. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  162. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  163. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  164. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  165. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  166. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  167. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  168. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  169. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  170. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  171. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  172. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  173. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  174. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  175. beego.Router("/api/5101", &HisApiController{}, "get:Get5101")
  176. beego.Router("/api/5102", &HisApiController{}, "get:Get5102")
  177. }
  178. func (c *HisApiController) Get5101() {
  179. adminUser := c.GetAdminUserInfo()
  180. admin_user_id, _ := c.GetInt64("admin_user_id")
  181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  182. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  183. if miConfig.MdtrtareaAdmvs == "341203" {
  184. fmt.Println(miConfig.SecretKey)
  185. var res models.Result9001Two
  186. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  187. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  188. resp, requestErr := http.Get(api)
  189. if requestErr != nil {
  190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  191. return
  192. }
  193. body, ioErr := ioutil.ReadAll(resp.Body)
  194. if ioErr != nil {
  195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  197. return
  198. }
  199. var respJSON map[string]interface{}
  200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  203. return
  204. }
  205. status := respJSON["data"].(map[string]interface{})["status"].(string)
  206. if status == "0" {
  207. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  208. c.ServeSuccessJSON(map[string]interface{}{
  209. "failed_code": -10,
  210. "msg": err_msg,
  211. })
  212. return
  213. }
  214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  215. result, _ := json.Marshal(respJSON)
  216. fmt.Println("log")
  217. fmt.Println(string(result))
  218. if err := json.Unmarshal([]byte(result), &res); err != nil {
  219. utils.ErrorLog("解析失败:%v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. if res.Infcode == 0 {
  224. sign := models.HisSignIn{
  225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  226. SignNo: res.Output.Signinoutb.SignNo,
  227. SignTime: "",
  228. Ctime: time.Now().Unix(),
  229. Mtime: time.Now().Unix(),
  230. Status: 1,
  231. InputLog: "",
  232. OutputLog: "",
  233. FixmedinsCode: miConfig.Code,
  234. }
  235. err := service.CreateSignIn(&sign)
  236. if err == nil {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "msg": "签到成功",
  239. })
  240. }
  241. } else {
  242. c.ServeSuccessJSON(map[string]interface{}{
  243. "failed_code": -10,
  244. "msg": res.ErrMsg,
  245. })
  246. return
  247. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  248. //return
  249. }
  250. } else if miConfig.MdtrtareaAdmvs == "340699" {
  251. fmt.Println(miConfig.SecretKey)
  252. var res models.Result9001Two
  253. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  254. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  255. resp, requestErr := http.Get(api)
  256. if requestErr != nil {
  257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  258. return
  259. }
  260. body, ioErr := ioutil.ReadAll(resp.Body)
  261. if ioErr != nil {
  262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  264. return
  265. }
  266. var respJSON map[string]interface{}
  267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  270. return
  271. }
  272. status := respJSON["data"].(map[string]interface{})["status"].(string)
  273. if status == "0" {
  274. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  275. c.ServeSuccessJSON(map[string]interface{}{
  276. "failed_code": -10,
  277. "msg": err_msg,
  278. })
  279. return
  280. }
  281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  282. result, _ := json.Marshal(respJSON)
  283. fmt.Println("log")
  284. fmt.Println(string(result))
  285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  286. utils.ErrorLog("解析失败:%v", err)
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. if res.Infcode == 0 {
  291. sign := models.HisSignIn{
  292. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  293. SignNo: res.Output.Signinoutb.SignNo,
  294. SignTime: "",
  295. Ctime: time.Now().Unix(),
  296. Mtime: time.Now().Unix(),
  297. Status: 1,
  298. InputLog: "",
  299. OutputLog: "",
  300. FixmedinsCode: miConfig.Code,
  301. }
  302. err := service.CreateSignIn(&sign)
  303. if err == nil {
  304. c.ServeSuccessJSON(map[string]interface{}{
  305. "msg": "查询成功",
  306. })
  307. }
  308. } else {
  309. c.ServeSuccessJSON(map[string]interface{}{
  310. "failed_code": -10,
  311. "msg": res.ErrMsg,
  312. })
  313. return
  314. }
  315. }
  316. }
  317. func (c *HisApiController) Get5102() {
  318. adminUser := c.GetAdminUserInfo()
  319. admin_user_id, _ := c.GetInt64("admin_user_id")
  320. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  321. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  322. if miConfig.MdtrtareaAdmvs == "341203" {
  323. fmt.Println(miConfig.SecretKey)
  324. var res models.Result9001Two
  325. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  326. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  327. resp, requestErr := http.Get(api)
  328. if requestErr != nil {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  330. return
  331. }
  332. body, ioErr := ioutil.ReadAll(resp.Body)
  333. if ioErr != nil {
  334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  336. return
  337. }
  338. var respJSON map[string]interface{}
  339. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  342. return
  343. }
  344. status := respJSON["data"].(map[string]interface{})["status"].(string)
  345. if status == "0" {
  346. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  347. c.ServeSuccessJSON(map[string]interface{}{
  348. "failed_code": -10,
  349. "msg": err_msg,
  350. })
  351. return
  352. }
  353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  354. result, _ := json.Marshal(respJSON)
  355. fmt.Println("log")
  356. fmt.Println(string(result))
  357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  358. utils.ErrorLog("解析失败:%v", err)
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. if res.Infcode == 0 {
  363. sign := models.HisSignIn{
  364. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  365. SignNo: res.Output.Signinoutb.SignNo,
  366. SignTime: "",
  367. Ctime: time.Now().Unix(),
  368. Mtime: time.Now().Unix(),
  369. Status: 1,
  370. InputLog: "",
  371. OutputLog: "",
  372. FixmedinsCode: miConfig.Code,
  373. }
  374. err := service.CreateSignIn(&sign)
  375. if err == nil {
  376. c.ServeSuccessJSON(map[string]interface{}{
  377. "msg": "签到成功",
  378. })
  379. }
  380. } else {
  381. c.ServeSuccessJSON(map[string]interface{}{
  382. "failed_code": -10,
  383. "msg": res.ErrMsg,
  384. })
  385. return
  386. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  387. //return
  388. }
  389. } else if miConfig.MdtrtareaAdmvs == "340699" {
  390. fmt.Println(miConfig.SecretKey)
  391. var res models.Result9001Two
  392. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  394. resp, requestErr := http.Get(api)
  395. if requestErr != nil {
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  397. return
  398. }
  399. body, ioErr := ioutil.ReadAll(resp.Body)
  400. if ioErr != nil {
  401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  403. return
  404. }
  405. var respJSON map[string]interface{}
  406. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. return
  410. }
  411. status := respJSON["data"].(map[string]interface{})["status"].(string)
  412. if status == "0" {
  413. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  414. c.ServeSuccessJSON(map[string]interface{}{
  415. "failed_code": -10,
  416. "msg": err_msg,
  417. })
  418. return
  419. }
  420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  421. result, _ := json.Marshal(respJSON)
  422. fmt.Println("log")
  423. fmt.Println(string(result))
  424. if err := json.Unmarshal([]byte(result), &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == 0 {
  430. sign := models.HisSignIn{
  431. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  432. SignNo: res.Output.Signinoutb.SignNo,
  433. SignTime: "",
  434. Ctime: time.Now().Unix(),
  435. Mtime: time.Now().Unix(),
  436. Status: 1,
  437. InputLog: "",
  438. OutputLog: "",
  439. FixmedinsCode: miConfig.Code,
  440. }
  441. err := service.CreateSignIn(&sign)
  442. if err == nil {
  443. c.ServeSuccessJSON(map[string]interface{}{
  444. "msg": "查询成功",
  445. })
  446. }
  447. } else {
  448. c.ServeSuccessJSON(map[string]interface{}{
  449. "failed_code": -10,
  450. "msg": res.ErrMsg,
  451. })
  452. return
  453. }
  454. }
  455. }
  456. func (c *HisApiController) Get3201() {
  457. adminUser := c.GetAdminUserInfo()
  458. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  459. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  460. var response Response
  461. if err := json.Unmarshal([]byte(result), &response); err != nil {
  462. fmt.Println("Error decoding JSON:", err)
  463. return
  464. }
  465. }
  466. func (c *HisApiController) TestNet() {
  467. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  468. //return
  469. c.ServeSuccessJSON(map[string]interface{}{
  470. "msg": "成功",
  471. })
  472. }
  473. func (c *HisApiController) Get3508() {
  474. admin_user_id, _ := c.GetInt64("admin_user_id")
  475. drug_id, _ := c.GetInt64("id")
  476. start_time := c.GetString("start_time")
  477. end_time := c.GetString("end_time")
  478. adminUser := c.GetAdminUserInfo()
  479. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  480. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  481. drug, _ := service.GetDrugByID(drug_id)
  482. var struct3508 models.Struct3508
  483. struct3508.OrgName = miConfig.OrgName
  484. struct3508.FixmedinsCode = miConfig.Code
  485. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  486. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  487. struct3508.AccessKey = miConfig.AccessKey
  488. struct3508.Opter = curRoles.UserName
  489. struct3508.RequestUrl = miConfig.Url
  490. struct3508.Url = miConfig.Url
  491. struct3508.AppId = miConfig.Cainfo
  492. struct3508.AppSecret = miConfig.AppSecret
  493. struct3508.Enckey = miConfig.EncKey
  494. struct3508.SignKey = miConfig.SignKey
  495. struct3508.SecretKey = miConfig.SecretKey
  496. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  497. struct3508.Begndate = start_time
  498. struct3508.Enddate = end_time
  499. struct3508.Enddate = end_time
  500. struct3508.Enddate = end_time
  501. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  502. result1, result2 := service.Gdyb3508(struct3508, struct3508.SecretKey)
  503. saveLog(result1, result2, "3508", "3508")
  504. var res models.Result3508
  505. var respJSON2 map[string]interface{}
  506. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  509. return
  510. }
  511. userJSONBytes2, _ := json.Marshal(respJSON2)
  512. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  513. utils.ErrorLog("解析失败:%v", err)
  514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  515. return
  516. }
  517. if res.Infcode == -1 {
  518. c.ServeSuccessJSON(map[string]interface{}{
  519. "failed_code": -10,
  520. "msg": res.ErrMsg,
  521. })
  522. } else {
  523. c.ServeSuccessJSON(map[string]interface{}{
  524. "info": res.Output,
  525. })
  526. }
  527. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  528. result1, result2, _ := service.FJyb3508(struct3508)
  529. saveLog(result1, result2, "3508", "3508")
  530. var res models.Result3508
  531. var respJSON2 map[string]interface{}
  532. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  535. return
  536. }
  537. userJSONBytes2, _ := json.Marshal(respJSON2)
  538. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  539. utils.ErrorLog("解析失败:%v", err)
  540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  541. return
  542. }
  543. if res.Infcode == -1 {
  544. c.ServeSuccessJSON(map[string]interface{}{
  545. "failed_code": -10,
  546. "msg": res.ErrMsg,
  547. })
  548. } else {
  549. c.ServeSuccessJSON(map[string]interface{}{
  550. "info": res.Output,
  551. })
  552. }
  553. }
  554. }
  555. func (c *HisApiController) Get3509() {
  556. admin_user_id, _ := c.GetInt64("admin_user_id")
  557. drug_id, _ := c.GetInt64("id")
  558. start_time := c.GetString("start_time")
  559. end_time := c.GetString("end_time")
  560. adminUser := c.GetAdminUserInfo()
  561. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  562. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  563. drug, _ := service.GetDrugByID(drug_id)
  564. var struct3508 models.Struct3509
  565. struct3508.OrgName = miConfig.OrgName
  566. struct3508.FixmedinsCode = miConfig.Code
  567. struct3508.AccessKey = miConfig.AccessKey
  568. struct3508.Opter = curRoles.UserName
  569. struct3508.RequestUrl = miConfig.Url
  570. struct3508.Url = miConfig.Url
  571. struct3508.AppId = miConfig.Cainfo
  572. struct3508.AppSecret = miConfig.AppSecret
  573. struct3508.Enckey = miConfig.EncKey
  574. struct3508.SignKey = miConfig.SignKey
  575. struct3508.SecretKey = miConfig.SecretKey
  576. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  577. struct3508.Begndate = start_time
  578. struct3508.Enddate = end_time
  579. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  580. result1, result2 := service.Gdyb3509(struct3508, struct3508.SecretKey)
  581. saveLog(result1, result2, "3509", "3509")
  582. var res models.Result3508
  583. var respJSON2 map[string]interface{}
  584. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  587. return
  588. }
  589. userJSONBytes2, _ := json.Marshal(respJSON2)
  590. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  591. utils.ErrorLog("解析失败:%v", err)
  592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  593. return
  594. }
  595. if res.Infcode == -1 {
  596. c.ServeSuccessJSON(map[string]interface{}{
  597. "failed_code": -10,
  598. "msg": res.ErrMsg,
  599. })
  600. } else {
  601. c.ServeSuccessJSON(map[string]interface{}{
  602. "info": res.Output,
  603. })
  604. }
  605. } else {
  606. result1, result2, _ := service.FJyb3509(struct3508)
  607. saveLog(result1, result2, "3509", "3509")
  608. var res models.Result3509
  609. var respJSON2 map[string]interface{}
  610. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  613. return
  614. }
  615. userJSONBytes2, _ := json.Marshal(respJSON2)
  616. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  617. utils.ErrorLog("解析失败:%v", err)
  618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  619. return
  620. }
  621. if res.Infcode == -1 {
  622. c.ServeSuccessJSON(map[string]interface{}{
  623. "failed_code": -10,
  624. "msg": res.ErrMsg,
  625. })
  626. } else {
  627. c.ServeSuccessJSON(map[string]interface{}{
  628. "info": res.Output,
  629. })
  630. }
  631. }
  632. }
  633. func (c *HisApiController) Get3510() {
  634. admin_user_id, _ := c.GetInt64("admin_user_id")
  635. drug_id, _ := c.GetInt64("id")
  636. start_time := c.GetString("start_time")
  637. end_time := c.GetString("end_time")
  638. adminUser := c.GetAdminUserInfo()
  639. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  640. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  641. drug, _ := service.GetDrugByID(drug_id)
  642. var struct3508 models.Struct3510
  643. struct3508.FixmedinsCode = miConfig.Code
  644. struct3508.OrgName = miConfig.OrgName
  645. struct3508.AccessKey = miConfig.AccessKey
  646. struct3508.Opter = curRoles.UserName
  647. struct3508.RequestUrl = miConfig.Url
  648. struct3508.Url = miConfig.Url
  649. struct3508.AppId = miConfig.Cainfo
  650. struct3508.AppSecret = miConfig.AppSecret
  651. struct3508.Enckey = miConfig.EncKey
  652. struct3508.SignKey = miConfig.SignKey
  653. struct3508.SecretKey = miConfig.SecretKey
  654. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  655. struct3508.Begndate = start_time
  656. struct3508.Enddate = end_time
  657. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  658. result1, result2 := service.Gdyb3510(struct3508, struct3508.SecretKey)
  659. saveLog(result1, result2, "3510", "3510")
  660. var res models.Result3510
  661. var respJSON2 map[string]interface{}
  662. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  665. return
  666. }
  667. userJSONBytes2, _ := json.Marshal(respJSON2)
  668. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  669. utils.ErrorLog("解析失败:%v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. if res.Infcode == -1 {
  674. c.ServeSuccessJSON(map[string]interface{}{
  675. "failed_code": -10,
  676. "msg": res.ErrMsg,
  677. })
  678. } else {
  679. c.ServeSuccessJSON(map[string]interface{}{
  680. "info": res.Output,
  681. })
  682. }
  683. } else {
  684. result1, result2, _ := service.FJyb3510(struct3508)
  685. saveLog(result1, result2, "3510", "3510")
  686. var res models.Result3510
  687. var respJSON2 map[string]interface{}
  688. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  691. return
  692. }
  693. userJSONBytes2, _ := json.Marshal(respJSON2)
  694. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  695. utils.ErrorLog("解析失败:%v", err)
  696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  697. return
  698. }
  699. if res.Infcode == -1 {
  700. c.ServeSuccessJSON(map[string]interface{}{
  701. "failed_code": -10,
  702. "msg": res.ErrMsg,
  703. })
  704. } else {
  705. c.ServeSuccessJSON(map[string]interface{}{
  706. "info": res.Output,
  707. })
  708. }
  709. }
  710. }
  711. func (c *HisApiController) Get3511() {
  712. admin_user_id, _ := c.GetInt64("admin_user_id")
  713. drug_id, _ := c.GetInt64("id")
  714. start_time := c.GetString("start_time")
  715. end_time := c.GetString("end_time")
  716. adminUser := c.GetAdminUserInfo()
  717. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  718. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  719. drug, _ := service.GetDrugByID(drug_id)
  720. var struct3508 models.Struct3511
  721. struct3508.FixmedinsCode = miConfig.Code
  722. struct3508.OrgName = miConfig.OrgName
  723. struct3508.AccessKey = miConfig.AccessKey
  724. struct3508.Opter = curRoles.UserName
  725. struct3508.RequestUrl = miConfig.Url
  726. struct3508.Url = miConfig.Url
  727. struct3508.AppId = miConfig.Cainfo
  728. struct3508.AppSecret = miConfig.AppSecret
  729. struct3508.Enckey = miConfig.EncKey
  730. struct3508.SignKey = miConfig.SignKey
  731. struct3508.SecretKey = miConfig.SecretKey
  732. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  733. struct3508.Begndate = start_time
  734. struct3508.Enddate = end_time
  735. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  736. result1, result2 := service.Gdyb3511(struct3508, struct3508.SecretKey)
  737. saveLog(result1, result2, "3511", "3511")
  738. var res models.Result3511
  739. var respJSON2 map[string]interface{}
  740. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  743. return
  744. }
  745. userJSONBytes2, _ := json.Marshal(respJSON2)
  746. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  747. utils.ErrorLog("解析失败:%v", err)
  748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  749. return
  750. }
  751. if res.Infcode == -1 {
  752. c.ServeSuccessJSON(map[string]interface{}{
  753. "failed_code": -10,
  754. "msg": res.ErrMsg,
  755. })
  756. } else {
  757. c.ServeSuccessJSON(map[string]interface{}{
  758. "info": res.Output,
  759. })
  760. }
  761. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  762. var res models.Result3511
  763. //安徽
  764. data := make(map[string]interface{})
  765. data["struct_3511s"] = struct3508
  766. client := &http.Client{}
  767. bytesData, _ := json.Marshal(data)
  768. var req *http.Request
  769. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3511", bytes.NewReader(bytesData))
  770. resp, _ := client.Do(req)
  771. defer resp.Body.Close()
  772. body, ioErr := ioutil.ReadAll(resp.Body)
  773. if ioErr != nil {
  774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  775. }
  776. var respJSON map[string]interface{}
  777. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  780. return
  781. }
  782. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  783. result, _ := json.Marshal(respJSON)
  784. if err := json.Unmarshal([]byte(result), &res); err != nil {
  785. //utils.ErrorLog("解析失败:%v", err)
  786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  787. return
  788. }
  789. if res.Infcode == -1 {
  790. c.ServeSuccessJSON(map[string]interface{}{
  791. "failed_code": -10,
  792. "msg": res.ErrMsg,
  793. })
  794. } else {
  795. c.ServeSuccessJSON(map[string]interface{}{
  796. "info": res.Output,
  797. })
  798. }
  799. }else {
  800. result1, result2, _ := service.FJyb3511(struct3508)
  801. saveLog(result1, result2, "3511", "3511")
  802. var res models.Result3511
  803. var respJSON2 map[string]interface{}
  804. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  807. return
  808. }
  809. userJSONBytes2, _ := json.Marshal(respJSON2)
  810. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  811. utils.ErrorLog("解析失败:%v", err)
  812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  813. return
  814. }
  815. if res.Infcode == -1 {
  816. c.ServeSuccessJSON(map[string]interface{}{
  817. "failed_code": -10,
  818. "msg": res.ErrMsg,
  819. })
  820. } else {
  821. c.ServeSuccessJSON(map[string]interface{}{
  822. "info": res.Output,
  823. })
  824. }
  825. }
  826. }
  827. func (c *HisApiController) Get3512() {
  828. admin_user_id, _ := c.GetInt64("admin_user_id")
  829. drug_id, _ := c.GetInt64("id")
  830. start_time := c.GetString("start_time")
  831. end_time := c.GetString("end_time")
  832. adminUser := c.GetAdminUserInfo()
  833. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  834. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  835. drug, _ := service.GetDrugByIDTwo(drug_id,adminUser.CurrentOrgId)
  836. var infos models.Output2
  837. for _, item := range drug{
  838. var struct3508 models.Struct3512
  839. struct3508.FixmedinsCode = miConfig.Code
  840. struct3508.OrgName = miConfig.OrgName
  841. struct3508.AccessKey = miConfig.AccessKey
  842. struct3508.Opter = curRoles.UserName
  843. struct3508.RequestUrl = miConfig.Url
  844. struct3508.Url = miConfig.Url
  845. struct3508.AppId = miConfig.Cainfo
  846. struct3508.AppSecret = miConfig.AppSecret
  847. struct3508.Enckey = miConfig.EncKey
  848. struct3508.SignKey = miConfig.SignKey
  849. struct3508.SecretKey = miConfig.SecretKey
  850. struct3508.MedListCodg = item.MedicalInsuranceNumber
  851. struct3508.Begndate = start_time
  852. struct3508.Enddate = end_time
  853. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  854. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  855. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  856. result1, result2 := service.Gdyb3512(struct3508, struct3508.SecretKey)
  857. saveLog(result1, result2, "3512", "3512")
  858. var res models.Result3512
  859. var respJSON2 map[string]interface{}
  860. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  863. return
  864. }
  865. userJSONBytes2, _ := json.Marshal(respJSON2)
  866. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  867. utils.ErrorLog("解析失败:%v", err)
  868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  869. return
  870. }
  871. infos = append(infos, res.Output...)
  872. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  873. result1, result2, _ := service.FJyb3512(struct3508)
  874. saveLog(result1, result2, "3512", "3512")
  875. var res models.Result3512
  876. var respJSON2 map[string]interface{}
  877. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  880. return
  881. }
  882. userJSONBytes2, _ := json.Marshal(respJSON2)
  883. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  884. utils.ErrorLog("解析失败:%v", err)
  885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  886. return
  887. }
  888. infos = append(infos, res.Output...)
  889. }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  890. var res models.Result3512
  891. //安徽
  892. data := make(map[string]interface{})
  893. data["struct_3512s"] = struct3508
  894. client := &http.Client{}
  895. bytesData, _ := json.Marshal(data)
  896. var req *http.Request
  897. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3512", bytes.NewReader(bytesData))
  898. resp, _ := client.Do(req)
  899. defer resp.Body.Close()
  900. body, ioErr := ioutil.ReadAll(resp.Body)
  901. if ioErr != nil {
  902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  903. }
  904. var respJSON map[string]interface{}
  905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  908. return
  909. }
  910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  911. result, _ := json.Marshal(respJSON)
  912. if err := json.Unmarshal([]byte(result), &res); err != nil {
  913. //utils.ErrorLog("解析失败:%v", err)
  914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  915. return
  916. }
  917. infos = append(infos, res.Output...)
  918. }
  919. }
  920. c.ServeSuccessJSON(map[string]interface{}{
  921. "info": infos,
  922. })
  923. }
  924. func (c *HisApiController) Get3513() {
  925. admin_user_id, _ := c.GetInt64("admin_user_id")
  926. drug_id, _ := c.GetInt64("id")
  927. start_time := c.GetString("start_time")
  928. end_time := c.GetString("end_time")
  929. adminUser := c.GetAdminUserInfo()
  930. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  931. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  932. //drug, _ := service.GetDrugByID(drug_id)
  933. drug, _ := service.GetDrugByIDTwo(drug_id,adminUser.CurrentOrgId)
  934. var infos models.Output3
  935. for _, item := range drug {
  936. var struct3508 models.Struct3513
  937. struct3508.FixmedinsCode = miConfig.Code
  938. struct3508.OrgName = miConfig.OrgName
  939. struct3508.AccessKey = miConfig.AccessKey
  940. struct3508.Opter = curRoles.UserName
  941. struct3508.RequestUrl = miConfig.Url
  942. struct3508.Url = miConfig.Url
  943. struct3508.AppId = miConfig.Cainfo
  944. struct3508.AppSecret = miConfig.AppSecret
  945. struct3508.Enckey = miConfig.EncKey
  946. struct3508.SignKey = miConfig.SignKey
  947. struct3508.SecretKey = miConfig.SecretKey
  948. struct3508.MedListCodg = item.MedicalInsuranceNumber
  949. struct3508.Begndate = start_time
  950. struct3508.Enddate = end_time
  951. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  952. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  953. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  954. result1, result2 := service.Gdyb3513(struct3508, struct3508.SecretKey)
  955. saveLog(result1, result2, "3513", "3513")
  956. var res models.Result3513
  957. var respJSON2 map[string]interface{}
  958. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  961. return
  962. }
  963. userJSONBytes2, _ := json.Marshal(respJSON2)
  964. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  965. utils.ErrorLog("解析失败:%v", err)
  966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  967. return
  968. }
  969. infos = append(infos, res.Output...)
  970. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  971. result1, result2, _ := service.FJyb3513(struct3508)
  972. saveLog(result1, result2, "3513", "3513")
  973. var res models.Result3513
  974. var respJSON2 map[string]interface{}
  975. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. return
  979. }
  980. userJSONBytes2, _ := json.Marshal(respJSON2)
  981. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  982. utils.ErrorLog("解析失败:%v", err)
  983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  984. return
  985. }
  986. infos = append(infos, res.Output...)
  987. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  988. var res models.Result3513
  989. //安徽
  990. data := make(map[string]interface{})
  991. data["struct_3513s"] = struct3508
  992. client := &http.Client{}
  993. bytesData, _ := json.Marshal(data)
  994. var req *http.Request
  995. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3513", bytes.NewReader(bytesData))
  996. resp, _ := client.Do(req)
  997. defer resp.Body.Close()
  998. body, ioErr := ioutil.ReadAll(resp.Body)
  999. if ioErr != nil {
  1000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1001. }
  1002. var respJSON map[string]interface{}
  1003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1006. return
  1007. }
  1008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1009. result, _ := json.Marshal(respJSON)
  1010. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1011. //utils.ErrorLog("解析失败:%v", err)
  1012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1013. return
  1014. }
  1015. infos = append(infos, res.Output...)
  1016. }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") { //
  1017. result1, result2 := service.JXyb3513(struct3508, struct3508.SecretKey, struct3508.AccessKey, struct3508.RequestUrl)
  1018. saveLog(result1, result2, "3513", "3513")
  1019. var res models.Result3513
  1020. var respJSON2 map[string]interface{}
  1021. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. userJSONBytes2, _ := json.Marshal(respJSON2)
  1027. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1028. utils.ErrorLog("解析失败:%v", err)
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. return
  1031. }
  1032. infos = append(infos, res.Output...)
  1033. }
  1034. }
  1035. type Newinfo struct {
  1036. FixmedinsCode string
  1037. MedListCodg string
  1038. MedinsListCodg string
  1039. MedinsListName string
  1040. FixmedinsBchno string
  1041. MdtrtId string
  1042. MdtrtSetlType string
  1043. BkkpSn string
  1044. DrugTracCodg string
  1045. PsnNo string
  1046. PsnCertType string
  1047. Certno string
  1048. PsnName string
  1049. Memo string
  1050. TrdnFlag string
  1051. UpdtTime string
  1052. OpterName string
  1053. Rid string
  1054. CrteTime string
  1055. OptTime string
  1056. OpterId string
  1057. CrterName string
  1058. CrterId string
  1059. OptinsNo string
  1060. }
  1061. var Newinfos []Newinfo
  1062. for _, item := range infos {
  1063. var ni Newinfo
  1064. patient, _ := service.GetPatientByIDCard(item.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1065. //patient, _ := service.GetPatientByIDCard(item.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1066. numbers := strings.Split(item.FixmedinsBchno,"-")
  1067. flow := service.GetSaleDate(numbers[1])
  1068. ni.MdtrtId = item.MdtrtId
  1069. ni.UpdtTime = flow.SaleDate
  1070. ni.PsnName = patient.Name
  1071. ni.Certno = item.Certno
  1072. ni.MedinsListName = item.MedinsListName
  1073. ni.FixmedinsBchno = item.FixmedinsBchno
  1074. ni.DrugTracCodg = item.DrugTracCodg
  1075. ni.MedListCodg = patient.Name
  1076. Newinfos = append(Newinfos, ni)
  1077. }
  1078. c.ServeSuccessJSON(map[string]interface{}{
  1079. "info": Newinfos,
  1080. })
  1081. }
  1082. func (c *HisApiController) Get35081() {
  1083. admin_user_id, _ := c.GetInt64("admin_user_id")
  1084. drug_id, _ := c.GetInt64("id")
  1085. //start_time := c.GetString("start_time")
  1086. //end_time := c.GetString("end_time")
  1087. page, _ := c.GetInt("page")
  1088. adminUser := c.GetAdminUserInfo()
  1089. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1090. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1091. drug, _ := service.GetDrugByID(drug_id)
  1092. var struct3508 models.Struct35081
  1093. struct3508.FixmedinsCode = miConfig.Code
  1094. struct3508.OrgName = miConfig.OrgName
  1095. struct3508.AccessKey = miConfig.AccessKey
  1096. struct3508.Opter = curRoles.UserName
  1097. struct3508.RequestUrl = miConfig.Url
  1098. struct3508.Url = miConfig.Url
  1099. struct3508.AppId = miConfig.Cainfo
  1100. struct3508.AppSecret = miConfig.AppSecret
  1101. struct3508.Enckey = miConfig.EncKey
  1102. struct3508.SignKey = miConfig.SignKey
  1103. struct3508.SecretKey = miConfig.SecretKey
  1104. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1105. struct3508.PageNum = page
  1106. struct3508.PageSize = 10
  1107. result1, result2, _ := service.FJyb35081(struct3508)
  1108. saveLog(result1, result2, "35081", "35081")
  1109. var res models.Result35081
  1110. var respJSON2 map[string]interface{}
  1111. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1114. return
  1115. }
  1116. userJSONBytes2, _ := json.Marshal(respJSON2)
  1117. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1118. utils.ErrorLog("解析失败:%v", err)
  1119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1120. return
  1121. }
  1122. if res.Infcode == -1 {
  1123. c.ServeSuccessJSON(map[string]interface{}{
  1124. "failed_code": -10,
  1125. "msg": res.ErrMsg,
  1126. })
  1127. } else {
  1128. c.ServeSuccessJSON(map[string]interface{}{
  1129. "info": res.Output,
  1130. })
  1131. }
  1132. }
  1133. func (c *HisApiController) Get35082() {
  1134. admin_user_id, _ := c.GetInt64("admin_user_id")
  1135. drug_id, _ := c.GetInt64("id")
  1136. //start_time := c.GetString("start_time")
  1137. //end_time := c.GetString("end_time")
  1138. page, _ := c.GetInt("page")
  1139. adminUser := c.GetAdminUserInfo()
  1140. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1141. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1142. drug, _ := service.GetDrugByID(drug_id)
  1143. var struct3508 models.Struct35082
  1144. struct3508.FixmedinsCode = miConfig.Code
  1145. struct3508.OrgName = miConfig.OrgName
  1146. struct3508.AccessKey = miConfig.AccessKey
  1147. struct3508.Opter = curRoles.UserName
  1148. struct3508.RequestUrl = miConfig.Url
  1149. struct3508.Url = miConfig.Url
  1150. struct3508.AppId = miConfig.Cainfo
  1151. struct3508.AppSecret = miConfig.AppSecret
  1152. struct3508.Enckey = miConfig.EncKey
  1153. struct3508.SignKey = miConfig.SignKey
  1154. struct3508.SecretKey = miConfig.SecretKey
  1155. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1156. struct3508.PageNum = page
  1157. struct3508.PageSize = 10
  1158. result1, result2, _ := service.FJyb35082(struct3508)
  1159. saveLog(result1, result2, "35082", "35082")
  1160. var res models.Result35082
  1161. var respJSON2 map[string]interface{}
  1162. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1165. return
  1166. }
  1167. userJSONBytes2, _ := json.Marshal(respJSON2)
  1168. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1169. utils.ErrorLog("解析失败:%v", err)
  1170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1171. return
  1172. }
  1173. if res.Infcode == -1 {
  1174. c.ServeSuccessJSON(map[string]interface{}{
  1175. "failed_code": -10,
  1176. "msg": res.ErrMsg,
  1177. })
  1178. } else {
  1179. c.ServeSuccessJSON(map[string]interface{}{
  1180. "info": res.Output,
  1181. })
  1182. }
  1183. }
  1184. func IsDigit(s string) bool {
  1185. re := regexp.MustCompile("^[0-9]+$")
  1186. return re.MatchString(s)
  1187. }
  1188. func (c *HisApiController) FJ3501AND3502() {
  1189. ids := c.GetString("ids")
  1190. admin_user_id, _ := c.GetInt64("admin_user_id")
  1191. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1192. id_arr := strings.Split(ids, ",")
  1193. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1194. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1195. //规则判断
  1196. var errs []string
  1197. for _, drug := range drugs {
  1198. if drug.IsPc == 0 {
  1199. if len(drug.DrugCode) > 0 {
  1200. codes := strings.Split(drug.DrugCode, ",")
  1201. for _, code := range codes {
  1202. if len(code) > 0 {
  1203. if len(code) != 20 {
  1204. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  1205. }
  1206. if IsDigit(code) == false {
  1207. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  1208. }
  1209. }
  1210. }
  1211. }
  1212. }
  1213. }
  1214. if len(errs) > 0 {
  1215. c.ServeSuccessJSON(map[string]interface{}{
  1216. "failed_code": -10,
  1217. "msg": errs,
  1218. })
  1219. return
  1220. }
  1221. //库盘
  1222. for _, drug := range drugs {
  1223. if drug.IsPc == 0 {
  1224. var res2 ResultSix
  1225. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  1226. var struct3501 models.Struct3501
  1227. struct3501.Code = miConfig.Code
  1228. struct3501.OrgName = miConfig.OrgName
  1229. struct3501.AccessKey = miConfig.AccessKey
  1230. struct3501.Opter = roles.UserName
  1231. struct3501.RequestUrl = miConfig.Url
  1232. struct3501.Url = miConfig.Url
  1233. struct3501.AppId = miConfig.Cainfo
  1234. struct3501.AppSecret = miConfig.AppSecret
  1235. struct3501.Enckey = miConfig.EncKey
  1236. struct3501.SignKey = miConfig.SignKey
  1237. struct3501.SecretKey = miConfig.SecretKey
  1238. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1239. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1240. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1241. struct3501.RxFlag = "1"
  1242. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  1243. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1244. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1245. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1246. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  1247. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  1248. struct3501.FixmedinsBchno = number
  1249. struct3501.DrugTracCodg = drug.DrugCode
  1250. memo := make(map[string]interface{})
  1251. memo["pric"] = drug.Price
  1252. bytesData, _ := json.Marshal(memo)
  1253. struct3501.Memo = string(bytesData)
  1254. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  1255. result1, result2, _ := service.FJyb3501(struct3501)
  1256. saveLog(result1, result2, "3501", "3501")
  1257. //saveLog(result, requestLog, "2201", "挂号")
  1258. var respJSON2 map[string]interface{}
  1259. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1262. return
  1263. }
  1264. userJSONBytes2, _ := json.Marshal(respJSON2)
  1265. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1266. utils.ErrorLog("解析失败:%v", err)
  1267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1268. return
  1269. }
  1270. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  1271. data := make(map[string]interface{})
  1272. data["struct_3501s"] = struct3501
  1273. client := &http.Client{}
  1274. bytesData, _ := json.Marshal(data)
  1275. var req *http.Request
  1276. if miConfig.MdtrtareaAdmvs == "320830" {
  1277. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  1278. } else {
  1279. if miConfig.MdtrtareaAdmvs == "320921" {
  1280. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1281. } else {
  1282. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1283. }
  1284. }
  1285. resp, _ := client.Do(req)
  1286. defer resp.Body.Close()
  1287. body, ioErr := ioutil.ReadAll(resp.Body)
  1288. if ioErr != nil {
  1289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1290. }
  1291. var respJSON map[string]interface{}
  1292. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1295. return
  1296. }
  1297. var resSix10265 ResultSix10265 //1101结果
  1298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1299. result, _ := json.Marshal(respJSON)
  1300. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1301. utils.ErrorLog("解析失败:%v", err)
  1302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1303. return
  1304. }
  1305. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1306. res2.Output = resSix10265.Output
  1307. res2.ErrMsg = resSix10265.ErrMsg
  1308. res2.Cainfo = resSix10265.Cainfo
  1309. res2.WarnMsg = resSix10265.WarnMsg
  1310. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1311. res2.Infcode = infocode
  1312. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  1313. data := make(map[string]interface{})
  1314. data["struct_3501s"] = struct3501
  1315. client := &http.Client{}
  1316. bytesData, _ := json.Marshal(data)
  1317. var req *http.Request
  1318. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1319. resp, _ := client.Do(req)
  1320. defer resp.Body.Close()
  1321. body, ioErr := ioutil.ReadAll(resp.Body)
  1322. if ioErr != nil {
  1323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1324. }
  1325. var respJSON map[string]interface{}
  1326. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1329. return
  1330. }
  1331. var resSix10265 ResultSix10265 //1101结果
  1332. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1333. result, _ := json.Marshal(respJSON)
  1334. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1335. utils.ErrorLog("解析失败:%v", err)
  1336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1337. return
  1338. }
  1339. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1340. res2.Output = resSix10265.Output
  1341. res2.ErrMsg = resSix10265.ErrMsg
  1342. res2.Cainfo = resSix10265.Cainfo
  1343. res2.WarnMsg = resSix10265.WarnMsg
  1344. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1345. res2.Infcode = infocode
  1346. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  1347. data := make(map[string]interface{})
  1348. data["struct_3501s"] = struct3501
  1349. client := &http.Client{}
  1350. bytesData, _ := json.Marshal(data)
  1351. var req *http.Request
  1352. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  1353. resp, _ := client.Do(req)
  1354. defer resp.Body.Close()
  1355. body, ioErr := ioutil.ReadAll(resp.Body)
  1356. if ioErr != nil {
  1357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1358. }
  1359. var respJSON map[string]interface{}
  1360. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1363. return
  1364. }
  1365. var resSix10265 ResultSix10265 //1101结果
  1366. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1367. result, _ := json.Marshal(respJSON)
  1368. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1369. utils.ErrorLog("解析失败:%v", err)
  1370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1371. return
  1372. }
  1373. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1374. res2.Output = resSix10265.Output
  1375. res2.ErrMsg = resSix10265.ErrMsg
  1376. res2.Cainfo = resSix10265.Cainfo
  1377. res2.WarnMsg = resSix10265.WarnMsg
  1378. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1379. res2.Infcode = infocode
  1380. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  1381. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  1382. saveLog(result1, result2, "3501", "3501")
  1383. //saveLog(result, requestLog, "2201", "挂号")
  1384. var respJSON2 map[string]interface{}
  1385. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1388. return
  1389. }
  1390. userJSONBytes2, _ := json.Marshal(respJSON2)
  1391. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1392. utils.ErrorLog("解析失败:%v", err)
  1393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1394. return
  1395. }
  1396. }
  1397. utils.ErrorLog("解析失败:%v", res2.Infcode)
  1398. if res2.Infcode != -1 {
  1399. drug.IsPc = 1
  1400. drug.Bchno = number
  1401. drug.PcDate = time.Now().Unix()
  1402. service.SaveW(drug)
  1403. //if err == nil {
  1404. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  1405. // var struct3502 models.Struct3502
  1406. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1407. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1408. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1409. // struct3502.FixmedinsCode = miConfig.Code
  1410. // struct3502.Code = miConfig.Code
  1411. //
  1412. // struct3502.RxFlag = "0"
  1413. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1414. // struct3502.OrgName = miConfig.OrgName
  1415. // struct3502.Opter = roles.UserName
  1416. // struct3502.AccessKey = miConfig.AccessKey
  1417. // struct3502.RequestUrl = miConfig.Url
  1418. // struct3502.SecretKey = miConfig.SecretKey
  1419. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1420. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1421. // struct3502.Url = miConfig.Url
  1422. // struct3502.AppId = miConfig.Cainfo
  1423. // struct3502.AppSecret = miConfig.AppSecret
  1424. // struct3502.Enckey = miConfig.EncKey
  1425. // struct3502.SignKey = miConfig.SignKey
  1426. // struct3502.SecretKey = miConfig.SecretKey
  1427. // struct3502.DrugTracCodg = drug.DrugCode
  1428. //
  1429. // struct3502.Memo = ""
  1430. // struct3502.InvChgType = "108"
  1431. // struct3502.FixmedinsBchno = bg_number
  1432. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  1433. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  1434. //
  1435. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  1436. // result11, result22, _ := service.FJyb3502(struct3502)
  1437. // saveLog(result11, result22, "3502", "3502")
  1438. //
  1439. // var respJSON3 map[string]interface{}
  1440. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1441. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1442. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1443. // return
  1444. // }
  1445. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1446. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1447. // utils.ErrorLog("解析失败:%v", err)
  1448. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1449. // return
  1450. // }
  1451. //
  1452. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1453. // data := make(map[string]interface{})
  1454. // data["struct_3502s"] = struct3502
  1455. // client := &http.Client{}
  1456. // bytesData, _ := json.Marshal(data)
  1457. // var req *http.Request
  1458. // if miConfig.MdtrtareaAdmvs == "320830" {
  1459. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  1460. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  1461. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1462. // } else {
  1463. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1464. // }
  1465. //
  1466. // resp, _ := client.Do(req)
  1467. // defer resp.Body.Close()
  1468. // body, ioErr := ioutil.ReadAll(resp.Body)
  1469. // if ioErr != nil {
  1470. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1471. // }
  1472. // var respJSON map[string]interface{}
  1473. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1474. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1476. // return
  1477. // }
  1478. // var resSix10265 ResultSix10265 //1101结果
  1479. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1480. // result, _ := json.Marshal(respJSON)
  1481. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1482. // utils.ErrorLog("解析失败:%v", err)
  1483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1484. // return
  1485. // }
  1486. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1487. // res3.Output = resSix10265.Output
  1488. // res3.ErrMsg = resSix10265.ErrMsg
  1489. // res3.Cainfo = resSix10265.Cainfo
  1490. // res3.WarnMsg = resSix10265.WarnMsg
  1491. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1492. // res3.Infcode = infocode
  1493. //
  1494. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1495. //
  1496. // data := make(map[string]interface{})
  1497. // data["struct_3502s"] = struct3502
  1498. // client := &http.Client{}
  1499. // bytesData, _ := json.Marshal(data)
  1500. // var req *http.Request
  1501. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  1502. // resp, _ := client.Do(req)
  1503. // defer resp.Body.Close()
  1504. // body, ioErr := ioutil.ReadAll(resp.Body)
  1505. // if ioErr != nil {
  1506. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1507. // }
  1508. // var respJSON map[string]interface{}
  1509. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1510. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1511. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1512. // return
  1513. // }
  1514. // var resSix10265 ResultSix10265 //1101结果
  1515. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1516. // result, _ := json.Marshal(respJSON)
  1517. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1518. // utils.ErrorLog("解析失败:%v", err)
  1519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1520. // return
  1521. // }
  1522. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1523. // res3.Output = resSix10265.Output
  1524. // res3.ErrMsg = resSix10265.ErrMsg
  1525. // res3.Cainfo = resSix10265.Cainfo
  1526. // res3.WarnMsg = resSix10265.WarnMsg
  1527. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1528. // res3.Infcode = infocode
  1529. //
  1530. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1531. //
  1532. // data := make(map[string]interface{})
  1533. // data["struct_3501s"] = struct3501
  1534. // client := &http.Client{}
  1535. // bytesData, _ := json.Marshal(data)
  1536. // var req *http.Request
  1537. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1538. // resp, _ := client.Do(req)
  1539. // defer resp.Body.Close()
  1540. // body, ioErr := ioutil.ReadAll(resp.Body)
  1541. // if ioErr != nil {
  1542. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1543. // }
  1544. // var respJSON map[string]interface{}
  1545. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1546. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1548. // return
  1549. // }
  1550. // var resSix10265 ResultSix10265 //1101结果
  1551. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1552. // result, _ := json.Marshal(respJSON)
  1553. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1554. // utils.ErrorLog("解析失败:%v", err)
  1555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1556. // return
  1557. // }
  1558. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  1559. // res2.Output = resSix10265.Output
  1560. // res2.ErrMsg = resSix10265.ErrMsg
  1561. // res2.Cainfo = resSix10265.Cainfo
  1562. // res2.WarnMsg = resSix10265.WarnMsg
  1563. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1564. // res2.Infcode = infocode
  1565. //
  1566. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1567. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  1568. // saveLog(result11, result22, "3502", "3502")
  1569. //
  1570. // var respJSON3 map[string]interface{}
  1571. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1572. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1573. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1574. // return
  1575. // }
  1576. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1577. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1578. // utils.ErrorLog("解析失败:%v", err)
  1579. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1580. // return
  1581. // }
  1582. // }
  1583. // if res3.Infcode == -1 {
  1584. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1585. // c.ServeSuccessJSON(map[string]interface{}{
  1586. // "failed_code": -10,
  1587. // "msg": res3.ErrMsg,
  1588. // })
  1589. // } else {
  1590. // drug.IsBg = 1
  1591. // drug.BgBchno = bg_number
  1592. // service.SaveW(drug)
  1593. // }
  1594. //}
  1595. //} else {
  1596. } else {
  1597. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  1598. }
  1599. }
  1600. //变更
  1601. }
  1602. if len(errs) == 0 {
  1603. c.ServeSuccessJSON(map[string]interface{}{
  1604. "msg": "盘存变更成功",
  1605. })
  1606. } else {
  1607. c.ServeSuccessJSON(map[string]interface{}{
  1608. "failed_code": -10,
  1609. "msg": errs,
  1610. })
  1611. }
  1612. }
  1613. func (c *HisApiController) DeletePCandBG() {
  1614. ids := c.GetString("ids")
  1615. id_arr := strings.Split(ids, ",")
  1616. admin_user_id, _ := c.GetInt64("admin_user_id")
  1617. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1618. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1619. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1620. var err []string
  1621. for _, item := range drugs {
  1622. if item.IsPc == 1 {
  1623. var res FJ3507Result
  1624. var struct3507 models.Struct3507
  1625. struct3507.FixmedinsBchno = item.Bchno
  1626. struct3507.InvDataType = "1"
  1627. struct3507.Opter = roles.UserName
  1628. struct3507.OrgName = miConfig.OrgName
  1629. struct3507.AccessKey = miConfig.AccessKey
  1630. struct3507.RequestUrl = miConfig.Url
  1631. struct3507.FixmedinsCode = miConfig.Code
  1632. struct3507.Code = miConfig.Code
  1633. struct3507.SecretKey = miConfig.SecretKey
  1634. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1635. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1636. struct3507.Url = miConfig.Url
  1637. struct3507.AppId = miConfig.Cainfo
  1638. struct3507.AppSecret = miConfig.AppSecret
  1639. struct3507.Enckey = miConfig.EncKey
  1640. struct3507.SignKey = miConfig.SignKey
  1641. struct3507.SecretKey = miConfig.SecretKey
  1642. if miConfig.MdtrtareaAdmvs == "350500" {
  1643. result, result1, _ := service.FJyb3507(struct3507)
  1644. saveLog(result, result1, "3507", "3507")
  1645. var respJSON2 map[string]interface{}
  1646. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1649. return
  1650. }
  1651. userJSONBytes2, _ := json.Marshal(respJSON2)
  1652. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1653. utils.ErrorLog("解析失败:%v", err)
  1654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1655. return
  1656. }
  1657. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1658. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  1659. saveLog(result2, result1, "3507", "3507")
  1660. var respJSON2 map[string]interface{}
  1661. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1664. return
  1665. }
  1666. userJSONBytes2, _ := json.Marshal(respJSON2)
  1667. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1668. utils.ErrorLog("解析失败:%v", err)
  1669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1670. return
  1671. }
  1672. } else {
  1673. data := make(map[string]interface{})
  1674. data["struct_3507s"] = struct3507
  1675. client := &http.Client{}
  1676. bytesData, _ := json.Marshal(data)
  1677. var req *http.Request
  1678. if miConfig.MdtrtareaAdmvs == "320830" {
  1679. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1680. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1681. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1682. } else {
  1683. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1684. }
  1685. resp, _ := client.Do(req)
  1686. defer resp.Body.Close()
  1687. body, ioErr := ioutil.ReadAll(resp.Body)
  1688. if ioErr != nil {
  1689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1690. }
  1691. var respJSON map[string]interface{}
  1692. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1695. return
  1696. }
  1697. var resSix10265 ResultSix10265 //1101结果
  1698. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1699. result, _ := json.Marshal(respJSON)
  1700. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1701. utils.ErrorLog("解析失败:%v", err)
  1702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1703. return
  1704. }
  1705. res.InfRefmsgid = resSix10265.InfRefmsgid
  1706. //res.Output = resSix10265.Output
  1707. res.ErrMsg = resSix10265.ErrMsg
  1708. res.Cainfo = resSix10265.Cainfo
  1709. res.WarnMsg = resSix10265.WarnMsg
  1710. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1711. res.Infcode = infocode
  1712. }
  1713. if res.Infcode == 0 {
  1714. item.IsPc = 0
  1715. service.SaveW(item)
  1716. } else {
  1717. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1718. }
  1719. }
  1720. }
  1721. if len(err) == 0 {
  1722. c.ServeSuccessJSON(map[string]interface{}{
  1723. "msg": "删除盘存变更成功",
  1724. })
  1725. } else {
  1726. c.ServeSuccessJSON(map[string]interface{}{
  1727. "failed_code": -10,
  1728. "msg": err,
  1729. })
  1730. }
  1731. }
  1732. func (c *HisApiController) DeleteXSandBG() {
  1733. ids := c.GetString("ids")
  1734. id_arr := strings.Split(ids, ",")
  1735. admin_user_id, _ := c.GetInt64("admin_user_id")
  1736. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1737. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1738. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1739. var err []string
  1740. for _, item := range flows {
  1741. if item.IsSale == 1 && item.IsChange == 1 {
  1742. var res FJ3507Result
  1743. var res2 FJ3507Result
  1744. var struct3507 models.Struct3507
  1745. struct3507.FixmedinsBchno = item.Bchno
  1746. struct3507.InvDataType = "4"
  1747. struct3507.Opter = roles.UserName
  1748. struct3507.OrgName = miConfig.OrgName
  1749. struct3507.AccessKey = miConfig.AccessKey
  1750. struct3507.RequestUrl = miConfig.Url
  1751. struct3507.FixmedinsCode = miConfig.Code
  1752. struct3507.SecretKey = miConfig.SecretKey
  1753. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1754. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1755. struct3507.Url = miConfig.Url
  1756. struct3507.AppId = miConfig.Cainfo
  1757. struct3507.AppSecret = miConfig.AppSecret
  1758. struct3507.Enckey = miConfig.EncKey
  1759. struct3507.SignKey = miConfig.SignKey
  1760. struct3507.SecretKey = miConfig.SecretKey
  1761. //result, result1, _ := service.FJyb3507(struct3507)
  1762. //saveLog(result, result1, "3507", "3507")
  1763. if miConfig.MdtrtareaAdmvs == "350500" {
  1764. result, result1, _ := service.FJyb3507(struct3507)
  1765. saveLog(result, result1, "3507", "3507")
  1766. var respJSON2 map[string]interface{}
  1767. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1770. return
  1771. }
  1772. userJSONBytes2, _ := json.Marshal(respJSON2)
  1773. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1774. utils.ErrorLog("解析失败:%v", err)
  1775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1776. return
  1777. }
  1778. } else {
  1779. data := make(map[string]interface{})
  1780. data["struct_3507s"] = struct3507
  1781. client := &http.Client{}
  1782. bytesData, _ := json.Marshal(data)
  1783. var req *http.Request
  1784. if miConfig.MdtrtareaAdmvs == "320830" {
  1785. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1786. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1787. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1788. } else {
  1789. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1790. }
  1791. resp, _ := client.Do(req)
  1792. defer resp.Body.Close()
  1793. body, ioErr := ioutil.ReadAll(resp.Body)
  1794. if ioErr != nil {
  1795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1796. }
  1797. var respJSON map[string]interface{}
  1798. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1801. return
  1802. }
  1803. var resSix10265 ResultSix10265 //1101结果
  1804. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1805. result, _ := json.Marshal(respJSON)
  1806. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1807. utils.ErrorLog("解析失败:%v", err)
  1808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1809. return
  1810. }
  1811. res.InfRefmsgid = resSix10265.InfRefmsgid
  1812. //res.Output = resSix10265.Output
  1813. res.ErrMsg = resSix10265.ErrMsg
  1814. res.Cainfo = resSix10265.Cainfo
  1815. res.WarnMsg = resSix10265.WarnMsg
  1816. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1817. res.Infcode = infocode
  1818. }
  1819. if res.Infcode == 0 {
  1820. item.IsSale = 0
  1821. item.SaleDate = ""
  1822. item.Bchno = ""
  1823. err2 := service.SaveDF(item)
  1824. if err2 == nil {
  1825. var struct3507_2 models.Struct3507
  1826. struct3507_2.OrgName = miConfig.OrgName
  1827. struct3507_2.AccessKey = miConfig.AccessKey
  1828. struct3507_2.RequestUrl = miConfig.Url
  1829. struct3507_2.Opter = roles.UserName
  1830. struct3507_2.FixmedinsCode = miConfig.Code
  1831. struct3507_2.Code = miConfig.Code
  1832. struct3507_2.SecretKey = miConfig.SecretKey
  1833. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1834. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1835. struct3507_2.Url = miConfig.Url
  1836. struct3507_2.AppId = miConfig.Cainfo
  1837. struct3507_2.AppSecret = miConfig.AppSecret
  1838. struct3507_2.Enckey = miConfig.EncKey
  1839. struct3507_2.SignKey = miConfig.SignKey
  1840. struct3507_2.SecretKey = miConfig.SecretKey
  1841. struct3507_2.FixmedinsBchno = item.BgBchno
  1842. struct3507_2.InvDataType = "2"
  1843. if miConfig.MdtrtareaAdmvs == "350500" {
  1844. result11, result22, _ := service.FJyb3507(struct3507_2)
  1845. saveLog(result11, result22, "3507", "3507")
  1846. var respJSON3 map[string]interface{}
  1847. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1850. return
  1851. }
  1852. userJSONBytes3, _ := json.Marshal(respJSON3)
  1853. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1854. utils.ErrorLog("解析失败:%v", err)
  1855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1856. return
  1857. }
  1858. } else {
  1859. data := make(map[string]interface{})
  1860. data["struct_3507s"] = struct3507_2
  1861. client := &http.Client{}
  1862. bytesData, _ := json.Marshal(data)
  1863. var req *http.Request
  1864. if miConfig.MdtrtareaAdmvs == "320830" {
  1865. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1866. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1867. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1868. } else {
  1869. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1870. }
  1871. resp, _ := client.Do(req)
  1872. defer resp.Body.Close()
  1873. body, ioErr := ioutil.ReadAll(resp.Body)
  1874. if ioErr != nil {
  1875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1876. }
  1877. var respJSON map[string]interface{}
  1878. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1881. return
  1882. }
  1883. var resSix10265 ResultSix10265 //1101结果
  1884. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1885. result, _ := json.Marshal(respJSON)
  1886. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1887. utils.ErrorLog("解析失败:%v", err)
  1888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1889. return
  1890. }
  1891. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1892. //res.Output = resSix10265.Output
  1893. res2.ErrMsg = resSix10265.ErrMsg
  1894. res2.Cainfo = resSix10265.Cainfo
  1895. res2.WarnMsg = resSix10265.WarnMsg
  1896. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1897. res2.Infcode = infocode
  1898. }
  1899. if res2.Infcode == 0 {
  1900. item.IsChange = 0
  1901. item.BgBchno = ""
  1902. service.SaveDF2(item)
  1903. } else {
  1904. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1905. }
  1906. }
  1907. } else {
  1908. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1909. }
  1910. }
  1911. if item.IsSale == 2 && item.IsChange == 1 {
  1912. var res FJ3507Result
  1913. var res2 FJ3507Result
  1914. var struct3507 models.Struct3507
  1915. struct3507.FixmedinsBchno = item.Bchno
  1916. struct3507.InvDataType = "4"
  1917. struct3507.Opter = roles.UserName
  1918. struct3507.OrgName = miConfig.OrgName
  1919. struct3507.AccessKey = miConfig.AccessKey
  1920. struct3507.RequestUrl = miConfig.Url
  1921. struct3507.FixmedinsCode = miConfig.Code
  1922. struct3507.Code = miConfig.Code
  1923. struct3507.SecretKey = miConfig.SecretKey
  1924. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1925. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1926. struct3507.Url = miConfig.Url
  1927. struct3507.AppId = miConfig.Cainfo
  1928. struct3507.AppSecret = miConfig.AppSecret
  1929. struct3507.Enckey = miConfig.EncKey
  1930. struct3507.SignKey = miConfig.SignKey
  1931. struct3507.SecretKey = miConfig.SecretKey
  1932. //result, result1, _ := service.FJyb3507(struct3507)
  1933. //saveLog(result, result1, "3507", "3507")
  1934. //
  1935. //var respJSON2 map[string]interface{}
  1936. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1937. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1938. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1939. // return
  1940. //}
  1941. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1942. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1943. // utils.ErrorLog("解析失败:%v", err)
  1944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1945. // return
  1946. //}
  1947. if miConfig.MdtrtareaAdmvs == "350500" {
  1948. result, result1, _ := service.FJyb3507(struct3507)
  1949. saveLog(result, result1, "3507", "3507")
  1950. var respJSON2 map[string]interface{}
  1951. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1954. return
  1955. }
  1956. userJSONBytes2, _ := json.Marshal(respJSON2)
  1957. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1958. utils.ErrorLog("解析失败:%v", err)
  1959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1960. return
  1961. }
  1962. } else {
  1963. data := make(map[string]interface{})
  1964. data["struct_3507s"] = struct3507
  1965. client := &http.Client{}
  1966. bytesData, _ := json.Marshal(data)
  1967. var req *http.Request
  1968. if miConfig.MdtrtareaAdmvs == "320830" {
  1969. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1970. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1971. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1972. } else {
  1973. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1974. }
  1975. resp, _ := client.Do(req)
  1976. defer resp.Body.Close()
  1977. body, ioErr := ioutil.ReadAll(resp.Body)
  1978. if ioErr != nil {
  1979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1980. }
  1981. var respJSON map[string]interface{}
  1982. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1985. return
  1986. }
  1987. var resSix10265 ResultSix10265 //1101结果
  1988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1989. result, _ := json.Marshal(respJSON)
  1990. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1991. utils.ErrorLog("解析失败:%v", err)
  1992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1993. return
  1994. }
  1995. res.InfRefmsgid = resSix10265.InfRefmsgid
  1996. //res.Output = resSix10265.Output
  1997. res.ErrMsg = resSix10265.ErrMsg
  1998. res.Cainfo = resSix10265.Cainfo
  1999. res.WarnMsg = resSix10265.WarnMsg
  2000. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2001. res.Infcode = infocode
  2002. }
  2003. if res.Infcode == 0 {
  2004. item.IsSale = 0
  2005. item.SaleDate = ""
  2006. item.Bchno = ""
  2007. err2 := service.SaveDF(item)
  2008. if err2 == nil {
  2009. var struct3507_2 models.Struct3507
  2010. struct3507_2.OrgName = miConfig.OrgName
  2011. struct3507_2.AccessKey = miConfig.AccessKey
  2012. struct3507_2.RequestUrl = miConfig.Url
  2013. struct3507_2.Opter = roles.UserName
  2014. struct3507_2.FixmedinsCode = miConfig.Code
  2015. struct3507_2.Code = miConfig.Code
  2016. struct3507_2.SecretKey = miConfig.SecretKey
  2017. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2018. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2019. struct3507_2.Url = miConfig.Url
  2020. struct3507_2.AppId = miConfig.Cainfo
  2021. struct3507_2.AppSecret = miConfig.AppSecret
  2022. struct3507_2.Enckey = miConfig.EncKey
  2023. struct3507_2.SignKey = miConfig.SignKey
  2024. struct3507_2.SecretKey = miConfig.SecretKey
  2025. struct3507_2.FixmedinsBchno = item.BgBchno
  2026. struct3507_2.InvDataType = "2"
  2027. //result11, result22, _ := service.FJyb3507(struct3507_2)
  2028. //saveLog(result11, result22, "3507", "3507")
  2029. //var respJSON3 map[string]interface{}
  2030. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2031. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2033. // return
  2034. //}
  2035. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2036. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2037. // utils.ErrorLog("解析失败:%v", err)
  2038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2039. // return
  2040. //}
  2041. if miConfig.MdtrtareaAdmvs == "350500" {
  2042. result11, result22, _ := service.FJyb3507(struct3507_2)
  2043. saveLog(result11, result22, "3507", "3507")
  2044. var respJSON3 map[string]interface{}
  2045. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2048. return
  2049. }
  2050. userJSONBytes3, _ := json.Marshal(respJSON3)
  2051. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2052. utils.ErrorLog("解析失败:%v", err)
  2053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2054. return
  2055. }
  2056. } else {
  2057. data := make(map[string]interface{})
  2058. data["struct_3507s"] = struct3507_2
  2059. client := &http.Client{}
  2060. bytesData, _ := json.Marshal(data)
  2061. var req *http.Request
  2062. if miConfig.MdtrtareaAdmvs == "320830" {
  2063. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2064. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2065. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2066. } else {
  2067. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2068. }
  2069. resp, _ := client.Do(req)
  2070. defer resp.Body.Close()
  2071. body, ioErr := ioutil.ReadAll(resp.Body)
  2072. if ioErr != nil {
  2073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2074. }
  2075. var respJSON map[string]interface{}
  2076. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2079. return
  2080. }
  2081. var resSix10265 ResultSix10265 //1101结果
  2082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2083. result, _ := json.Marshal(respJSON)
  2084. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2085. utils.ErrorLog("解析失败:%v", err)
  2086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2087. return
  2088. }
  2089. res2.InfRefmsgid = resSix10265.InfRefmsgid
  2090. //res.Output = resSix10265.Output
  2091. res2.ErrMsg = resSix10265.ErrMsg
  2092. res2.Cainfo = resSix10265.Cainfo
  2093. res2.WarnMsg = resSix10265.WarnMsg
  2094. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2095. res2.Infcode = infocode
  2096. }
  2097. if res2.Infcode == 0 {
  2098. item.IsChange = 0
  2099. item.BgBchno = ""
  2100. service.SaveDF2(item)
  2101. } else {
  2102. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2103. }
  2104. }
  2105. } else {
  2106. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2107. }
  2108. }
  2109. if item.IsSale == 1 && item.IsChange == 0 {
  2110. var res FJ3507Result
  2111. var struct3507 models.Struct3507
  2112. struct3507.FixmedinsBchno = item.Bchno
  2113. struct3507.InvDataType = "4"
  2114. struct3507.Opter = roles.UserName
  2115. struct3507.FixmedinsCode = miConfig.Code
  2116. struct3507.Code = miConfig.Code
  2117. struct3507.OrgName = miConfig.OrgName
  2118. struct3507.AccessKey = miConfig.AccessKey
  2119. struct3507.RequestUrl = miConfig.Url
  2120. struct3507.SecretKey = miConfig.SecretKey
  2121. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2122. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2123. struct3507.Url = miConfig.Url
  2124. struct3507.AppId = miConfig.Cainfo
  2125. struct3507.AppSecret = miConfig.AppSecret
  2126. struct3507.Enckey = miConfig.EncKey
  2127. struct3507.SignKey = miConfig.SignKey
  2128. struct3507.SecretKey = miConfig.SecretKey
  2129. //result, result1, _ := service.FJyb3507(struct3507)
  2130. //saveLog(result, result1, "3507", "3507")
  2131. //
  2132. //var respJSON3 map[string]interface{}
  2133. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2134. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2135. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2136. // return
  2137. //}
  2138. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2139. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2140. // utils.ErrorLog("解析失败:%v", err)
  2141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2142. // return
  2143. //}
  2144. if miConfig.MdtrtareaAdmvs == "350500" {
  2145. result, result1, _ := service.FJyb3507(struct3507)
  2146. saveLog(result, result1, "3507", "3507")
  2147. var respJSON2 map[string]interface{}
  2148. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2151. return
  2152. }
  2153. userJSONBytes2, _ := json.Marshal(respJSON2)
  2154. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2155. utils.ErrorLog("解析失败:%v", err)
  2156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2157. return
  2158. }
  2159. } else {
  2160. data := make(map[string]interface{})
  2161. data["struct_3507s"] = struct3507
  2162. client := &http.Client{}
  2163. bytesData, _ := json.Marshal(data)
  2164. var req *http.Request
  2165. if miConfig.MdtrtareaAdmvs == "320830" {
  2166. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2167. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2168. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2169. } else {
  2170. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2171. }
  2172. resp, _ := client.Do(req)
  2173. defer resp.Body.Close()
  2174. body, ioErr := ioutil.ReadAll(resp.Body)
  2175. if ioErr != nil {
  2176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2177. }
  2178. var respJSON map[string]interface{}
  2179. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2182. return
  2183. }
  2184. var resSix10265 ResultSix10265 //1101结果
  2185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2186. result, _ := json.Marshal(respJSON)
  2187. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2188. utils.ErrorLog("解析失败:%v", err)
  2189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2190. return
  2191. }
  2192. res.InfRefmsgid = resSix10265.InfRefmsgid
  2193. //res.Output = resSix10265.Output
  2194. res.ErrMsg = resSix10265.ErrMsg
  2195. res.Cainfo = resSix10265.Cainfo
  2196. res.WarnMsg = resSix10265.WarnMsg
  2197. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2198. res.Infcode = infocode
  2199. }
  2200. if res.Infcode == 0 {
  2201. item.IsSale = 0
  2202. item.SaleDate = ""
  2203. service.SaveDF(item)
  2204. } else {
  2205. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2206. }
  2207. }
  2208. if item.IsSale == 2 && item.IsChange == 0 {
  2209. var res FJ3507Result
  2210. var struct3507 models.Struct3507
  2211. struct3507.FixmedinsBchno = item.Bchno
  2212. struct3507.InvDataType = "4"
  2213. struct3507.Opter = roles.UserName
  2214. struct3507.FixmedinsCode = miConfig.Code
  2215. struct3507.Code = miConfig.Code
  2216. struct3507.OrgName = miConfig.OrgName
  2217. struct3507.AccessKey = miConfig.AccessKey
  2218. struct3507.RequestUrl = miConfig.Url
  2219. struct3507.SecretKey = miConfig.SecretKey
  2220. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2221. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2222. struct3507.Url = miConfig.Url
  2223. struct3507.AppId = miConfig.Cainfo
  2224. struct3507.AppSecret = miConfig.AppSecret
  2225. struct3507.Enckey = miConfig.EncKey
  2226. struct3507.SignKey = miConfig.SignKey
  2227. struct3507.SecretKey = miConfig.SecretKey
  2228. //result, result1, _ := service.FJyb3507(struct3507)
  2229. //saveLog(result, result1, "3507", "3507")
  2230. //
  2231. //var respJSON3 map[string]interface{}
  2232. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2233. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2235. // return
  2236. //}
  2237. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2238. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2239. // utils.ErrorLog("解析失败:%v", err)
  2240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2241. // return
  2242. //}
  2243. if miConfig.MdtrtareaAdmvs == "350500" {
  2244. result, result1, _ := service.FJyb3507(struct3507)
  2245. saveLog(result, result1, "3507", "3507")
  2246. var respJSON2 map[string]interface{}
  2247. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2250. return
  2251. }
  2252. userJSONBytes2, _ := json.Marshal(respJSON2)
  2253. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2254. utils.ErrorLog("解析失败:%v", err)
  2255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2256. return
  2257. }
  2258. } else {
  2259. data := make(map[string]interface{})
  2260. data["struct_3507s"] = struct3507
  2261. client := &http.Client{}
  2262. bytesData, _ := json.Marshal(data)
  2263. var req *http.Request
  2264. if miConfig.MdtrtareaAdmvs == "320830" {
  2265. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2266. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2267. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2268. } else {
  2269. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2270. }
  2271. resp, _ := client.Do(req)
  2272. defer resp.Body.Close()
  2273. body, ioErr := ioutil.ReadAll(resp.Body)
  2274. if ioErr != nil {
  2275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2276. }
  2277. var respJSON map[string]interface{}
  2278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2281. return
  2282. }
  2283. var resSix10265 ResultSix10265 //1101结果
  2284. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2285. result, _ := json.Marshal(respJSON)
  2286. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2287. utils.ErrorLog("解析失败:%v", err)
  2288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2289. return
  2290. }
  2291. res.InfRefmsgid = resSix10265.InfRefmsgid
  2292. //res.Output = resSix10265.Output
  2293. res.ErrMsg = resSix10265.ErrMsg
  2294. res.Cainfo = resSix10265.Cainfo
  2295. res.WarnMsg = resSix10265.WarnMsg
  2296. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2297. res.Infcode = infocode
  2298. }
  2299. if res.Infcode == 0 {
  2300. item.IsSale = 0
  2301. item.SaleDate = ""
  2302. item.Bchno = ""
  2303. service.SaveDF(item)
  2304. } else {
  2305. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2306. }
  2307. }
  2308. if item.IsSale == 0 && item.IsChange == 1 {
  2309. var res FJ3507Result
  2310. var struct3507 models.Struct3507
  2311. struct3507.FixmedinsBchno = item.BgBchno
  2312. struct3507.InvDataType = "2"
  2313. struct3507.Opter = roles.UserName
  2314. struct3507.FixmedinsCode = miConfig.Code
  2315. struct3507.Code = miConfig.Code
  2316. struct3507.OrgName = miConfig.OrgName
  2317. struct3507.AccessKey = miConfig.AccessKey
  2318. struct3507.RequestUrl = miConfig.Url
  2319. struct3507.SecretKey = miConfig.SecretKey
  2320. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2321. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2322. struct3507.Url = miConfig.Url
  2323. struct3507.AppId = miConfig.Cainfo
  2324. struct3507.AppSecret = miConfig.AppSecret
  2325. struct3507.Enckey = miConfig.EncKey
  2326. struct3507.SignKey = miConfig.SignKey
  2327. struct3507.SecretKey = miConfig.SecretKey
  2328. //result, result1, _ := service.FJyb3507(struct3507)
  2329. //saveLog(result, result1, "3507", "3507")
  2330. //
  2331. //var respJSON3 map[string]interface{}
  2332. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2333. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2335. // return
  2336. //}
  2337. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2338. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2339. // utils.ErrorLog("解析失败:%v", err)
  2340. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2341. // return
  2342. //}
  2343. if miConfig.MdtrtareaAdmvs == "350500" {
  2344. result, result1, _ := service.FJyb3507(struct3507)
  2345. saveLog(result, result1, "3507", "3507")
  2346. var respJSON2 map[string]interface{}
  2347. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2350. return
  2351. }
  2352. userJSONBytes2, _ := json.Marshal(respJSON2)
  2353. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2354. utils.ErrorLog("解析失败:%v", err)
  2355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2356. return
  2357. }
  2358. } else {
  2359. data := make(map[string]interface{})
  2360. data["struct_3507s"] = struct3507
  2361. client := &http.Client{}
  2362. bytesData, _ := json.Marshal(data)
  2363. var req *http.Request
  2364. if miConfig.MdtrtareaAdmvs == "320830" {
  2365. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2366. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2367. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2368. } else {
  2369. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2370. }
  2371. resp, _ := client.Do(req)
  2372. defer resp.Body.Close()
  2373. body, ioErr := ioutil.ReadAll(resp.Body)
  2374. if ioErr != nil {
  2375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2376. }
  2377. var respJSON map[string]interface{}
  2378. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2381. return
  2382. }
  2383. var resSix10265 ResultSix10265 //1101结果
  2384. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2385. result, _ := json.Marshal(respJSON)
  2386. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2387. utils.ErrorLog("解析失败:%v", err)
  2388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2389. return
  2390. }
  2391. res.InfRefmsgid = resSix10265.InfRefmsgid
  2392. //res.Output = resSix10265.Output
  2393. res.ErrMsg = resSix10265.ErrMsg
  2394. res.Cainfo = resSix10265.Cainfo
  2395. res.WarnMsg = resSix10265.WarnMsg
  2396. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2397. res.Infcode = infocode
  2398. }
  2399. if res.Infcode == 0 {
  2400. item.IsChange = 0
  2401. item.BgBchno = ""
  2402. service.SaveDF2(item)
  2403. } else {
  2404. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2405. }
  2406. }
  2407. }
  2408. if len(err) == 0 {
  2409. c.ServeSuccessJSON(map[string]interface{}{
  2410. "msg": "删除销售变更成功",
  2411. })
  2412. } else {
  2413. c.ServeSuccessJSON(map[string]interface{}{
  2414. "failed_code": -10,
  2415. "msg": err,
  2416. })
  2417. }
  2418. }
  2419. //func (c *HisApiController) BatchFJ3501AND3502() {
  2420. // //ids := c.GetString("ids")
  2421. // start_time := c.GetString("start_time")
  2422. // end_time := c.GetString("end_time")
  2423. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2424. //
  2425. //
  2426. // timeLayout := "2006-01-02"
  2427. // loc, _ := time.LoadLocation("Local")
  2428. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2429. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2430. //
  2431. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2432. // //id_arr := strings.Split(ids, ",")
  2433. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2434. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2435. // //库盘
  2436. // var errs []string
  2437. // for _, drug := range drugs {
  2438. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2439. // var res2 ResultSix
  2440. // var res3 ResultSix
  2441. //
  2442. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2443. // var struct3501 models.Struct3501
  2444. // struct3501.Code = miConfig.Code
  2445. // struct3501.OrgName = miConfig.OrgName
  2446. // struct3501.AccessKey = miConfig.AccessKey
  2447. // struct3501.Opter = roles.UserName
  2448. // struct3501.RequestUrl = miConfig.Url
  2449. // struct3501.Url = miConfig.Url
  2450. // struct3501.AppId = miConfig.Cainfo
  2451. // struct3501.AppSecret = miConfig.AppSecret
  2452. // struct3501.Enckey = miConfig.EncKey
  2453. // struct3501.SignKey = miConfig.SignKey
  2454. // struct3501.SecretKey = miConfig.SecretKey
  2455. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2456. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2457. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2458. // struct3501.RxFlag = "1"
  2459. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2460. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2461. //
  2462. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2463. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2464. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2465. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2466. // struct3501.FixmedinsBchno = number
  2467. // struct3501.DrugTracCodg = drug.DrugCode
  2468. // memo := make(map[string]interface{})
  2469. // memo["pric"] = drug.Price
  2470. // bytesData, _ := json.Marshal(memo)
  2471. // struct3501.Memo = string(bytesData)
  2472. //
  2473. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2474. //
  2475. // result1, result2, _ := service.FJyb3501(struct3501)
  2476. // saveLog(result1, result2, "3501", "3501")
  2477. // //saveLog(result, requestLog, "2201", "挂号")
  2478. //
  2479. // var respJSON2 map[string]interface{}
  2480. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2481. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2483. // return
  2484. // }
  2485. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2486. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2487. // utils.ErrorLog("解析失败:%v", err)
  2488. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2489. // return
  2490. // }
  2491. //
  2492. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2493. // data := make(map[string]interface{})
  2494. // data["struct_3501s"] = struct3501
  2495. // client := &http.Client{}
  2496. // bytesData, _ := json.Marshal(data)
  2497. // var req *http.Request
  2498. // if miConfig.MdtrtareaAdmvs == "320921" {
  2499. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2500. // } else {
  2501. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2502. // }
  2503. //
  2504. // resp, _ := client.Do(req)
  2505. // defer resp.Body.Close()
  2506. // body, ioErr := ioutil.ReadAll(resp.Body)
  2507. // if ioErr != nil {
  2508. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2509. // }
  2510. // var respJSON map[string]interface{}
  2511. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2512. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2514. // return
  2515. // }
  2516. // var resSix10265 ResultSix10265 //1101结果
  2517. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2518. // result, _ := json.Marshal(respJSON)
  2519. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2520. // utils.ErrorLog("解析失败:%v", err)
  2521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2522. // return
  2523. // }
  2524. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2525. // res2.Output = resSix10265.Output
  2526. // res2.ErrMsg = resSix10265.ErrMsg
  2527. // res2.Cainfo = resSix10265.Cainfo
  2528. // res2.WarnMsg = resSix10265.WarnMsg
  2529. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2530. // res2.Infcode = infocode
  2531. //
  2532. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2533. // data := make(map[string]interface{})
  2534. // data["struct_3501s"] = struct3501
  2535. // client := &http.Client{}
  2536. // bytesData, _ := json.Marshal(data)
  2537. // var req *http.Request
  2538. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2539. // resp, _ := client.Do(req)
  2540. // defer resp.Body.Close()
  2541. // body, ioErr := ioutil.ReadAll(resp.Body)
  2542. // if ioErr != nil {
  2543. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2544. // }
  2545. // var respJSON map[string]interface{}
  2546. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2547. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2549. // return
  2550. // }
  2551. // var resSix10265 ResultSix10265 //1101结果
  2552. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2553. // result, _ := json.Marshal(respJSON)
  2554. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2555. // utils.ErrorLog("解析失败:%v", err)
  2556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2557. // return
  2558. // }
  2559. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2560. // res2.Output = resSix10265.Output
  2561. // res2.ErrMsg = resSix10265.ErrMsg
  2562. // res2.Cainfo = resSix10265.Cainfo
  2563. // res2.WarnMsg = resSix10265.WarnMsg
  2564. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2565. // res2.Infcode = infocode
  2566. //
  2567. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2568. // data := make(map[string]interface{})
  2569. // data["struct_3501s"] = struct3501
  2570. // client := &http.Client{}
  2571. // bytesData, _ := json.Marshal(data)
  2572. // var req *http.Request
  2573. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2574. // resp, _ := client.Do(req)
  2575. // defer resp.Body.Close()
  2576. // body, ioErr := ioutil.ReadAll(resp.Body)
  2577. // if ioErr != nil {
  2578. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2579. // }
  2580. // var respJSON map[string]interface{}
  2581. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2582. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2584. // return
  2585. // }
  2586. // var resSix10265 ResultSix10265 //1101结果
  2587. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2588. // result, _ := json.Marshal(respJSON)
  2589. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2590. // utils.ErrorLog("解析失败:%v", err)
  2591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2592. // return
  2593. // }
  2594. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2595. // res2.Output = resSix10265.Output
  2596. // res2.ErrMsg = resSix10265.ErrMsg
  2597. // res2.Cainfo = resSix10265.Cainfo
  2598. // res2.WarnMsg = resSix10265.WarnMsg
  2599. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2600. // res2.Infcode = infocode
  2601. //
  2602. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2603. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2604. // saveLog(result1, result2, "3501", "3501")
  2605. // //saveLog(result, requestLog, "2201", "挂号")
  2606. //
  2607. // var respJSON2 map[string]interface{}
  2608. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2609. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2611. // return
  2612. // }
  2613. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2614. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2615. // utils.ErrorLog("解析失败:%v", err)
  2616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2617. // return
  2618. // }
  2619. //
  2620. // }
  2621. //
  2622. // if res2.Infcode != -1 {
  2623. // drug.IsPc = 1
  2624. // drug.Bchno = number
  2625. // drug.PcDate = time.Now().Unix()
  2626. // err := service.SaveW(drug)
  2627. // if err == nil {
  2628. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2629. // var struct3502 models.Struct3502
  2630. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2631. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2632. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2633. // struct3502.FixmedinsCode = miConfig.Code
  2634. // struct3502.Code = miConfig.Code
  2635. //
  2636. // struct3502.RxFlag = "0"
  2637. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2638. // struct3502.OrgName = miConfig.OrgName
  2639. // struct3502.Opter = roles.UserName
  2640. // struct3502.AccessKey = miConfig.AccessKey
  2641. // struct3502.RequestUrl = miConfig.Url
  2642. // struct3502.SecretKey = miConfig.SecretKey
  2643. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2644. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2645. // struct3502.Url = miConfig.Url
  2646. // struct3502.AppId = miConfig.Cainfo
  2647. // struct3502.AppSecret = miConfig.AppSecret
  2648. // struct3502.Enckey = miConfig.EncKey
  2649. // struct3502.SignKey = miConfig.SignKey
  2650. // struct3502.SecretKey = miConfig.SecretKey
  2651. // struct3502.DrugTracCodg = drug.DrugCode
  2652. //
  2653. // struct3502.Memo = ""
  2654. // struct3502.InvChgType = "108"
  2655. // struct3502.FixmedinsBchno = bg_number
  2656. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2657. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2658. //
  2659. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2660. // result11, result22, _ := service.FJyb3502(struct3502)
  2661. // saveLog(result11, result22, "3502", "3502")
  2662. //
  2663. // var respJSON3 map[string]interface{}
  2664. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2665. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2666. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2667. // return
  2668. // }
  2669. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2670. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2671. // utils.ErrorLog("解析失败:%v", err)
  2672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2673. // return
  2674. // }
  2675. //
  2676. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2677. // data := make(map[string]interface{})
  2678. // data["struct_3502s"] = struct3502
  2679. // client := &http.Client{}
  2680. // bytesData, _ := json.Marshal(data)
  2681. // var req *http.Request
  2682. // if miConfig.MdtrtareaAdmvs == "320921" {
  2683. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2684. // } else {
  2685. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2686. // }
  2687. //
  2688. // resp, _ := client.Do(req)
  2689. // defer resp.Body.Close()
  2690. // body, ioErr := ioutil.ReadAll(resp.Body)
  2691. // if ioErr != nil {
  2692. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2693. // }
  2694. // var respJSON map[string]interface{}
  2695. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2696. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2698. // return
  2699. // }
  2700. // var resSix10265 ResultSix10265 //1101结果
  2701. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2702. // result, _ := json.Marshal(respJSON)
  2703. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2704. // utils.ErrorLog("解析失败:%v", err)
  2705. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2706. // return
  2707. // }
  2708. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2709. // res3.Output = resSix10265.Output
  2710. // res3.ErrMsg = resSix10265.ErrMsg
  2711. // res3.Cainfo = resSix10265.Cainfo
  2712. // res3.WarnMsg = resSix10265.WarnMsg
  2713. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2714. // res3.Infcode = infocode
  2715. //
  2716. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2717. //
  2718. // data := make(map[string]interface{})
  2719. // data["struct_3502s"] = struct3502
  2720. // client := &http.Client{}
  2721. // bytesData, _ := json.Marshal(data)
  2722. // var req *http.Request
  2723. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2724. // resp, _ := client.Do(req)
  2725. // defer resp.Body.Close()
  2726. // body, ioErr := ioutil.ReadAll(resp.Body)
  2727. // if ioErr != nil {
  2728. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2729. // }
  2730. // var respJSON map[string]interface{}
  2731. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2732. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2733. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2734. // return
  2735. // }
  2736. // var resSix10265 ResultSix10265 //1101结果
  2737. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2738. // result, _ := json.Marshal(respJSON)
  2739. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2740. // utils.ErrorLog("解析失败:%v", err)
  2741. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2742. // return
  2743. // }
  2744. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2745. // res3.Output = resSix10265.Output
  2746. // res3.ErrMsg = resSix10265.ErrMsg
  2747. // res3.Cainfo = resSix10265.Cainfo
  2748. // res3.WarnMsg = resSix10265.WarnMsg
  2749. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2750. // res3.Infcode = infocode
  2751. //
  2752. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2753. //
  2754. // data := make(map[string]interface{})
  2755. // data["struct_3501s"] = struct3501
  2756. // client := &http.Client{}
  2757. // bytesData, _ := json.Marshal(data)
  2758. // var req *http.Request
  2759. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2760. // resp, _ := client.Do(req)
  2761. // defer resp.Body.Close()
  2762. // body, ioErr := ioutil.ReadAll(resp.Body)
  2763. // if ioErr != nil {
  2764. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2765. // }
  2766. // var respJSON map[string]interface{}
  2767. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2768. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2769. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2770. // return
  2771. // }
  2772. // var resSix10265 ResultSix10265 //1101结果
  2773. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2774. // result, _ := json.Marshal(respJSON)
  2775. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2776. // utils.ErrorLog("解析失败:%v", err)
  2777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2778. // return
  2779. // }
  2780. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2781. // res2.Output = resSix10265.Output
  2782. // res2.ErrMsg = resSix10265.ErrMsg
  2783. // res2.Cainfo = resSix10265.Cainfo
  2784. // res2.WarnMsg = resSix10265.WarnMsg
  2785. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2786. // res2.Infcode = infocode
  2787. //
  2788. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2789. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2790. // saveLog(result11, result22, "3502", "3502")
  2791. //
  2792. // var respJSON3 map[string]interface{}
  2793. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2794. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2796. // return
  2797. // }
  2798. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2799. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2800. // utils.ErrorLog("解析失败:%v", err)
  2801. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2802. // return
  2803. // }
  2804. // }
  2805. // if res3.Infcode == -1 {
  2806. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2807. // c.ServeSuccessJSON(map[string]interface{}{
  2808. // "failed_code": -10,
  2809. // "msg": res3.ErrMsg,
  2810. // })
  2811. // } else {
  2812. // drug.IsBg = 1
  2813. // drug.BgBchno = bg_number
  2814. // service.SaveW(drug)
  2815. // }
  2816. // }
  2817. // } else {
  2818. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2819. // }
  2820. // }
  2821. // //变更
  2822. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2823. // var res3 ResultSix
  2824. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2825. //
  2826. // var struct3502 models.Struct3502
  2827. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2828. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2829. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2830. // struct3502.FixmedinsCode = miConfig.Code
  2831. // struct3502.Code = miConfig.Code
  2832. //
  2833. // struct3502.Opter = roles.UserName
  2834. // struct3502.RxFlag = "0"
  2835. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2836. // struct3502.OrgName = miConfig.OrgName
  2837. // struct3502.AccessKey = miConfig.AccessKey
  2838. // struct3502.RequestUrl = miConfig.Url
  2839. // struct3502.SecretKey = miConfig.SecretKey
  2840. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2841. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2842. // struct3502.InvChgType = "108"
  2843. // struct3502.DrugTracCodg = drug.DrugCode
  2844. //
  2845. // struct3502.Url = miConfig.Url
  2846. // struct3502.AppId = miConfig.Cainfo
  2847. // struct3502.AppSecret = miConfig.AppSecret
  2848. // struct3502.Enckey = miConfig.EncKey
  2849. // struct3502.SignKey = miConfig.SignKey
  2850. // struct3502.SecretKey = miConfig.SecretKey
  2851. //
  2852. // struct3502.FixmedinsBchno = bg_number
  2853. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2854. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2855. //
  2856. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2857. // result1, result2, _ := service.FJyb3502(struct3502)
  2858. // saveLog(result1, result2, "3502", "3502")
  2859. // var respJSON3 map[string]interface{}
  2860. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2861. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2862. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2863. // return
  2864. // }
  2865. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2866. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2867. // utils.ErrorLog("解析失败:%v", err)
  2868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2869. // return
  2870. // }
  2871. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2872. // data := make(map[string]interface{})
  2873. // data["struct_3502s"] = struct3502
  2874. // client := &http.Client{}
  2875. // bytesData, _ := json.Marshal(data)
  2876. // var req *http.Request
  2877. // if miConfig.MdtrtareaAdmvs == "320921" {
  2878. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2879. // } else {
  2880. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2881. // }
  2882. // resp, _ := client.Do(req)
  2883. // defer resp.Body.Close()
  2884. // body, ioErr := ioutil.ReadAll(resp.Body)
  2885. // if ioErr != nil {
  2886. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2887. // }
  2888. // var respJSON map[string]interface{}
  2889. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2890. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2891. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2892. // return
  2893. // }
  2894. // var resSix10265 ResultSix10265 //1101结果
  2895. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2896. // result, _ := json.Marshal(respJSON)
  2897. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2898. // utils.ErrorLog("解析失败:%v", err)
  2899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2900. // return
  2901. // }
  2902. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2903. // res3.Output = resSix10265.Output
  2904. // res3.ErrMsg = resSix10265.ErrMsg
  2905. // res3.Cainfo = resSix10265.Cainfo
  2906. // res3.WarnMsg = resSix10265.WarnMsg
  2907. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2908. // res3.Infcode = infocode
  2909. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2910. //
  2911. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2912. //
  2913. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2914. //
  2915. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2916. //
  2917. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2918. // saveLog(result1, result2, "3501", "3501")
  2919. // //saveLog(result, requestLog, "2201", "挂号")
  2920. //
  2921. // var respJSON2 map[string]interface{}
  2922. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2923. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2924. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2925. // return
  2926. // }
  2927. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2928. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2929. // utils.ErrorLog("解析失败:%v", err)
  2930. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2931. // return
  2932. // }
  2933. //
  2934. // }
  2935. // if res3.Infcode == -1 {
  2936. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2937. // } else {
  2938. // drug.IsBg = 1
  2939. // drug.BgBchno = bg_number
  2940. // service.SaveW(drug)
  2941. // }
  2942. // }
  2943. // }
  2944. //
  2945. // if len(errs) == 0 {
  2946. // c.ServeSuccessJSON(map[string]interface{}{
  2947. // "msg": "盘存变更成功",
  2948. // })
  2949. // } else {
  2950. // c.ServeSuccessJSON(map[string]interface{}{
  2951. // "failed_code": -10,
  2952. // "msg": errs,
  2953. // })
  2954. // }
  2955. //}
  2956. func (c *HisApiController) DeleteXSandBGTwo() {
  2957. patient_id, _ := c.GetInt64("patient_id")
  2958. admin_user_id, _ := c.GetInt64("admin_user_id")
  2959. times := c.GetString("time", "")
  2960. timeLayout := "2006-01-02"
  2961. loc, _ := time.LoadLocation("Local")
  2962. var stime, etime int64
  2963. if times == "" {
  2964. stime, etime = GetNowTime()
  2965. } else {
  2966. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2967. stime = stmp.Unix()
  2968. etime = stime + 86399
  2969. }
  2970. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2971. var flows []*models.DrugFlow
  2972. for _, item := range advicelist {
  2973. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2974. flows = append(flows, flow...)
  2975. }
  2976. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2977. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2978. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2979. var err []string
  2980. for _, item := range flows {
  2981. if item.IsSale == 1 {
  2982. var res FJ3507Result
  2983. var struct3507 models.Struct3507
  2984. struct3507.FixmedinsBchno = item.Bchno
  2985. struct3507.InvDataType = "4"
  2986. struct3507.Opter = roles.UserName
  2987. struct3507.OrgName = miConfig.OrgName
  2988. struct3507.AccessKey = miConfig.AccessKey
  2989. struct3507.RequestUrl = miConfig.Url
  2990. struct3507.FixmedinsCode = miConfig.Code
  2991. struct3507.SecretKey = miConfig.SecretKey
  2992. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2993. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2994. struct3507.Url = miConfig.Url
  2995. struct3507.AppId = miConfig.Cainfo
  2996. struct3507.AppSecret = miConfig.AppSecret
  2997. struct3507.Enckey = miConfig.EncKey
  2998. struct3507.SignKey = miConfig.SignKey
  2999. struct3507.SecretKey = miConfig.SecretKey
  3000. if miConfig.MdtrtareaAdmvs == "350500" {
  3001. result, result1, _ := service.FJyb3507(struct3507)
  3002. saveLog(result, result1, "3507", "3507")
  3003. var respJSON2 map[string]interface{}
  3004. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3007. return
  3008. }
  3009. userJSONBytes2, _ := json.Marshal(respJSON2)
  3010. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3011. utils.ErrorLog("解析失败:%v", err)
  3012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3013. return
  3014. }
  3015. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  3016. data := make(map[string]interface{})
  3017. data["struct_3507s"] = struct3507
  3018. client := &http.Client{}
  3019. bytesData, _ := json.Marshal(data)
  3020. var req *http.Request
  3021. if miConfig.MdtrtareaAdmvs == "320830" {
  3022. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  3023. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3024. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3025. } else {
  3026. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3027. }
  3028. resp, _ := client.Do(req)
  3029. defer resp.Body.Close()
  3030. body, ioErr := ioutil.ReadAll(resp.Body)
  3031. if ioErr != nil {
  3032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3033. }
  3034. var respJSON map[string]interface{}
  3035. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3038. return
  3039. }
  3040. var resSix10265 ResultSix10265 //1101结果
  3041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3042. result, _ := json.Marshal(respJSON)
  3043. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3044. utils.ErrorLog("解析失败:%v", err)
  3045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3046. return
  3047. }
  3048. res.InfRefmsgid = resSix10265.InfRefmsgid
  3049. //res.Output = resSix10265.Output
  3050. res.ErrMsg = resSix10265.ErrMsg
  3051. res.Cainfo = resSix10265.Cainfo
  3052. res.WarnMsg = resSix10265.WarnMsg
  3053. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3054. res.Infcode = infocode
  3055. } else if miConfig.MdtrtareaAdmvs == "440100" {
  3056. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3057. saveLog(result2, result1, "3507", "3507")
  3058. var respJSON2 map[string]interface{}
  3059. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3060. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3062. return
  3063. }
  3064. userJSONBytes2, _ := json.Marshal(respJSON2)
  3065. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3066. utils.ErrorLog("解析失败:%v", err)
  3067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3068. return
  3069. }
  3070. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3071. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3072. saveLog(result2, result1, "3507", "3507")
  3073. var respJSON2 map[string]interface{}
  3074. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3077. return
  3078. }
  3079. userJSONBytes2, _ := json.Marshal(respJSON2)
  3080. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3081. utils.ErrorLog("解析失败:%v", err)
  3082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3083. return
  3084. }
  3085. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3086. result1, result2 := service.Jxyb3507(struct3507)
  3087. saveLog(result2, result1, "3507", "3507")
  3088. var respJSON2 map[string]interface{}
  3089. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3092. return
  3093. }
  3094. userJSONBytes2, _ := json.Marshal(respJSON2)
  3095. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3096. utils.ErrorLog("解析失败:%v", err)
  3097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3098. return
  3099. }
  3100. } else if miConfig.MdtrtareaAdmvs == "340699" {
  3101. result1, result2 := service.AHyb3507(struct3507)
  3102. saveLog(result2, result1, "3507", "3507")
  3103. var respJSON2 map[string]interface{}
  3104. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3107. return
  3108. }
  3109. userJSONBytes2, _ := json.Marshal(respJSON2)
  3110. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3111. utils.ErrorLog("解析失败:%v", err)
  3112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3113. return
  3114. }
  3115. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3116. data := make(map[string]interface{})
  3117. data["struct_3507s"] = struct3507
  3118. client := &http.Client{}
  3119. bytesData, _ := json.Marshal(data)
  3120. var req *http.Request
  3121. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3122. resp, _ := client.Do(req)
  3123. defer resp.Body.Close()
  3124. body, ioErr := ioutil.ReadAll(resp.Body)
  3125. if ioErr != nil {
  3126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3127. }
  3128. var respJSON map[string]interface{}
  3129. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3131. }
  3132. var resSix10265 ResultSix10265 //1101结果
  3133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3134. result, _ := json.Marshal(respJSON)
  3135. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3136. utils.ErrorLog("解析失败:%v", err)
  3137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3138. return
  3139. }
  3140. res.InfRefmsgid = resSix10265.InfRefmsgid
  3141. res.ErrMsg = resSix10265.ErrMsg
  3142. res.Cainfo = resSix10265.Cainfo
  3143. res.WarnMsg = resSix10265.WarnMsg
  3144. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3145. res.Infcode = infocode
  3146. }
  3147. if res.Infcode == 0 {
  3148. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3149. item.IsSale = 0
  3150. item.SaleDate = ""
  3151. item.Bchno = ""
  3152. service.SaveDF(item)
  3153. } else {
  3154. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3155. }
  3156. }
  3157. }
  3158. c.ServeSuccessJSON(map[string]interface{}{
  3159. "msg": "删除销售数据成功",
  3160. })
  3161. }
  3162. // 删除
  3163. func (c *HisApiController) DeleteXSandBGThree() {
  3164. id, _ := c.GetInt64("id")
  3165. admin_user_id, _ := c.GetInt64("admin_user_id")
  3166. advicelist, _ := service.FinddelHisAdviceDocAdvice(id)
  3167. var flows []*models.DrugFlow
  3168. for _, item := range advicelist {
  3169. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3170. flows = append(flows, flow...)
  3171. }
  3172. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3173. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3174. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3175. var err []string
  3176. for _, item := range flows {
  3177. if item.IsSale == 1 {
  3178. var res FJ3507Result
  3179. var struct3507 models.Struct3507
  3180. struct3507.FixmedinsBchno = item.Bchno
  3181. struct3507.InvDataType = "4"
  3182. struct3507.Opter = roles.UserName
  3183. struct3507.OrgName = miConfig.OrgName
  3184. struct3507.AccessKey = miConfig.AccessKey
  3185. struct3507.RequestUrl = miConfig.Url
  3186. struct3507.FixmedinsCode = miConfig.Code
  3187. struct3507.SecretKey = miConfig.SecretKey
  3188. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3189. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3190. struct3507.Url = miConfig.Url
  3191. struct3507.AppId = miConfig.Cainfo
  3192. struct3507.AppSecret = miConfig.AppSecret
  3193. struct3507.Enckey = miConfig.EncKey
  3194. struct3507.SignKey = miConfig.SignKey
  3195. struct3507.SecretKey = miConfig.SecretKey
  3196. if miConfig.MdtrtareaAdmvs == "350500" {
  3197. result, result1, _ := service.FJyb3507(struct3507)
  3198. saveLog(result, result1, "3507", "3507")
  3199. var respJSON2 map[string]interface{}
  3200. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3203. return
  3204. }
  3205. userJSONBytes2, _ := json.Marshal(respJSON2)
  3206. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3207. utils.ErrorLog("解析失败:%v", err)
  3208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3209. return
  3210. }
  3211. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  3212. data := make(map[string]interface{})
  3213. data["struct_3507s"] = struct3507
  3214. client := &http.Client{}
  3215. bytesData, _ := json.Marshal(data)
  3216. var req *http.Request
  3217. if miConfig.MdtrtareaAdmvs == "320830" {
  3218. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  3219. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3220. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3221. } else {
  3222. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3223. }
  3224. resp, _ := client.Do(req)
  3225. defer resp.Body.Close()
  3226. body, ioErr := ioutil.ReadAll(resp.Body)
  3227. if ioErr != nil {
  3228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3229. }
  3230. var respJSON map[string]interface{}
  3231. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3234. return
  3235. }
  3236. var resSix10265 ResultSix10265 //1101结果
  3237. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3238. result, _ := json.Marshal(respJSON)
  3239. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3240. utils.ErrorLog("解析失败:%v", err)
  3241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3242. return
  3243. }
  3244. res.InfRefmsgid = resSix10265.InfRefmsgid
  3245. //res.Output = resSix10265.Output
  3246. res.ErrMsg = resSix10265.ErrMsg
  3247. res.Cainfo = resSix10265.Cainfo
  3248. res.WarnMsg = resSix10265.WarnMsg
  3249. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3250. res.Infcode = infocode
  3251. } else if miConfig.MdtrtareaAdmvs == "440100" {
  3252. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3253. saveLog(result2, result1, "3507", "3507")
  3254. var respJSON2 map[string]interface{}
  3255. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3258. return
  3259. }
  3260. userJSONBytes2, _ := json.Marshal(respJSON2)
  3261. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3262. utils.ErrorLog("解析失败:%v", err)
  3263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3264. return
  3265. }
  3266. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3267. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3268. saveLog(result2, result1, "3507", "3507")
  3269. var respJSON2 map[string]interface{}
  3270. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3273. return
  3274. }
  3275. userJSONBytes2, _ := json.Marshal(respJSON2)
  3276. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3277. utils.ErrorLog("解析失败:%v", err)
  3278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3279. return
  3280. }
  3281. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3282. result1, result2 := service.Jxyb3507(struct3507)
  3283. saveLog(result2, result1, "3507", "3507")
  3284. var respJSON2 map[string]interface{}
  3285. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3288. return
  3289. }
  3290. userJSONBytes2, _ := json.Marshal(respJSON2)
  3291. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3292. utils.ErrorLog("解析失败:%v", err)
  3293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3294. return
  3295. }
  3296. } else if miConfig.MdtrtareaAdmvs == "340699" {
  3297. result1, result2 := service.AHyb3507(struct3507)
  3298. saveLog(result2, result1, "3507", "3507")
  3299. var respJSON2 map[string]interface{}
  3300. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3303. return
  3304. }
  3305. userJSONBytes2, _ := json.Marshal(respJSON2)
  3306. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3307. utils.ErrorLog("解析失败:%v", err)
  3308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3309. return
  3310. }
  3311. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3312. data := make(map[string]interface{})
  3313. data["struct_3507s"] = struct3507
  3314. client := &http.Client{}
  3315. bytesData, _ := json.Marshal(data)
  3316. var req *http.Request
  3317. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3318. resp, _ := client.Do(req)
  3319. defer resp.Body.Close()
  3320. body, ioErr := ioutil.ReadAll(resp.Body)
  3321. if ioErr != nil {
  3322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3323. }
  3324. var respJSON map[string]interface{}
  3325. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3327. }
  3328. var resSix10265 ResultSix10265 //1101结果
  3329. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3330. result, _ := json.Marshal(respJSON)
  3331. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3332. utils.ErrorLog("解析失败:%v", err)
  3333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3334. return
  3335. }
  3336. res.InfRefmsgid = resSix10265.InfRefmsgid
  3337. res.ErrMsg = resSix10265.ErrMsg
  3338. res.Cainfo = resSix10265.Cainfo
  3339. res.WarnMsg = resSix10265.WarnMsg
  3340. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3341. res.Infcode = infocode
  3342. }
  3343. if res.Infcode == 0 {
  3344. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3345. item.IsSale = 0
  3346. item.SaleDate = ""
  3347. item.Bchno = ""
  3348. service.SaveDF(item)
  3349. } else {
  3350. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3351. }
  3352. }
  3353. }
  3354. c.ServeSuccessJSON(map[string]interface{}{
  3355. "msg": "删除销售数据成功",
  3356. })
  3357. }
  3358. // 获取当天起止时间戳
  3359. func GetNowTime() (int64, int64) {
  3360. t := time.Now()
  3361. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3362. timesamp := addTime.Unix()
  3363. return timesamp, timesamp + 86399
  3364. }
  3365. func (c *HisApiController) ChangeDrugfour() {
  3366. patient_id, _ := c.GetInt64("patient_id")
  3367. admin_user_id, _ := c.GetInt64("admin_user_id")
  3368. times := c.GetString("time", "")
  3369. timeLayout := "2006-01-02"
  3370. loc, _ := time.LoadLocation("Local")
  3371. var stime, etime int64
  3372. if times == "" {
  3373. stime, etime = GetNowTime()
  3374. } else {
  3375. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3376. stime = stmp.Unix()
  3377. etime = stime + 86399
  3378. }
  3379. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3380. var flows []*models.DrugFlow
  3381. for _, item := range advicelist {
  3382. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  3383. flows = append(flows, flow...)
  3384. }
  3385. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3386. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3387. var err []string
  3388. for _, item := range flows {
  3389. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3390. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3391. if prescription.OrderStatus == 2 {
  3392. if item.IsSale == 0 {
  3393. var res FJ3507Result
  3394. var res3507for10188 FJ3507ResultFor10188
  3395. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3396. //进行商品销售接口
  3397. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3398. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3399. var respJSON3 map[string]interface{}
  3400. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3403. return
  3404. }
  3405. userJSONBytes3, _ := json.Marshal(respJSON3)
  3406. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3407. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3408. utils.ErrorLog("解析失败:%v", err)
  3409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3410. return
  3411. }
  3412. //if res3507for10188.Infcode
  3413. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3414. //res.Output = resSix10265.Output
  3415. res.ErrMsg = res3507for10188.ErrMsg
  3416. res.Cainfo = res3507for10188.Cainfo
  3417. res.WarnMsg = res3507for10188.WarnMsg
  3418. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3419. res.Infcode = infocode
  3420. } else {
  3421. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3422. utils.ErrorLog("解析失败:%v", err)
  3423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3424. return
  3425. }
  3426. }
  3427. if res.Infcode == 0 {
  3428. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3429. item.IsSale = 1
  3430. item.Bchno = number
  3431. item.SaleDate = time.Now().Format("2006-01-02")
  3432. service.SaveDF(item)
  3433. } else {
  3434. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3435. }
  3436. }
  3437. } else { //还没结,提示用户去结算,并药品追溯上传
  3438. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3439. }
  3440. }
  3441. }
  3442. str := strings.Join(err, " ")
  3443. saveLog(str, str, "3505", "3505自动上传日志")
  3444. c.ServeSuccessJSON(map[string]interface{}{
  3445. "status": "1",
  3446. "msg": err,
  3447. })
  3448. }
  3449. func (c *HisApiController) ChangeDrugFive() {
  3450. id := c.GetString("id")
  3451. ids := strings.Split(id, ",")
  3452. admin_user_id, _ := c.GetInt64("admin_user_id")
  3453. var errs []string
  3454. //校验gui'ge
  3455. for _, value := range ids {
  3456. intValue, _ := strconv.ParseInt(value, 10, 64)
  3457. //file := strconv.FormatInt(int64(num), 10)
  3458. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3459. var flows []*models.DrugFlow
  3460. for _, item := range advicelist {
  3461. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3462. flows = append(flows, flow...)
  3463. }
  3464. //roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3465. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3466. for _, item := range flows {
  3467. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3468. if prescription.OrderStatus != 2 {
  3469. // 将时间戳转换为time.Time类型
  3470. t := time.Unix(item.HisDoctorAdviceInfo.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3471. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.HisDoctorAdviceInfo.PatientId)
  3472. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"医嘱没结算无法上传")
  3473. }
  3474. if len(item.HisDoctorAdviceInfo.DrugCode) > 0 {
  3475. t := time.Unix(item.HisDoctorAdviceInfo.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3476. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.HisDoctorAdviceInfo.PatientId)
  3477. codes := strings.Split(item.HisDoctorAdviceInfo.DrugCode, ",")
  3478. for _, code := range codes {
  3479. if len(code) > 0 {
  3480. if len(code) != 20 {
  3481. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  3482. }
  3483. if IsDigit(code) == false {
  3484. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  3485. }
  3486. }
  3487. }
  3488. }
  3489. }
  3490. }
  3491. utils.ErrorLog("接口返回数据解析JSON失败: %v", errs)
  3492. if len(errs) > 0 {
  3493. c.ServeSuccessJSON(map[string]interface{}{
  3494. "failed_code": -10,
  3495. "msg": errs,
  3496. })
  3497. return
  3498. }
  3499. for _, value := range ids {
  3500. intValue, _ := strconv.ParseInt(value, 10, 64)
  3501. //file := strconv.FormatInt(int64(num), 10)
  3502. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3503. var flows []*models.DrugFlow
  3504. for _, item := range advicelist {
  3505. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3506. flows = append(flows, flow...)
  3507. }
  3508. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3509. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3510. for _, item := range flows {
  3511. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3512. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3513. if prescription.OrderStatus == 2 {
  3514. if item.IsSale == 0 {
  3515. var res FJ3507Result
  3516. var res3507for10188 FJ3507ResultFor10188
  3517. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3518. //进行商品销售接口
  3519. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3520. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3521. var respJSON3 map[string]interface{}
  3522. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3525. return
  3526. }
  3527. userJSONBytes3, _ := json.Marshal(respJSON3)
  3528. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3529. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3530. utils.ErrorLog("解析失败:%v", err)
  3531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3532. return
  3533. }
  3534. //if res3507for10188.Infcode
  3535. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3536. //res.Output = resSix10265.Output
  3537. res.ErrMsg = res3507for10188.ErrMsg
  3538. res.Cainfo = res3507for10188.Cainfo
  3539. res.WarnMsg = res3507for10188.WarnMsg
  3540. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3541. res.Infcode = infocode
  3542. } else {
  3543. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3544. utils.ErrorLog("解析失败:%v", err)
  3545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3546. return
  3547. }
  3548. }
  3549. if res.Infcode == 0 {
  3550. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3551. item.IsSale = 1
  3552. item.Bchno = number
  3553. item.SaleDate = time.Now().Format("2006-01-02")
  3554. service.SaveDF(item)
  3555. } else {
  3556. errs = append(errs, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3557. }
  3558. }
  3559. } else { //还没结,提示用户去结算,并药品追溯上传
  3560. errs = append(errs, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3561. }
  3562. }
  3563. }
  3564. str := strings.Join(errs, " ")
  3565. saveLog(str, str, "3505", "3505自动上传日志")
  3566. }
  3567. c.ServeSuccessJSON(map[string]interface{}{
  3568. "status": "1",
  3569. "msg": errs,
  3570. })
  3571. }
  3572. //func (c *HisApiController) ChangeDrugfour() {
  3573. // patient_id, _ := c.GetInt64("patient_id")
  3574. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3575. // //id_arr := strings.Split(ids, ",")
  3576. // times := c.GetString("time", "")
  3577. // timeLayout := "2006-01-02"
  3578. // loc, _ := time.LoadLocation("Local")
  3579. // var stime, etime int64
  3580. // if times == "" {
  3581. // stime, etime = GetNowTime()
  3582. // } else {
  3583. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3584. // stime = stmp.Unix()
  3585. // etime = stime + 86399
  3586. // }
  3587. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3588. // var flows []*models.DrugFlow
  3589. // for _, item := range advicelist {
  3590. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3591. // flows = append(flows, flow...)
  3592. // }
  3593. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3594. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3595. // var err []string
  3596. //
  3597. // for _, item := range flows {
  3598. // var res3 ResultSix
  3599. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3600. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3601. // if prescription.OrderStatus == 2 {
  3602. // //已经结算
  3603. // //判断是否已经销售
  3604. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3605. // //是否已经变更 1是 0否
  3606. // if item.IsChange == 0 { //没变更,进行变更操作
  3607. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3608. //
  3609. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3610. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3611. // var respJSON3 map[string]interface{}
  3612. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3613. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3615. // return
  3616. // }
  3617. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3618. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3619. // utils.ErrorLog("解析失败:%v", err)
  3620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3621. // return
  3622. // }
  3623. // if res3.Infcode == 0 {
  3624. // item.IsChange = 1
  3625. // item.BgBchno = bg_number
  3626. // service.SaveDF2(item)
  3627. // } else {
  3628. //
  3629. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3630. // }
  3631. // }
  3632. // } else { //没销售,
  3633. // var res FJ3507Result
  3634. // var res3507for10188 FJ3507ResultFor10188
  3635. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3636. //
  3637. // //进行商品销售接口
  3638. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3639. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3640. // var respJSON3 map[string]interface{}
  3641. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3642. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3644. // return
  3645. // }
  3646. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3647. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3648. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3649. // utils.ErrorLog("解析失败:%v", err)
  3650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3651. // return
  3652. // }
  3653. // //if res3507for10188.Infcode
  3654. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3655. // //res.Output = resSix10265.Output
  3656. // res.ErrMsg = res3507for10188.ErrMsg
  3657. // res.Cainfo = res3507for10188.Cainfo
  3658. // res.WarnMsg = res3507for10188.WarnMsg
  3659. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3660. // res.Infcode = infocode
  3661. // } else {
  3662. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3663. // utils.ErrorLog("解析失败:%v", err)
  3664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3665. // return
  3666. // }
  3667. //
  3668. // }
  3669. // if res.Infcode == 0 {
  3670. // item.IsSale = 1
  3671. // item.Bchno = number
  3672. // item.SaleDate = time.Now().Format("2006-01-02")
  3673. //
  3674. // err5 := service.SaveDF(item)
  3675. // if err5 == nil {
  3676. // if item.IsChange == 0 { //没变更,进行变更操作
  3677. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3678. //
  3679. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3680. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3681. //
  3682. // var respJSON3 map[string]interface{}
  3683. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3684. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3685. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3686. // return
  3687. // }
  3688. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3689. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3690. // utils.ErrorLog("解析失败:%v", err)
  3691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3692. // return
  3693. // }
  3694. // //if res3507for10188.Infcode
  3695. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3696. // //res.Output = resSix10265.Output
  3697. // res3.ErrMsg = res3507for10188.ErrMsg
  3698. // res3.Cainfo = res3507for10188.Cainfo
  3699. // res3.WarnMsg = res3507for10188.WarnMsg
  3700. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3701. // res3.Infcode = infocode
  3702. // } else {
  3703. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3704. // utils.ErrorLog("解析失败:%v", err)
  3705. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3706. // return
  3707. // }
  3708. // }
  3709. // if res3.Infcode == 0 {
  3710. // item.IsChange = 1
  3711. // item.BgBchno = bg_number
  3712. // service.SaveDF2(item)
  3713. // } else {
  3714. //
  3715. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3716. // }
  3717. // }
  3718. // }
  3719. // } else {
  3720. //
  3721. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3722. // }
  3723. // }
  3724. //
  3725. // } else { //还没结,提示用户去结算,并药品追溯上传
  3726. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3727. // }
  3728. // }
  3729. // }
  3730. // if len(err) == 0 {
  3731. // c.ServeSuccessJSON(map[string]interface{}{
  3732. // "msg": "销售变更成功",
  3733. // })
  3734. // } else {
  3735. // c.ServeSuccessJSON(map[string]interface{}{
  3736. // "failed_code": -10,
  3737. // "msg": err,
  3738. // })
  3739. // }
  3740. //}
  3741. func (c *HisApiController) ChangeDrug() {
  3742. ids := c.GetString("ids")
  3743. id_arr := strings.Split(ids, ",")
  3744. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3745. admin_user_id, _ := c.GetInt64("admin_user_id")
  3746. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3747. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3748. var err []string
  3749. for _, item := range flows {
  3750. var res3 ResultSix
  3751. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3752. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3753. if prescription.OrderStatus == 2 {
  3754. //已经结算
  3755. //判断是否已经销售
  3756. if item.IsSale == 1 { //是否已经销售,1是 0否
  3757. //是否已经变更 1是 0否
  3758. if item.IsChange == 0 { //没变更,进行变更操作
  3759. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3760. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3761. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3762. var respJSON3 map[string]interface{}
  3763. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3766. return
  3767. }
  3768. userJSONBytes3, _ := json.Marshal(respJSON3)
  3769. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3770. utils.ErrorLog("解析失败:%v", err)
  3771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3772. return
  3773. }
  3774. if res3.Infcode == 0 {
  3775. item.IsChange = 1
  3776. item.BgBchno = bg_number
  3777. service.SaveDF2(item)
  3778. } else {
  3779. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3780. }
  3781. }
  3782. } else { //没销售,
  3783. var res FJ3507Result
  3784. var res3507for10188 FJ3507ResultFor10188
  3785. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3786. //进行商品销售接口
  3787. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3788. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3789. var respJSON3 map[string]interface{}
  3790. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3793. return
  3794. }
  3795. userJSONBytes3, _ := json.Marshal(respJSON3)
  3796. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3797. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3798. utils.ErrorLog("解析失败:%v", err)
  3799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3800. return
  3801. }
  3802. //if res3507for10188.Infcode
  3803. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3804. //res.Output = resSix10265.Output
  3805. res.ErrMsg = res3507for10188.ErrMsg
  3806. res.Cainfo = res3507for10188.Cainfo
  3807. res.WarnMsg = res3507for10188.WarnMsg
  3808. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3809. res.Infcode = infocode
  3810. } else {
  3811. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3812. utils.ErrorLog("解析失败:%v", err)
  3813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3814. return
  3815. }
  3816. }
  3817. if res.Infcode == 0 {
  3818. item.IsSale = 1
  3819. item.Bchno = number
  3820. item.SaleDate = time.Now().Format("2006-01-02")
  3821. err5 := service.SaveDF(item)
  3822. if err5 == nil {
  3823. if item.IsChange == 0 { //没变更,进行变更操作
  3824. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3825. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3826. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3827. var respJSON3 map[string]interface{}
  3828. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3831. return
  3832. }
  3833. userJSONBytes3, _ := json.Marshal(respJSON3)
  3834. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3835. utils.ErrorLog("解析失败:%v", err)
  3836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3837. return
  3838. }
  3839. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3840. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3841. utils.ErrorLog("解析失败:%v", err)
  3842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3843. return
  3844. }
  3845. //if res3507for10188.Infcode
  3846. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3847. //res.Output = resSix10265.Output
  3848. res3.ErrMsg = res3507for10188.ErrMsg
  3849. res3.Cainfo = res3507for10188.Cainfo
  3850. res3.WarnMsg = res3507for10188.WarnMsg
  3851. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3852. res3.Infcode = infocode
  3853. } else {
  3854. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3855. utils.ErrorLog("解析失败:%v", err)
  3856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3857. return
  3858. }
  3859. }
  3860. if res3.Infcode == 0 {
  3861. item.IsChange = 1
  3862. item.BgBchno = bg_number
  3863. service.SaveDF2(item)
  3864. } else {
  3865. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3866. }
  3867. }
  3868. }
  3869. } else {
  3870. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3871. }
  3872. }
  3873. } else { //还没结算
  3874. var res3507for10188 FJ3507ResultFor10188
  3875. if item.IsChange == 0 { //没变更,进行变更操作
  3876. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3877. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3878. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3879. var respJSON3 map[string]interface{}
  3880. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3883. return
  3884. }
  3885. userJSONBytes3, _ := json.Marshal(respJSON3)
  3886. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3887. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3888. utils.ErrorLog("解析失败:%v", err)
  3889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3890. return
  3891. }
  3892. //if res3507for10188.Infcode
  3893. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3894. //res.Output = resSix10265.Output
  3895. res3.ErrMsg = res3507for10188.ErrMsg
  3896. res3.Cainfo = res3507for10188.Cainfo
  3897. res3.WarnMsg = res3507for10188.WarnMsg
  3898. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3899. res3.Infcode = infocode
  3900. } else {
  3901. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3902. utils.ErrorLog("解析失败:%v", err)
  3903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3904. return
  3905. }
  3906. }
  3907. if res3.Infcode == 0 {
  3908. item.IsChange = 1
  3909. item.BgBchno = bg_number
  3910. service.SaveDF2(item)
  3911. } else {
  3912. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3913. }
  3914. }
  3915. }
  3916. } else if item.ConsumableType == 7 {
  3917. var res3507for10188 FJ3507ResultFor10188
  3918. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3919. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3920. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3921. //判断是否已经销售
  3922. if item.IsSale == 2 { //是否已经销售,1是 0否
  3923. //是否已经变更 1是 0否
  3924. if item.IsChange == 0 { //没变更,进行变更操作
  3925. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3926. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3927. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3928. var respJSON3 map[string]interface{}
  3929. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3932. return
  3933. }
  3934. userJSONBytes3, _ := json.Marshal(respJSON3)
  3935. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3936. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3937. utils.ErrorLog("解析失败:%v", err)
  3938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. return
  3940. }
  3941. //if res3507for10188.Infcode
  3942. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3943. //res.Output = resSix10265.Output
  3944. res3.ErrMsg = res3507for10188.ErrMsg
  3945. res3.Cainfo = res3507for10188.Cainfo
  3946. res3.WarnMsg = res3507for10188.WarnMsg
  3947. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3948. res3.Infcode = infocode
  3949. } else {
  3950. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3951. utils.ErrorLog("解析失败:%v", err)
  3952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3953. return
  3954. }
  3955. }
  3956. if res3.Infcode == 0 {
  3957. item.IsChange = 1
  3958. item.BgBchno = bg_number
  3959. service.SaveDF2(item)
  3960. } else {
  3961. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3962. }
  3963. }
  3964. } else { //没销售,
  3965. //进行商品销售退货接口
  3966. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3967. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3968. saveLog(result111, result222, "3506", "销售退货")
  3969. var res7 FJ3507Result
  3970. //进行商品销售接口
  3971. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3972. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3973. var respJSON3 map[string]interface{}
  3974. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3977. return
  3978. }
  3979. userJSONBytes3, _ := json.Marshal(respJSON3)
  3980. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3981. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3982. utils.ErrorLog("解析失败:%v", err)
  3983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3984. return
  3985. }
  3986. //if res3507for10188.Infcode
  3987. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3988. //res.Output = resSix10265.Output
  3989. res7.ErrMsg = res3507for10188.ErrMsg
  3990. res7.Cainfo = res3507for10188.Cainfo
  3991. res7.WarnMsg = res3507for10188.WarnMsg
  3992. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3993. res7.Infcode = infocode
  3994. } else {
  3995. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3996. utils.ErrorLog("解析失败:%v", err)
  3997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3998. return
  3999. }
  4000. }
  4001. if res7.Infcode == 0 {
  4002. item.IsSale = 2
  4003. item.SaleDate = item.SaleDate
  4004. item.Bchno = number
  4005. service.SaveDF(item)
  4006. if item.IsChange == 0 { //没变更,进行变更操作
  4007. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4008. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4009. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4010. var respJSON3 map[string]interface{}
  4011. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4014. return
  4015. }
  4016. userJSONBytes3, _ := json.Marshal(respJSON3)
  4017. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4018. // utils.ErrorLog("解析失败:%v", err)
  4019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4020. // return
  4021. //}
  4022. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4023. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4024. utils.ErrorLog("解析失败:%v", err)
  4025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4026. return
  4027. }
  4028. //if res3507for10188.Infcode
  4029. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4030. //res.Output = resSix10265.Output
  4031. res3.ErrMsg = res3507for10188.ErrMsg
  4032. res3.Cainfo = res3507for10188.Cainfo
  4033. res3.WarnMsg = res3507for10188.WarnMsg
  4034. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4035. res3.Infcode = infocode
  4036. } else {
  4037. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4038. utils.ErrorLog("解析失败:%v", err)
  4039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4040. return
  4041. }
  4042. }
  4043. if res3.Infcode == 0 {
  4044. item.IsChange = 1
  4045. item.BgBchno = bg_number
  4046. service.SaveDF2(item)
  4047. } else {
  4048. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4049. }
  4050. }
  4051. } else {
  4052. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4053. }
  4054. }
  4055. } else { //还没结算
  4056. if item.IsChange == 0 { //没变更,进行变更操作
  4057. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4058. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4059. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4060. var respJSON3 map[string]interface{}
  4061. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4064. return
  4065. }
  4066. userJSONBytes3, _ := json.Marshal(respJSON3)
  4067. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4068. // utils.ErrorLog("解析失败:%v", err)
  4069. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4070. // return
  4071. //}
  4072. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4073. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4074. utils.ErrorLog("解析失败:%v", err)
  4075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4076. return
  4077. }
  4078. //if res3507for10188.Infcode
  4079. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4080. //res.Output = resSix10265.Output
  4081. res3.ErrMsg = res3507for10188.ErrMsg
  4082. res3.Cainfo = res3507for10188.Cainfo
  4083. res3.WarnMsg = res3507for10188.WarnMsg
  4084. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4085. res3.Infcode = infocode
  4086. } else {
  4087. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4088. utils.ErrorLog("解析失败:%v", err)
  4089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4090. return
  4091. }
  4092. }
  4093. if res3.Infcode == 0 {
  4094. item.IsChange = 1
  4095. item.BgBchno = bg_number
  4096. service.SaveDF2(item)
  4097. } else {
  4098. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4099. }
  4100. }
  4101. }
  4102. }
  4103. }
  4104. if len(err) == 0 {
  4105. c.ServeSuccessJSON(map[string]interface{}{
  4106. "msg": "销售变更成功",
  4107. })
  4108. } else {
  4109. c.ServeSuccessJSON(map[string]interface{}{
  4110. "failed_code": -10,
  4111. "msg": err,
  4112. })
  4113. }
  4114. }
  4115. func (c *HisApiController) ChangeDrugtwo() {
  4116. //ids := c.GetString("ids")
  4117. //id_arr := strings.Split(ids, ",")
  4118. flows, _ := service.GetNewDrugFlowInfothree123()
  4119. admin_user_id, _ := c.GetInt64("admin_user_id")
  4120. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4121. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4122. var err []string
  4123. for _, item := range flows {
  4124. var res3 ResultSix
  4125. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4126. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4127. if prescription.OrderStatus == 2 {
  4128. //已经结算
  4129. //判断是否已经销售
  4130. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4131. // //是否已经变更 1是 0否
  4132. // if item.IsChange == 0 { //没变更,进行变更操作
  4133. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4134. //
  4135. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4136. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4137. // var respJSON3 map[string]interface{}
  4138. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4139. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4141. // return
  4142. // }
  4143. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4144. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4145. // utils.ErrorLog("解析失败:%v", err)
  4146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4147. // return
  4148. // }
  4149. // if res3.Infcode == 0 {
  4150. // item.IsChange = 1
  4151. // item.BgBchno = bg_number
  4152. // service.SaveDF2(item)
  4153. // } else {
  4154. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4155. // }
  4156. // }
  4157. //}
  4158. //else
  4159. { //没销售,
  4160. var res FJ3507Result
  4161. var res3507for10188 FJ3507ResultFor10188
  4162. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4163. //进行商品销售接口
  4164. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4165. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4166. var respJSON3 map[string]interface{}
  4167. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4170. return
  4171. }
  4172. userJSONBytes3, _ := json.Marshal(respJSON3)
  4173. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4174. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4175. utils.ErrorLog("解析失败:%v", err)
  4176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4177. return
  4178. }
  4179. //if res3507for10188.Infcode
  4180. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4181. //res.Output = resSix10265.Output
  4182. res.ErrMsg = res3507for10188.ErrMsg
  4183. res.Cainfo = res3507for10188.Cainfo
  4184. res.WarnMsg = res3507for10188.WarnMsg
  4185. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4186. res.Infcode = infocode
  4187. } else {
  4188. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4189. utils.ErrorLog("解析失败:%v", err)
  4190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4191. return
  4192. }
  4193. }
  4194. if res.Infcode == 0 {
  4195. item.IsSale = 1
  4196. item.Bchno = number
  4197. item.SaleDate = time.Now().Format("2006-01-02")
  4198. service.SaveDF(item)
  4199. //if err5 == nil {
  4200. // if item.IsChange == 0 { //没变更,进行变更操作
  4201. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4202. //
  4203. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4204. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4205. //
  4206. // var respJSON3 map[string]interface{}
  4207. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4208. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4210. // return
  4211. // }
  4212. //
  4213. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4214. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4215. // utils.ErrorLog("解析失败:%v", err)
  4216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4217. // return
  4218. // }
  4219. // //if res3507for10188.Infcode
  4220. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4221. // //res.Output = resSix10265.Output
  4222. // res3.ErrMsg = res3507for10188.ErrMsg
  4223. // res3.Cainfo = res3507for10188.Cainfo
  4224. // res3.WarnMsg = res3507for10188.WarnMsg
  4225. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4226. // res3.Infcode = infocode
  4227. // } else {
  4228. //
  4229. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4230. // utils.ErrorLog("解析失败:%v", err)
  4231. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4232. // return
  4233. // }
  4234. //
  4235. // }
  4236. //
  4237. // if res3.Infcode == 0 {
  4238. // item.IsChange = 1
  4239. // item.BgBchno = bg_number
  4240. // service.SaveDF2(item)
  4241. // } else {
  4242. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4243. // }
  4244. // }
  4245. //}
  4246. } else {
  4247. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4248. }
  4249. }
  4250. } else { //还没结算
  4251. var res3507for10188 FJ3507ResultFor10188
  4252. if item.IsChange == 0 { //没变更,进行变更操作
  4253. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4254. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4255. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4256. var respJSON3 map[string]interface{}
  4257. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4260. return
  4261. }
  4262. userJSONBytes3, _ := json.Marshal(respJSON3)
  4263. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4264. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4265. utils.ErrorLog("解析失败:%v", err)
  4266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4267. return
  4268. }
  4269. //if res3507for10188.Infcode
  4270. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4271. //res.Output = resSix10265.Output
  4272. res3.ErrMsg = res3507for10188.ErrMsg
  4273. res3.Cainfo = res3507for10188.Cainfo
  4274. res3.WarnMsg = res3507for10188.WarnMsg
  4275. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4276. res3.Infcode = infocode
  4277. } else {
  4278. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4279. utils.ErrorLog("解析失败:%v", err)
  4280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4281. return
  4282. }
  4283. }
  4284. if res3.Infcode == 0 {
  4285. item.IsChange = 1
  4286. item.BgBchno = bg_number
  4287. service.SaveDF2(item)
  4288. } else {
  4289. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4290. }
  4291. }
  4292. }
  4293. }
  4294. //if item.ConsumableType == 7 {
  4295. // var res3507for10188 FJ3507ResultFor10188
  4296. //
  4297. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4298. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4299. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4300. // //判断是否已经销售
  4301. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4302. // //是否已经变更 1是 0否
  4303. // if item.IsChange == 0 { //没变更,进行变更操作
  4304. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4305. //
  4306. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4307. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4308. //
  4309. // var respJSON3 map[string]interface{}
  4310. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4311. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4313. // return
  4314. // }
  4315. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4316. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4317. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4318. // utils.ErrorLog("解析失败:%v", err)
  4319. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4320. // return
  4321. // }
  4322. // //if res3507for10188.Infcode
  4323. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4324. // //res.Output = resSix10265.Output
  4325. // res3.ErrMsg = res3507for10188.ErrMsg
  4326. // res3.Cainfo = res3507for10188.Cainfo
  4327. // res3.WarnMsg = res3507for10188.WarnMsg
  4328. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4329. // res3.Infcode = infocode
  4330. // } else {
  4331. //
  4332. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4333. // utils.ErrorLog("解析失败:%v", err)
  4334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4335. // return
  4336. // }
  4337. //
  4338. // }
  4339. // if res3.Infcode == 0 {
  4340. // item.IsChange = 1
  4341. // item.BgBchno = bg_number
  4342. // service.SaveDF2(item)
  4343. // } else {
  4344. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4345. // }
  4346. // }
  4347. // } else { //没销售,
  4348. // //进行商品销售退货接口
  4349. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4350. //
  4351. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4352. // saveLog(result111, result222, "3506", "销售退货")
  4353. // var res7 FJ3507Result
  4354. //
  4355. // //进行商品销售接口
  4356. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4357. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4358. // var respJSON3 map[string]interface{}
  4359. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4360. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4362. // return
  4363. // }
  4364. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4365. //
  4366. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4367. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4368. // utils.ErrorLog("解析失败:%v", err)
  4369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4370. // return
  4371. // }
  4372. // //if res3507for10188.Infcode
  4373. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4374. // //res.Output = resSix10265.Output
  4375. // res7.ErrMsg = res3507for10188.ErrMsg
  4376. // res7.Cainfo = res3507for10188.Cainfo
  4377. // res7.WarnMsg = res3507for10188.WarnMsg
  4378. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4379. // res7.Infcode = infocode
  4380. // } else {
  4381. //
  4382. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4383. // utils.ErrorLog("解析失败:%v", err)
  4384. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4385. // return
  4386. // }
  4387. //
  4388. // }
  4389. // if res7.Infcode == 0 {
  4390. // item.IsSale = 2
  4391. // item.SaleDate = item.SaleDate
  4392. // item.Bchno = number
  4393. // service.SaveDF(item)
  4394. // if item.IsChange == 0 { //没变更,进行变更操作
  4395. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4396. //
  4397. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4398. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4399. //
  4400. // var respJSON3 map[string]interface{}
  4401. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4402. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4404. // return
  4405. // }
  4406. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4407. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4408. // // utils.ErrorLog("解析失败:%v", err)
  4409. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4410. // // return
  4411. // //}
  4412. //
  4413. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4414. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4415. // utils.ErrorLog("解析失败:%v", err)
  4416. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4417. // return
  4418. // }
  4419. // //if res3507for10188.Infcode
  4420. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4421. // //res.Output = resSix10265.Output
  4422. // res3.ErrMsg = res3507for10188.ErrMsg
  4423. // res3.Cainfo = res3507for10188.Cainfo
  4424. // res3.WarnMsg = res3507for10188.WarnMsg
  4425. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4426. // res3.Infcode = infocode
  4427. // } else {
  4428. //
  4429. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4430. // utils.ErrorLog("解析失败:%v", err)
  4431. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4432. // return
  4433. // }
  4434. //
  4435. // }
  4436. // if res3.Infcode == 0 {
  4437. // item.IsChange = 1
  4438. // item.BgBchno = bg_number
  4439. // service.SaveDF2(item)
  4440. // } else {
  4441. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4442. // }
  4443. // }
  4444. // } else {
  4445. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4446. // }
  4447. // }
  4448. // } else { //还没结算
  4449. // if item.IsChange == 0 { //没变更,进行变更操作
  4450. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4451. //
  4452. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4453. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4454. //
  4455. // var respJSON3 map[string]interface{}
  4456. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4457. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4458. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4459. // return
  4460. // }
  4461. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4462. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4463. // // utils.ErrorLog("解析失败:%v", err)
  4464. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4465. // // return
  4466. // //}
  4467. //
  4468. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4469. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4470. // utils.ErrorLog("解析失败:%v", err)
  4471. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4472. // return
  4473. // }
  4474. // //if res3507for10188.Infcode
  4475. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4476. // //res.Output = resSix10265.Output
  4477. // res3.ErrMsg = res3507for10188.ErrMsg
  4478. // res3.Cainfo = res3507for10188.Cainfo
  4479. // res3.WarnMsg = res3507for10188.WarnMsg
  4480. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4481. // res3.Infcode = infocode
  4482. // } else {
  4483. //
  4484. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4485. // utils.ErrorLog("解析失败:%v", err)
  4486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4487. // return
  4488. // }
  4489. //
  4490. // }
  4491. // if res3.Infcode == 0 {
  4492. // item.IsChange = 1
  4493. // item.BgBchno = bg_number
  4494. // service.SaveDF2(item)
  4495. // } else {
  4496. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4497. // }
  4498. // }
  4499. // }
  4500. //}
  4501. }
  4502. if len(err) == 0 {
  4503. c.ServeSuccessJSON(map[string]interface{}{
  4504. "msg": "销售变更成功",
  4505. })
  4506. } else {
  4507. c.ServeSuccessJSON(map[string]interface{}{
  4508. "failed_code": -10,
  4509. "msg": err,
  4510. })
  4511. }
  4512. }
  4513. func (c *HisApiController) ChangeDrugthree() {
  4514. //ids := c.GetString("ids")
  4515. //id_arr := strings.Split(ids, ",")
  4516. flows, _ := service.GetNewDrugFlowInfothree()
  4517. admin_user_id, _ := c.GetInt64("admin_user_id")
  4518. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4519. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4520. var err []string
  4521. for _, item := range flows {
  4522. var res3 ResultSix
  4523. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4524. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4525. if prescription.OrderStatus == 2 {
  4526. //已经结算
  4527. //判断是否已经销售
  4528. if item.IsSale == 1 { //是否已经销售,1是 0否
  4529. //是否已经变更 1是 0否
  4530. if item.IsChange == 0 { //没变更,进行变更操作
  4531. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4532. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4533. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4534. var respJSON3 map[string]interface{}
  4535. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4538. return
  4539. }
  4540. userJSONBytes3, _ := json.Marshal(respJSON3)
  4541. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4542. utils.ErrorLog("解析失败:%v", err)
  4543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4544. return
  4545. }
  4546. if res3.Infcode == 0 {
  4547. item.IsChange = 1
  4548. item.BgBchno = bg_number
  4549. service.SaveDF2(item)
  4550. } else {
  4551. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4552. }
  4553. }
  4554. } else { //没销售,
  4555. var res FJ3507Result
  4556. var res3507for10188 FJ3507ResultFor10188
  4557. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4558. //进行商品销售接口
  4559. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4560. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4561. var respJSON3 map[string]interface{}
  4562. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4565. return
  4566. }
  4567. userJSONBytes3, _ := json.Marshal(respJSON3)
  4568. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4569. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4570. utils.ErrorLog("解析失败:%v", err)
  4571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4572. return
  4573. }
  4574. //if res3507for10188.Infcode
  4575. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4576. //res.Output = resSix10265.Output
  4577. res.ErrMsg = res3507for10188.ErrMsg
  4578. res.Cainfo = res3507for10188.Cainfo
  4579. res.WarnMsg = res3507for10188.WarnMsg
  4580. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4581. res.Infcode = infocode
  4582. } else {
  4583. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4584. utils.ErrorLog("解析失败:%v", err)
  4585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4586. return
  4587. }
  4588. }
  4589. if res.Infcode == 0 {
  4590. item.IsSale = 1
  4591. item.Bchno = number
  4592. item.SaleDate = time.Now().Format("2006-01-02")
  4593. err5 := service.SaveDF(item)
  4594. if err5 == nil {
  4595. if item.IsChange == 0 { //没变更,进行变更操作
  4596. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4597. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4598. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4599. var respJSON3 map[string]interface{}
  4600. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4603. return
  4604. }
  4605. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4606. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4607. utils.ErrorLog("解析失败:%v", err)
  4608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4609. return
  4610. }
  4611. //if res3507for10188.Infcode
  4612. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4613. //res.Output = resSix10265.Output
  4614. res3.ErrMsg = res3507for10188.ErrMsg
  4615. res3.Cainfo = res3507for10188.Cainfo
  4616. res3.WarnMsg = res3507for10188.WarnMsg
  4617. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4618. res3.Infcode = infocode
  4619. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4620. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4621. utils.ErrorLog("解析失败:%v", err)
  4622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4623. return
  4624. }
  4625. //if res3507for10188.Infcode
  4626. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4627. //res.Output = resSix10265.Output
  4628. res3.ErrMsg = res3507for10188.ErrMsg
  4629. res3.Cainfo = res3507for10188.Cainfo
  4630. res3.WarnMsg = res3507for10188.WarnMsg
  4631. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4632. res3.Infcode = infocode
  4633. } else {
  4634. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4635. utils.ErrorLog("解析失败:%v", err)
  4636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4637. return
  4638. }
  4639. }
  4640. if res3.Infcode == 0 {
  4641. item.IsChange = 1
  4642. item.BgBchno = bg_number
  4643. service.SaveDF2(item)
  4644. } else {
  4645. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4646. }
  4647. }
  4648. }
  4649. } else {
  4650. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4651. }
  4652. }
  4653. } else { //还没结算
  4654. var res3507for10188 FJ3507ResultFor10188
  4655. if item.IsChange == 0 { //没变更,进行变更操作
  4656. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4657. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4658. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4659. var respJSON3 map[string]interface{}
  4660. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4663. return
  4664. }
  4665. userJSONBytes3, _ := json.Marshal(respJSON3)
  4666. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4667. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4668. utils.ErrorLog("解析失败:%v", err)
  4669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4670. return
  4671. }
  4672. //if res3507for10188.Infcode
  4673. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4674. //res.Output = resSix10265.Output
  4675. res3.ErrMsg = res3507for10188.ErrMsg
  4676. res3.Cainfo = res3507for10188.Cainfo
  4677. res3.WarnMsg = res3507for10188.WarnMsg
  4678. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4679. res3.Infcode = infocode
  4680. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4681. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4682. utils.ErrorLog("解析失败:%v", err)
  4683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4684. return
  4685. }
  4686. //if res3507for10188.Infcode
  4687. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4688. //res.Output = resSix10265.Output
  4689. res3.ErrMsg = res3507for10188.ErrMsg
  4690. res3.Cainfo = res3507for10188.Cainfo
  4691. res3.WarnMsg = res3507for10188.WarnMsg
  4692. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4693. res3.Infcode = infocode
  4694. } else {
  4695. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4696. utils.ErrorLog("解析失败:%v", err)
  4697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4698. return
  4699. }
  4700. }
  4701. if res3.Infcode == 0 {
  4702. item.IsChange = 1
  4703. item.BgBchno = bg_number
  4704. service.SaveDF2(item)
  4705. } else {
  4706. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4707. }
  4708. }
  4709. }
  4710. } else if item.ConsumableType == 7 {
  4711. var res3507for10188 FJ3507ResultFor10188
  4712. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4713. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4714. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4715. //判断是否已经销售
  4716. if item.IsSale == 2 { //是否已经销售,1是 0否
  4717. //是否已经变更 1是 0否
  4718. if item.IsChange == 0 { //没变更,进行变更操作
  4719. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4720. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4721. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4722. var respJSON3 map[string]interface{}
  4723. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4726. return
  4727. }
  4728. userJSONBytes3, _ := json.Marshal(respJSON3)
  4729. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4730. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4731. utils.ErrorLog("解析失败:%v", err)
  4732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4733. return
  4734. }
  4735. //if res3507for10188.Infcode
  4736. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4737. //res.Output = resSix10265.Output
  4738. res3.ErrMsg = res3507for10188.ErrMsg
  4739. res3.Cainfo = res3507for10188.Cainfo
  4740. res3.WarnMsg = res3507for10188.WarnMsg
  4741. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4742. res3.Infcode = infocode
  4743. } else {
  4744. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4745. utils.ErrorLog("解析失败:%v", err)
  4746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4747. return
  4748. }
  4749. }
  4750. if res3.Infcode == 0 {
  4751. item.IsChange = 1
  4752. item.BgBchno = bg_number
  4753. service.SaveDF2(item)
  4754. } else {
  4755. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4756. }
  4757. }
  4758. } else { //没销售,
  4759. //进行商品销售退货接口
  4760. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4761. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4762. saveLog(result111, result222, "3506", "销售退货")
  4763. var res7 FJ3507Result
  4764. //进行商品销售接口
  4765. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4766. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4767. var respJSON3 map[string]interface{}
  4768. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4771. return
  4772. }
  4773. userJSONBytes3, _ := json.Marshal(respJSON3)
  4774. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4775. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4776. utils.ErrorLog("解析失败:%v", err)
  4777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4778. return
  4779. }
  4780. //if res3507for10188.Infcode
  4781. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4782. //res.Output = resSix10265.Output
  4783. res7.ErrMsg = res3507for10188.ErrMsg
  4784. res7.Cainfo = res3507for10188.Cainfo
  4785. res7.WarnMsg = res3507for10188.WarnMsg
  4786. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4787. res7.Infcode = infocode
  4788. } else {
  4789. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4790. utils.ErrorLog("解析失败:%v", err)
  4791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4792. return
  4793. }
  4794. }
  4795. if res7.Infcode == 0 {
  4796. item.IsSale = 2
  4797. item.SaleDate = item.SaleDate
  4798. item.Bchno = number
  4799. service.SaveDF(item)
  4800. if item.IsChange == 0 { //没变更,进行变更操作
  4801. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4802. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4803. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4804. var respJSON3 map[string]interface{}
  4805. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4808. return
  4809. }
  4810. userJSONBytes3, _ := json.Marshal(respJSON3)
  4811. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4812. // utils.ErrorLog("解析失败:%v", err)
  4813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4814. // return
  4815. //}
  4816. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4817. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4818. utils.ErrorLog("解析失败:%v", err)
  4819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4820. return
  4821. }
  4822. //if res3507for10188.Infcode
  4823. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4824. //res.Output = resSix10265.Output
  4825. res3.ErrMsg = res3507for10188.ErrMsg
  4826. res3.Cainfo = res3507for10188.Cainfo
  4827. res3.WarnMsg = res3507for10188.WarnMsg
  4828. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4829. res3.Infcode = infocode
  4830. } else {
  4831. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4832. utils.ErrorLog("解析失败:%v", err)
  4833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4834. return
  4835. }
  4836. }
  4837. if res3.Infcode == 0 {
  4838. item.IsChange = 1
  4839. item.BgBchno = bg_number
  4840. service.SaveDF2(item)
  4841. } else {
  4842. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4843. }
  4844. }
  4845. } else {
  4846. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4847. }
  4848. }
  4849. } else { //还没结算
  4850. if item.IsChange == 0 { //没变更,进行变更操作
  4851. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4852. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4853. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4854. var respJSON3 map[string]interface{}
  4855. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4858. return
  4859. }
  4860. userJSONBytes3, _ := json.Marshal(respJSON3)
  4861. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4862. // utils.ErrorLog("解析失败:%v", err)
  4863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4864. // return
  4865. //}
  4866. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4867. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4868. utils.ErrorLog("解析失败:%v", err)
  4869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4870. return
  4871. }
  4872. //if res3507for10188.Infcode
  4873. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4874. //res.Output = resSix10265.Output
  4875. res3.ErrMsg = res3507for10188.ErrMsg
  4876. res3.Cainfo = res3507for10188.Cainfo
  4877. res3.WarnMsg = res3507for10188.WarnMsg
  4878. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4879. res3.Infcode = infocode
  4880. } else {
  4881. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4882. utils.ErrorLog("解析失败:%v", err)
  4883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4884. return
  4885. }
  4886. }
  4887. if res3.Infcode == 0 {
  4888. item.IsChange = 1
  4889. item.BgBchno = bg_number
  4890. service.SaveDF2(item)
  4891. } else {
  4892. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4893. }
  4894. }
  4895. }
  4896. }
  4897. }
  4898. if len(err) == 0 {
  4899. c.ServeSuccessJSON(map[string]interface{}{
  4900. "msg": "销售变更成功",
  4901. })
  4902. } else {
  4903. c.ServeSuccessJSON(map[string]interface{}{
  4904. "failed_code": -10,
  4905. "msg": err,
  4906. })
  4907. }
  4908. }
  4909. func (c *HisApiController) ChangeDrugTen() {
  4910. start_time_str := c.GetString("start_time")
  4911. end_time_str := c.GetString("end_time")
  4912. //ids := c.GetString("ids")
  4913. //id_arr := strings.Split(ids, ",")
  4914. timeLayout := "2006-01-02"
  4915. loc, _ := time.LoadLocation("Local")
  4916. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4917. recordStartTime := theStartTime.Unix()
  4918. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4919. recordEndTime := theEndTime.Unix()
  4920. //timestamp := int64(1729612800)
  4921. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4922. admin_user_id, _ := c.GetInt64("admin_user_id")
  4923. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4924. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4925. var err []string
  4926. for _, item := range flows {
  4927. var res3 ResultSix
  4928. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4929. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4930. continue
  4931. }
  4932. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4933. continue
  4934. }
  4935. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4936. if prescription.OrderStatus == 2 {
  4937. //已经结算
  4938. //判断 是否已经销售
  4939. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4940. ////是否已经变更 1是 0否
  4941. //if item.IsChange == 0 { //没变更,进行变更操作
  4942. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4943. //
  4944. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4945. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4946. // var respJSON3 map[string]interface{}
  4947. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4948. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4950. // return
  4951. // }
  4952. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4953. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4954. // utils.ErrorLog("解析失败:%v", err)
  4955. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4956. // return
  4957. // }
  4958. // if res3.Infcode == 0 {
  4959. // item.IsChange = 1
  4960. // item.BgBchno = bg_number
  4961. // service.SaveDF2(item)
  4962. // } else {
  4963. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4964. // }
  4965. //}
  4966. //} else
  4967. if item.IsSale == 0 { //没销售,
  4968. var res FJ3507Result
  4969. var res3507for10188 FJ3507ResultFor10188
  4970. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4971. //进行商品销售接口
  4972. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4973. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4974. var respJSON3 map[string]interface{}
  4975. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4978. return
  4979. }
  4980. userJSONBytes3, _ := json.Marshal(respJSON3)
  4981. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  4982. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4983. utils.ErrorLog("解析失败:%v", err)
  4984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4985. return
  4986. }
  4987. //if res3507for10188.Infcode
  4988. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4989. //res.Output = resSix10265.Output
  4990. res.ErrMsg = res3507for10188.ErrMsg
  4991. res.Cainfo = res3507for10188.Cainfo
  4992. res.WarnMsg = res3507for10188.WarnMsg
  4993. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4994. res.Infcode = infocode
  4995. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4996. } else {
  4997. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4998. utils.ErrorLog("解析失败:%v", err)
  4999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5000. return
  5001. }
  5002. }
  5003. if res.Infcode == 0 {
  5004. item.IsSale = 1
  5005. item.Bchno = number
  5006. item.SaleDate = time.Now().Format("2006-01-02")
  5007. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  5008. err5 := service.SaveDF(item)
  5009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  5010. //if err5 == nil {
  5011. //
  5012. // if item.IsChange == 1 { //没变更,进行变更操作
  5013. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5014. //
  5015. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5016. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5017. //
  5018. // var respJSON3 map[string]interface{}
  5019. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5020. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5021. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5022. // return
  5023. // }
  5024. //
  5025. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  5026. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5027. // utils.ErrorLog("解析失败:%v", err)
  5028. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5029. // return
  5030. // }
  5031. // //if res3507for10188.Infcode
  5032. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5033. // //res.Output = resSix10265.Output
  5034. // res3.ErrMsg = res3507for10188.ErrMsg
  5035. // res3.Cainfo = res3507for10188.Cainfo
  5036. // res3.WarnMsg = res3507for10188.WarnMsg
  5037. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5038. // res3.Infcode = infocode
  5039. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5040. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5041. // utils.ErrorLog("解析失败:%v", err)
  5042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5043. // return
  5044. // }
  5045. // //if res3507for10188.Infcode
  5046. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5047. // //res.Output = resSix10265.Output
  5048. // res3.ErrMsg = res3507for10188.ErrMsg
  5049. // res3.Cainfo = res3507for10188.Cainfo
  5050. // res3.WarnMsg = res3507for10188.WarnMsg
  5051. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5052. // res3.Infcode = infocode
  5053. //
  5054. // } else {
  5055. //
  5056. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5057. // utils.ErrorLog("解析失败:%v", err)
  5058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5059. // return
  5060. // }
  5061. //
  5062. // }
  5063. //
  5064. // if res3.Infcode == 0 {
  5065. // item.IsChange = 1
  5066. // item.BgBchno = bg_number
  5067. // service.SaveDF2(item)
  5068. // return
  5069. // } else {
  5070. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5071. // }
  5072. // }
  5073. //}
  5074. } else {
  5075. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5076. }
  5077. }
  5078. }
  5079. } else if item.ConsumableType == 7 {
  5080. var res3507for10188 FJ3507ResultFor10188
  5081. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5082. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  5083. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  5084. //判断是否已经销售
  5085. if item.IsSale == 2 { //是否已经销售,1是 0否
  5086. //是否已经变更 1是 0否
  5087. if item.IsChange == 0 { //没变更,进行变更操作
  5088. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5089. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5090. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5091. var respJSON3 map[string]interface{}
  5092. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5095. return
  5096. }
  5097. userJSONBytes3, _ := json.Marshal(respJSON3)
  5098. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5099. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5100. utils.ErrorLog("解析失败:%v", err)
  5101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5102. return
  5103. }
  5104. //if res3507for10188.Infcode
  5105. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5106. //res.Output = resSix10265.Output
  5107. res3.ErrMsg = res3507for10188.ErrMsg
  5108. res3.Cainfo = res3507for10188.Cainfo
  5109. res3.WarnMsg = res3507for10188.WarnMsg
  5110. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5111. res3.Infcode = infocode
  5112. } else {
  5113. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5114. utils.ErrorLog("解析失败:%v", err)
  5115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5116. return
  5117. }
  5118. }
  5119. if res3.Infcode == 0 {
  5120. item.IsChange = 1
  5121. item.BgBchno = bg_number
  5122. service.SaveDF2(item)
  5123. } else {
  5124. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5125. }
  5126. }
  5127. } else { //没销售,
  5128. //进行商品销售退货接口
  5129. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  5130. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  5131. saveLog(result111, result222, "3506", "销售退货")
  5132. var res7 FJ3507Result
  5133. //进行商品销售接口
  5134. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  5135. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  5136. var respJSON3 map[string]interface{}
  5137. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  5138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5140. return
  5141. }
  5142. userJSONBytes3, _ := json.Marshal(respJSON3)
  5143. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5144. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5145. utils.ErrorLog("解析失败:%v", err)
  5146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5147. return
  5148. }
  5149. //if res3507for10188.Infcode
  5150. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  5151. //res.Output = resSix10265.Output
  5152. res7.ErrMsg = res3507for10188.ErrMsg
  5153. res7.Cainfo = res3507for10188.Cainfo
  5154. res7.WarnMsg = res3507for10188.WarnMsg
  5155. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5156. res7.Infcode = infocode
  5157. } else {
  5158. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  5159. utils.ErrorLog("解析失败:%v", err)
  5160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5161. return
  5162. }
  5163. }
  5164. if res7.Infcode == 0 {
  5165. item.IsSale = 2
  5166. item.SaleDate = item.SaleDate
  5167. item.Bchno = number
  5168. service.SaveDF(item)
  5169. if item.IsChange == 0 { //没变更,进行变更操作
  5170. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5171. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5172. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5173. var respJSON3 map[string]interface{}
  5174. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5177. return
  5178. }
  5179. userJSONBytes3, _ := json.Marshal(respJSON3)
  5180. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5181. // utils.ErrorLog("解析失败:%v", err)
  5182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5183. // return
  5184. //}
  5185. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5186. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5187. utils.ErrorLog("解析失败:%v", err)
  5188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5189. return
  5190. }
  5191. //if res3507for10188.Infcode
  5192. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5193. //res.Output = resSix10265.Output
  5194. res3.ErrMsg = res3507for10188.ErrMsg
  5195. res3.Cainfo = res3507for10188.Cainfo
  5196. res3.WarnMsg = res3507for10188.WarnMsg
  5197. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5198. res3.Infcode = infocode
  5199. } else {
  5200. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5201. utils.ErrorLog("解析失败:%v", err)
  5202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5203. return
  5204. }
  5205. }
  5206. if res3.Infcode == 0 {
  5207. item.IsChange = 1
  5208. item.BgBchno = bg_number
  5209. service.SaveDF2(item)
  5210. } else {
  5211. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5212. }
  5213. }
  5214. } else {
  5215. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5216. }
  5217. }
  5218. } else { //还没结算
  5219. if item.IsChange == 0 { //没变更,进行变更操作
  5220. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5221. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5222. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5223. var respJSON3 map[string]interface{}
  5224. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5227. return
  5228. }
  5229. userJSONBytes3, _ := json.Marshal(respJSON3)
  5230. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5231. // utils.ErrorLog("解析失败:%v", err)
  5232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5233. // return
  5234. //}
  5235. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5236. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5237. utils.ErrorLog("解析失败:%v", err)
  5238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5239. return
  5240. }
  5241. //if res3507for10188.Infcode
  5242. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5243. //res.Output = resSix10265.Output
  5244. res3.ErrMsg = res3507for10188.ErrMsg
  5245. res3.Cainfo = res3507for10188.Cainfo
  5246. res3.WarnMsg = res3507for10188.WarnMsg
  5247. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5248. res3.Infcode = infocode
  5249. } else {
  5250. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5251. utils.ErrorLog("解析失败:%v", err)
  5252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5253. return
  5254. }
  5255. }
  5256. if res3.Infcode == 0 {
  5257. item.IsChange = 1
  5258. item.BgBchno = bg_number
  5259. service.SaveDF2(item)
  5260. } else {
  5261. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5262. }
  5263. }
  5264. }
  5265. }
  5266. }
  5267. if len(err) == 0 {
  5268. c.ServeSuccessJSON(map[string]interface{}{
  5269. "msg": "销售变更成功",
  5270. })
  5271. } else {
  5272. c.ServeSuccessJSON(map[string]interface{}{
  5273. "failed_code": -10,
  5274. "msg": err,
  5275. })
  5276. }
  5277. }
  5278. func ChangeDrugTenone() {
  5279. //ids := c.GetString("ids")
  5280. //id_arr := strings.Split(ids, ",")
  5281. now := time.Now()
  5282. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  5283. //timestamp := int64(1729612800)
  5284. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  5285. admin_user_id := int64(2463)
  5286. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  5287. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  5288. var err []string
  5289. for _, item := range flows {
  5290. var res3 ResultSix
  5291. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  5292. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5293. continue
  5294. }
  5295. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5296. continue
  5297. }
  5298. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5299. if prescription.OrderStatus == 2 {
  5300. //已经结算
  5301. //判断是否已经销售
  5302. if item.IsSale == 1 { //是否已经销售,1是 0否
  5303. //是否已经变更 1是 0否
  5304. if item.IsChange == 0 { //没变更,进行变更操作
  5305. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5306. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5307. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  5308. var respJSON3 map[string]interface{}
  5309. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5311. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5312. return
  5313. }
  5314. userJSONBytes3, _ := json.Marshal(respJSON3)
  5315. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5316. utils.ErrorLog("解析失败:%v", err)
  5317. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5318. return
  5319. }
  5320. if res3.Infcode == 0 {
  5321. item.IsChange = 1
  5322. item.BgBchno = bg_number
  5323. service.SaveDF2(item)
  5324. } else {
  5325. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5326. }
  5327. }
  5328. } else { //没销售,
  5329. var res FJ3507Result
  5330. var res3507for10188 FJ3507ResultFor10188
  5331. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  5332. //进行商品销售接口
  5333. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  5334. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  5335. var respJSON3 map[string]interface{}
  5336. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  5337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5338. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5339. return
  5340. }
  5341. userJSONBytes3, _ := json.Marshal(respJSON3)
  5342. {
  5343. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5344. utils.ErrorLog("解析失败:%v", err)
  5345. return
  5346. }
  5347. //if res3507for10188.Infcode
  5348. res.InfRefmsgid = res3507for10188.InfRefmsgid
  5349. //res.Output = resSix10265.Output
  5350. res.ErrMsg = res3507for10188.ErrMsg
  5351. res.Cainfo = res3507for10188.Cainfo
  5352. res.WarnMsg = res3507for10188.WarnMsg
  5353. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5354. res.Infcode = infocode
  5355. }
  5356. if res.Infcode == 0 {
  5357. item.IsSale = 1
  5358. item.Bchno = number
  5359. item.SaleDate = time.Now().Format("2006-01-02")
  5360. err5 := service.SaveDF(item)
  5361. if err5 == nil {
  5362. if item.IsChange == 1 { //没变更,进行变更操作
  5363. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5364. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5365. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5366. var respJSON3 map[string]interface{}
  5367. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5369. return
  5370. }
  5371. {
  5372. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5373. utils.ErrorLog("解析失败:%v", err)
  5374. return
  5375. }
  5376. //if res3507for10188.Infcode
  5377. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5378. //res.Output = resSix10265.Output
  5379. res3.ErrMsg = res3507for10188.ErrMsg
  5380. res3.Cainfo = res3507for10188.Cainfo
  5381. res3.WarnMsg = res3507for10188.WarnMsg
  5382. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5383. res3.Infcode = infocode
  5384. }
  5385. if res3.Infcode == 0 {
  5386. item.IsChange = 1
  5387. item.BgBchno = bg_number
  5388. service.SaveDF2(item)
  5389. } else {
  5390. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5391. }
  5392. }
  5393. }
  5394. } else {
  5395. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5396. }
  5397. }
  5398. }
  5399. }
  5400. }
  5401. }
  5402. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5403. var struct3502 models.Struct3502
  5404. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5405. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5406. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5407. struct3502.FixmedinsCode = miConfig.Code
  5408. struct3502.Code = miConfig.Code
  5409. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5410. struct3502.Opter = role.UserName
  5411. struct3502.RxFlag = "1"
  5412. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5413. struct3502.OrgName = miConfig.OrgName
  5414. struct3502.AccessKey = miConfig.AccessKey
  5415. struct3502.RequestUrl = miConfig.Url
  5416. struct3502.SecretKey = miConfig.SecretKey
  5417. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5418. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5419. struct3502.Url = miConfig.Url
  5420. struct3502.AppId = miConfig.Cainfo
  5421. struct3502.AppSecret = miConfig.AppSecret
  5422. struct3502.Enckey = miConfig.EncKey
  5423. struct3502.SignKey = miConfig.SignKey
  5424. struct3502.SecretKey = miConfig.SecretKey
  5425. struct3502.InvChgType = chgType
  5426. struct3502.FixmedinsBchno = number
  5427. struct3502.Cnt = strconv.FormatInt(count, 10)
  5428. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5429. //result1, result2, _ := service.FJyb3502(struct3502)
  5430. if miConfig.MdtrtareaAdmvs == "350500" {
  5431. result1, result2, _ := service.FJyb3502(struct3502)
  5432. //saveLog(result1, result2, "3502", "3502")
  5433. return result1, result2
  5434. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5435. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5436. return result1, result2
  5437. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5438. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5439. return result1, result2
  5440. } else {
  5441. data := make(map[string]interface{})
  5442. data["struct_3502s"] = struct3502
  5443. client := &http.Client{}
  5444. bytesData, _ := json.Marshal(data)
  5445. var req *http.Request
  5446. if miConfig.MdtrtareaAdmvs == "320830" {
  5447. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  5448. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5449. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5450. } else {
  5451. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5452. }
  5453. resp, _ := client.Do(req)
  5454. defer resp.Body.Close()
  5455. body, ioErr := ioutil.ReadAll(resp.Body)
  5456. if ioErr != nil {
  5457. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5458. }
  5459. var respJSON map[string]interface{}
  5460. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5462. }
  5463. //var resSix10265 ResultSix10265 //1101结果
  5464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5465. result, _ := json.Marshal(respJSON)
  5466. return string(result), ""
  5467. }
  5468. }
  5469. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5470. var struct3505 models.Struct3505
  5471. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5472. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5473. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5474. struct3505.FixmedinsBchno = number
  5475. struct3505.Opter = role.UserName
  5476. struct3505.Bchno = "---"
  5477. struct3505.FixmedinsCode = miConfig.Code
  5478. struct3505.Code = miConfig.Code
  5479. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.HisDoctorAdviceInfo.Price, 'f', -1, 64)
  5480. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5481. struct3505.PrscDrName = roles.UserName
  5482. if org_id == 10191 {
  5483. struct3505.PharName = "刘水山"
  5484. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5485. }
  5486. if org_id == 10188 {
  5487. struct3505.PharName = "李汉清"
  5488. struct3505.PharPracCertNo = "30220200932022010034"
  5489. }
  5490. if org_id == 10217 {
  5491. struct3505.PharName = "张敏"
  5492. struct3505.PharPracCertNo = "30220230432090100108"
  5493. }
  5494. if org_id == 10318 {
  5495. struct3505.PharName = "邹刘阳"
  5496. struct3505.PharPracCertNo = "210441200001378"
  5497. }
  5498. if org_id == 10402 {
  5499. struct3505.PharName = "刘韶健"
  5500. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5501. }
  5502. if org_id == 9919 {
  5503. struct3505.PharName = "周君权"
  5504. struct3505.PharPracCertNo = "089644396094401375"
  5505. }
  5506. if org_id == 10644 {
  5507. struct3505.PharName = "陈金娣"
  5508. struct3505.PharPracCertNo = "20181441500320100066"
  5509. }
  5510. if org_id == 10567 {
  5511. struct3505.PharName = "范小兰"
  5512. struct3505.PharPracCertNo = "0200102079485"
  5513. }
  5514. if org_id == 10721 {
  5515. struct3505.PharName = "孙莉侠"
  5516. struct3505.PharPracCertNo = "060399"
  5517. }
  5518. if org_id == 10726 {
  5519. struct3505.PharName = "彭建福"
  5520. struct3505.PharPracCertNo = "D445281006261"
  5521. }
  5522. if org_id == 10697 {
  5523. struct3505.PharName = "陶海兰"
  5524. struct3505.PharPracCertNo = "0010933"
  5525. }
  5526. if org_id == 10265 {
  5527. struct3505.PharName = "李彩星"
  5528. struct3505.PharPracCertNo = "20171110600110100019"
  5529. }
  5530. if org_id == 10028 {
  5531. struct3505.PharName = "曾细平"
  5532. struct3505.PharPracCertNo = "D440307022134"
  5533. }
  5534. if org_id == 10138 {
  5535. struct3505.PharName = "彭斯遥"
  5536. struct3505.PharPracCertNo = "30220200943042010052"
  5537. }
  5538. if org_id == 10278 {
  5539. struct3505.PharName = "彭斯遥"
  5540. struct3505.PharPracCertNo = "30220200943042010052"
  5541. }
  5542. if org_id == 10610 {
  5543. struct3505.PharName = "彭斯遥"
  5544. struct3505.PharPracCertNo = "30220200943042010052"
  5545. }
  5546. if org_id == 10537 {
  5547. struct3505.PharName = "彭斯遥"
  5548. struct3505.PharPracCertNo = "30220200943042010052"
  5549. }
  5550. if org_id == 9504 {
  5551. struct3505.PharName = "资美红"
  5552. struct3505.PharPracCertNo = "D440904006635"
  5553. }
  5554. if org_id == 10480 {
  5555. struct3505.PharName = "陈思"
  5556. struct3505.PharPracCertNo = "30220240434110010470"
  5557. }
  5558. if org_id == 10653 {
  5559. struct3505.PharName = "邓树英"
  5560. struct3505.PharPracCertNo = "201910026440004734"
  5561. }
  5562. if org_id == 10571 {
  5563. struct3505.PharName = "廖志平"
  5564. struct3505.PharPracCertNo = "0136425"
  5565. }
  5566. if org_id == 10387 {
  5567. struct3505.PharName = "易圣"
  5568. struct3505.PharPracCertNo = "D430726002209"
  5569. }
  5570. if org_id == 10633 {
  5571. struct3505.PharName = "王敏"
  5572. struct3505.PharPracCertNo = "342222199107214042"
  5573. }
  5574. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5575. struct3505.SetlId = order.SetlId
  5576. struct3505.MdtrtSn = order.MdtrtId
  5577. struct3505.ManuLotnum = drug.BatchNumber
  5578. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5579. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5580. struct3505.RxFlag = "1"
  5581. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5582. struct3505.TrdnFlag = "0"
  5583. } else {
  5584. struct3505.TrdnFlag = "1"
  5585. }
  5586. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5587. struct3505.TrdnFlag = "1"
  5588. }
  5589. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5590. struct3505.TrdnFlag = "0"
  5591. }
  5592. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 || org_id == 10191 {
  5593. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 1 {
  5594. struct3505.TrdnFlag = "1"
  5595. }
  5596. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 2 {
  5597. struct3505.TrdnFlag = "0"
  5598. }
  5599. }
  5600. struct3505.RtalDocno = order.Number
  5601. struct3505.PsnCertType = "01"
  5602. struct3505.CertNo = order.Certno
  5603. struct3505.PsnNo = order.PsnNo
  5604. struct3505.PsnName = order.PsnName
  5605. struct3505.Url = miConfig.Url
  5606. struct3505.AppId = miConfig.Cainfo
  5607. struct3505.AppSecret = miConfig.AppSecret
  5608. struct3505.Enckey = miConfig.EncKey
  5609. struct3505.SignKey = miConfig.SignKey
  5610. struct3505.SecretKey = miConfig.SecretKey
  5611. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5612. struct3505.SelRetnCnt = strValue
  5613. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5614. struct3505.SelRetnOpterName = role.UserName
  5615. if order.IsMedicineInsurance == 1 {
  5616. struct3505.MdtrtSetlType = "1"
  5617. } else {
  5618. struct3505.MdtrtSetlType = "2"
  5619. }
  5620. struct3505.OrgName = miConfig.OrgName
  5621. struct3505.AccessKey = miConfig.AccessKey
  5622. struct3505.RequestUrl = miConfig.Url
  5623. struct3505.SecretKey = miConfig.SecretKey
  5624. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5625. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5626. struct3505.Cainfo = miConfig.Cainfo
  5627. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5628. if miConfig.MdtrtareaAdmvs == "350500" {
  5629. result1, result2, _ := service.FJyb3505(struct3505)
  5630. return result1, result2
  5631. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5632. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5633. return result1, result2
  5634. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5635. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5636. return result1, result2
  5637. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5638. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5639. return result1, result2
  5640. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5641. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5642. return result1, result2
  5643. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5644. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5645. return result1, result2
  5646. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5647. data := make(map[string]interface{})
  5648. data["struct_3505s"] = struct3505
  5649. client := &http.Client{}
  5650. bytesData, _ := json.Marshal(data)
  5651. var req *http.Request
  5652. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5653. resp, _ := client.Do(req)
  5654. defer resp.Body.Close()
  5655. body, ioErr := ioutil.ReadAll(resp.Body)
  5656. if ioErr != nil {
  5657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5658. }
  5659. var respJSON map[string]interface{}
  5660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5662. }
  5663. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5664. result, _ := json.Marshal(respJSON)
  5665. return string(result), ""
  5666. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5667. data := make(map[string]interface{})
  5668. data["struct_3505s"] = struct3505
  5669. client := &http.Client{}
  5670. bytesData, _ := json.Marshal(data)
  5671. var req *http.Request
  5672. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5673. resp, _ := client.Do(req)
  5674. defer resp.Body.Close()
  5675. body, ioErr := ioutil.ReadAll(resp.Body)
  5676. if ioErr != nil {
  5677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5678. }
  5679. var respJSON map[string]interface{}
  5680. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5682. }
  5683. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5684. if status == "0" {
  5685. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5686. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5687. }
  5688. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5689. result, _ := json.Marshal(respJSON)
  5690. return string(result), ""
  5691. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5692. result1, result2 := service.Hnyb3505(struct3505)
  5693. return result1, result2
  5694. } else {
  5695. data := make(map[string]interface{})
  5696. data["struct_3505s"] = struct3505
  5697. client := &http.Client{}
  5698. bytesData, _ := json.Marshal(data)
  5699. var req *http.Request
  5700. if miConfig.MdtrtareaAdmvs == "320830" {
  5701. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5702. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5703. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5704. } else {
  5705. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5706. }
  5707. resp, _ := client.Do(req)
  5708. defer resp.Body.Close()
  5709. body, ioErr := ioutil.ReadAll(resp.Body)
  5710. if ioErr != nil {
  5711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5712. }
  5713. var respJSON map[string]interface{}
  5714. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5716. }
  5717. //var resSix10265 ResultSix10265 //1101结果
  5718. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5719. result, _ := json.Marshal(respJSON)
  5720. return string(result), ""
  5721. }
  5722. }
  5723. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5724. var struct3505 models.Struct3505
  5725. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5726. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5727. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5728. struct3505.FixmedinsBchno = number
  5729. struct3505.Opter = role.UserName
  5730. struct3505.FixmedinsCode = miConfig.Code
  5731. struct3505.Code = miConfig.Code
  5732. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5733. struct3505.PrscDrName = roles.UserName
  5734. if org_id == 10191 {
  5735. struct3505.PharName = "刘水山"
  5736. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5737. }
  5738. if org_id == 10188 {
  5739. struct3505.PharName = "李汉清"
  5740. struct3505.PharPracCertNo = "30220200932022010034"
  5741. }
  5742. if org_id == 10217 {
  5743. struct3505.PharName = "张敏"
  5744. struct3505.PharPracCertNo = "30220230432090100108"
  5745. }
  5746. if org_id == 10318 {
  5747. struct3505.PharName = "邹刘阳"
  5748. struct3505.PharPracCertNo = "210441200001378"
  5749. }
  5750. if org_id == 10402 {
  5751. struct3505.PharName = "刘韶健"
  5752. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5753. }
  5754. if org_id == 9919 {
  5755. struct3505.PharName = "周君权"
  5756. struct3505.PharPracCertNo = "089644396094401375"
  5757. }
  5758. if org_id == 10644 {
  5759. struct3505.PharName = "陈金娣"
  5760. struct3505.PharPracCertNo = "20181441500320100066"
  5761. }
  5762. if org_id == 10567 {
  5763. struct3505.PharName = "范小兰"
  5764. struct3505.PharPracCertNo = "0200102079485"
  5765. }
  5766. if org_id == 10721 {
  5767. struct3505.PharName = "孙莉侠"
  5768. struct3505.PharPracCertNo = "060399"
  5769. }
  5770. if org_id == 10726 {
  5771. struct3505.PharName = "彭建福"
  5772. struct3505.PharPracCertNo = "D445281006261"
  5773. }
  5774. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5775. struct3505.SetlId = order.SetlId
  5776. struct3505.MdtrtSn = order.MdtrtId
  5777. struct3505.ManuLotnum = drug.Number
  5778. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5779. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5780. struct3505.RxFlag = "1"
  5781. struct3505.TrdnFlag = "0"
  5782. struct3505.RtalDocno = order.Number
  5783. struct3505.PsnCertType = "01"
  5784. struct3505.CertNo = order.Certno
  5785. struct3505.PsnNo = order.PsnNo
  5786. struct3505.PsnName = order.PsnName
  5787. struct3505.Url = miConfig.Url
  5788. struct3505.AppId = miConfig.Cainfo
  5789. struct3505.AppSecret = miConfig.AppSecret
  5790. struct3505.Enckey = miConfig.EncKey
  5791. struct3505.SignKey = miConfig.SignKey
  5792. struct3505.SecretKey = miConfig.SecretKey
  5793. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5794. struct3505.SelRetnCnt = strValue
  5795. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5796. struct3505.SelRetnOpterName = role.UserName
  5797. if order.IsMedicineInsurance == 1 {
  5798. struct3505.MdtrtSetlType = "1"
  5799. } else {
  5800. struct3505.MdtrtSetlType = "2"
  5801. }
  5802. struct3505.OrgName = miConfig.OrgName
  5803. struct3505.AccessKey = miConfig.AccessKey
  5804. struct3505.RequestUrl = miConfig.Url
  5805. struct3505.SecretKey = miConfig.SecretKey
  5806. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5807. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5808. struct3505.Cainfo = miConfig.Cainfo
  5809. struct3505.DrugTracCodg = drug.DrugCode
  5810. if miConfig.MdtrtareaAdmvs == "350500" {
  5811. result1, result2, _ := service.FJyb3505(struct3505)
  5812. return result1, result2
  5813. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5814. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5815. return result1, result2
  5816. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5817. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5818. return result1, result2
  5819. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5820. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5821. return result1, result2
  5822. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5823. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5824. return result1, result2
  5825. } else {
  5826. data := make(map[string]interface{})
  5827. data["struct_3505s"] = struct3505
  5828. client := &http.Client{}
  5829. bytesData, _ := json.Marshal(data)
  5830. var req *http.Request
  5831. if miConfig.MdtrtareaAdmvs == "320830" {
  5832. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5833. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5834. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5835. } else {
  5836. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5837. }
  5838. resp, _ := client.Do(req)
  5839. defer resp.Body.Close()
  5840. body, ioErr := ioutil.ReadAll(resp.Body)
  5841. if ioErr != nil {
  5842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5843. }
  5844. var respJSON map[string]interface{}
  5845. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5847. }
  5848. //var resSix10265 ResultSix10265 //1101结果
  5849. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5850. result, _ := json.Marshal(respJSON)
  5851. return string(result), ""
  5852. }
  5853. }
  5854. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5855. var struct3506 models.Struct3506
  5856. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5857. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5858. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5859. struct3506.FixmedinsCode = miConfig.Code
  5860. struct3506.Code = miConfig.Code
  5861. struct3506.FixmedinsBchno = number
  5862. struct3506.Opter = role.UserName
  5863. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5864. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5865. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5866. struct3506.MdtrtSn = order.MdtrtId
  5867. struct3506.ExpyEnd = ""
  5868. struct3506.RxFlag = "0"
  5869. struct3506.TrdnFlag = "1"
  5870. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5871. struct3506.SelRetnCnt = strValue
  5872. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5873. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5874. struct3506.SelRetnOpterName = role.UserName
  5875. struct3506.OrgName = miConfig.OrgName
  5876. struct3506.AccessKey = miConfig.AccessKey
  5877. struct3506.RequestUrl = miConfig.Url
  5878. struct3506.SecretKey = miConfig.SecretKey
  5879. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5880. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5881. struct3506.Url = miConfig.Url
  5882. struct3506.AppId = miConfig.Cainfo
  5883. struct3506.AppSecret = miConfig.AppSecret
  5884. struct3506.Enckey = miConfig.EncKey
  5885. struct3506.SignKey = miConfig.SignKey
  5886. struct3506.SecretKey = miConfig.SecretKey
  5887. struct3506.DrugTracCodg = drug.DrugCode
  5888. if miConfig.MdtrtareaAdmvs == "350500" {
  5889. result1, result2, _ := service.FJyb3506(struct3506)
  5890. return result1, result2
  5891. } else {
  5892. data := make(map[string]interface{})
  5893. data["struct_3506s"] = struct3506
  5894. client := &http.Client{}
  5895. bytesData, _ := json.Marshal(data)
  5896. var req *http.Request
  5897. if miConfig.MdtrtareaAdmvs == "320830" {
  5898. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3506", bytes.NewReader(bytesData))
  5899. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5900. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5901. } else {
  5902. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5903. }
  5904. resp, _ := client.Do(req)
  5905. defer resp.Body.Close()
  5906. body, ioErr := ioutil.ReadAll(resp.Body)
  5907. if ioErr != nil {
  5908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5909. }
  5910. var respJSON map[string]interface{}
  5911. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5913. }
  5914. //var resSix10265 ResultSix10265 //1101结果
  5915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5916. result, _ := json.Marshal(respJSON)
  5917. return string(result), ""
  5918. }
  5919. }
  5920. func (c *HisApiController) Get1318() {
  5921. adminUser := c.GetAdminUserInfo()
  5922. admin_user_id, _ := c.GetInt64("admin_user_id")
  5923. code := c.GetString("code")
  5924. code = ""
  5925. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5926. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5927. api := ""
  5928. if miConfig.MdtrtareaAdmvs == "320830" {
  5929. api = miConfig.AppSecret + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5930. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5931. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5932. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5933. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5934. } else {
  5935. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5936. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5937. }
  5938. resp, requestErr := http.Get(api)
  5939. if requestErr != nil {
  5940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5941. return
  5942. }
  5943. body, ioErr := ioutil.ReadAll(resp.Body)
  5944. if ioErr != nil {
  5945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5947. return
  5948. }
  5949. var respJSON map[string]interface{}
  5950. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5953. return
  5954. }
  5955. //var res Result2406
  5956. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5957. result, _ := json.Marshal(respJSON)
  5958. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5959. utils.ErrorLog("解析失败:%v", err)
  5960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5961. return
  5962. }
  5963. if res.Infcode == "0" {
  5964. c.ServeSuccessJSON(map[string]interface{}{
  5965. "result": "",
  5966. })
  5967. } else {
  5968. c.ServeSuccessJSON(map[string]interface{}{
  5969. "failed_code": -10,
  5970. "msg": res.ErrMsg,
  5971. })
  5972. */return
  5973. //}
  5974. }
  5975. func (c *HisApiController) Get2503() {
  5976. adminUser := c.GetAdminUserInfo()
  5977. admin_user_id, _ := c.GetInt64("admin_user_id")
  5978. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5979. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5980. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5981. }
  5982. func (c *HisApiController) Get2406() {
  5983. id, _ := c.GetInt64("id")
  5984. record_time := c.GetString("record_time")
  5985. his_patient_id, _ := c.GetInt64("his_patient_id")
  5986. admin_user_id, _ := c.GetInt64("admin_user_id")
  5987. diagnosis_id := c.GetString("diagnosis")
  5988. timeLayout := "2006-01-02"
  5989. loc, _ := time.LoadLocation("Local")
  5990. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5991. if err != nil {
  5992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5993. return
  5994. }
  5995. recordDateTime := theTime.Unix()
  5996. adminUser := c.GetAdminUserInfo()
  5997. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5998. var config []*models.HisXtDiagnoseConfig
  5999. for _, item := range diagnosis_ids {
  6000. id, _ := strconv.ParseInt(item, 10, 64)
  6001. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6002. config = append(config, &diagnosisConfig)
  6003. }
  6004. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6005. fmt.Println(his_patient_id)
  6006. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6007. //timestamp := time.Now().Unix()
  6008. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6009. var patientPrescription models.HisPrescriptionInfo
  6010. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6011. if patientPrescription.ID == 0 {
  6012. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6013. }
  6014. var res2 Result2406
  6015. if miConfig.MdtrtareaAdmvs == "341203" {
  6016. data := make(map[string]interface{})
  6017. client := &http.Client{}
  6018. data["psn_no"] = his.PsnNo
  6019. data["mdtrt_id"] = his.Number
  6020. data["operator"] = roles.UserName
  6021. data["cert_no"] = his.IdCardNo
  6022. data["org_name"] = miConfig.OrgName
  6023. data["psn_name"] = his.Name
  6024. data["ipt_otp_no"] = his.IptOtpNo
  6025. data["ipt_psn_sp_flag_type"] = "0901"
  6026. data["ipt_psn_sp_flag"] = "1"
  6027. data["fixmedins_code"] = miConfig.Code
  6028. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6029. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6030. data["url"] = miConfig.Url
  6031. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  6032. bytesData, _ := json.Marshal(data)
  6033. var req *http.Request
  6034. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  6035. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  6036. resp, _ := client.Do(req)
  6037. defer resp.Body.Close()
  6038. body, ioErr := ioutil.ReadAll(resp.Body)
  6039. if ioErr != nil {
  6040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6042. return
  6043. }
  6044. var respJSON map[string]interface{}
  6045. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6048. return
  6049. }
  6050. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6051. if status == "0" {
  6052. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6053. c.ServeSuccessJSON(map[string]interface{}{
  6054. "failed_code": -10,
  6055. "msg": err_msg,
  6056. })
  6057. return
  6058. }
  6059. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6060. userJSONBytes, _ := json.Marshal(respJSON)
  6061. fmt.Println("log")
  6062. fmt.Println(string(userJSONBytes))
  6063. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6064. utils.ErrorLog("解析失败:%v", err)
  6065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6066. return
  6067. }
  6068. } else if miConfig.MdtrtareaAdmvs == "340699" {
  6069. data := make(map[string]interface{})
  6070. client := &http.Client{}
  6071. data["psn_no"] = his.PsnNo
  6072. data["mdtrt_id"] = his.Number
  6073. data["operator"] = roles.UserName
  6074. data["cert_no"] = his.IdCardNo
  6075. data["org_name"] = miConfig.OrgName
  6076. data["psn_name"] = his.Name
  6077. data["ipt_otp_no"] = his.IptOtpNo
  6078. data["ipt_psn_sp_flag_type"] = "0901"
  6079. data["ipt_psn_sp_flag"] = "1"
  6080. data["fixmedins_code"] = miConfig.Code
  6081. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6082. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6083. data["url"] = miConfig.Url
  6084. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  6085. bytesData, _ := json.Marshal(data)
  6086. var req *http.Request
  6087. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  6088. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  6089. resp, _ := client.Do(req)
  6090. defer resp.Body.Close()
  6091. body, ioErr := ioutil.ReadAll(resp.Body)
  6092. if ioErr != nil {
  6093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6095. return
  6096. }
  6097. var respJSON map[string]interface{}
  6098. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6101. return
  6102. }
  6103. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6104. if status == "0" {
  6105. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6106. c.ServeSuccessJSON(map[string]interface{}{
  6107. "failed_code": -10,
  6108. "msg": err_msg,
  6109. })
  6110. return
  6111. }
  6112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6113. userJSONBytes, _ := json.Marshal(respJSON)
  6114. fmt.Println("log")
  6115. fmt.Println(string(userJSONBytes))
  6116. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6117. utils.ErrorLog("解析失败:%v", err)
  6118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6119. return
  6120. }
  6121. }
  6122. if res2.Infcode != 0 {
  6123. adminUser := c.GetAdminUserInfo()
  6124. errlog := &models.HisOrderError{
  6125. UserOrgId: adminUser.CurrentOrgId,
  6126. Ctime: time.Now().Unix(),
  6127. Mtime: time.Now().Unix(),
  6128. ErrMsg: res2.ErrMsg,
  6129. Status: 1,
  6130. PatientId: id,
  6131. RecordTime: recordDateTime,
  6132. Stage: 3,
  6133. }
  6134. service.CreateErrMsgLog(errlog)
  6135. c.ServeSuccessJSON(map[string]interface{}{
  6136. "failed_code": -10,
  6137. "msg": res2.ErrMsg,
  6138. })
  6139. return
  6140. } else {
  6141. c.ServeSuccessJSON(map[string]interface{}{
  6142. "msg": "上传成功",
  6143. })
  6144. return
  6145. }
  6146. }
  6147. func (c *HisApiController) Get4105() {
  6148. }
  6149. func (c *HisApiController) Post5302() {
  6150. patient_id, _ := c.GetInt64("id")
  6151. admin_user_id, _ := c.GetInt64("admin_user_id")
  6152. p, _ := service.GetHisPatientById(patient_id)
  6153. adminUser := c.GetAdminUserInfo()
  6154. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6155. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6156. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6157. }
  6158. func (c *HisApiController) Get4104() {
  6159. }
  6160. type Output struct {
  6161. CertNo string `json:"certno"`
  6162. PsnName string `json:"psn_name"`
  6163. CardNo string `json:"card_no"`
  6164. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6165. CardSN string `json:"card_sn"`
  6166. PsnCertType string `json:"psn_cert_type"`
  6167. MdtrtCertNo string `json:"mdtrt_cert_no"`
  6168. MdtrtCertType string `json:"mdtrt_cert_type"`
  6169. QRCode string `json:"qrCode"`
  6170. EcToken string `json:"ecToken"`
  6171. }
  6172. type AHResponse struct {
  6173. Body AHBody `json:"body"`
  6174. Code int `json:"code"`
  6175. CSBCode int `json:"csbCode"`
  6176. Message string `json:"message"`
  6177. RequestID string `json:"requestId"`
  6178. State struct{} `json:"state"`
  6179. }
  6180. type AHBody struct {
  6181. ErrMsg string `json:"err_msg"`
  6182. InfRefMsgID string `json:"inf_refmsgid"`
  6183. InfCode int `json:"infcode"`
  6184. Output struct {
  6185. Result []struct {
  6186. BasMednFlag string `json:"bas_medn_flag"`
  6187. ChldMedcFlag string `json:"chld_medc_flag"`
  6188. ChrgitmLv string `json:"chrgitm_lv"`
  6189. Cnt float64 `json:"cnt"`
  6190. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6191. DrtReimFlag string `json:"drt_reim_flag"`
  6192. FeedetlSn string `json:"feedetl_sn"`
  6193. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6194. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6195. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6196. ListSpItemFlag string `json:"list_sp_item_flag"`
  6197. LmtUsedFlag string `json:"lmt_used_flag"`
  6198. MedChrgitmType string `json:"med_chrgitm_type"`
  6199. Memo string `json:"memo"`
  6200. OverlmtAmt float64 `json:"overlmt_amt"`
  6201. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6202. Pric float64 `json:"pric"`
  6203. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6204. SelfpayProp float64 `json:"selfpay_prop"`
  6205. } `json:"result"`
  6206. } `json:"output"`
  6207. }
  6208. type Response struct {
  6209. Output Output `json:"output"`
  6210. Infcode int `json:"infcode"`
  6211. InfRefMsgID string `json:"inf_refmsgid"`
  6212. RefMsgTime string `json:"refmsg_time"`
  6213. RespondTime string `json:"respond_time"`
  6214. ErrMsg string `json:"err_msg"`
  6215. WarnMsg string `json:"warn_msg"`
  6216. SignType string `json:"signtype"`
  6217. CAInfo string `json:"cainfo"`
  6218. }
  6219. func (c *HisApiController) Getquerydata() {
  6220. query_type, _ := c.GetInt64("type")
  6221. refd_setl_flag := c.GetString("refd_setl_flag")
  6222. med_type := c.GetString("med_type")
  6223. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6224. cert_no := c.GetString("cert_no")
  6225. psn_no := c.GetString("psn_no")
  6226. start_time := c.GetString("start_time")
  6227. end_time := c.GetString("end_time")
  6228. page, _ := c.GetInt64("page")
  6229. limit, _ := c.GetInt64("limit")
  6230. var bp models.BusinessParams5262
  6231. bp.RefdSetlFlag = refd_setl_flag
  6232. bp.MedType = med_type
  6233. bp.Certno = cert_no
  6234. bp.Psnno = psn_no
  6235. bp.QBegntime = start_time
  6236. bp.QEndtime = end_time
  6237. if query_type == 1 { //本地
  6238. Post5262(c, bp, page, limit)
  6239. } else { //异地
  6240. Post5267(c, bp, page, limit)
  6241. }
  6242. }
  6243. func (c *HisApiController) Drugscheck() {
  6244. admin_user_id, _ := c.GetInt64("admin_user_id")
  6245. adminUser := c.GetAdminUserInfo()
  6246. var queryResult []QueryResult
  6247. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6248. for _, item := range drugs {
  6249. result := QueryResult{
  6250. ID: item.ID,
  6251. Name: item.DrugName,
  6252. Code: item.MedicalInsuranceNumber,
  6253. List_type_code: "101",
  6254. }
  6255. queryResult = append(queryResult, result)
  6256. }
  6257. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6258. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6259. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6260. for _, item := range queryResult {
  6261. 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)
  6262. }
  6263. }
  6264. func (c *HisApiController) Goodcheck() {
  6265. admin_user_id, _ := c.GetInt64("admin_user_id")
  6266. adminUser := c.GetAdminUserInfo()
  6267. var queryResult []QueryResult
  6268. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6269. for _, item := range goods {
  6270. result := QueryResult{
  6271. ID: item.ID,
  6272. Name: item.GoodName,
  6273. Code: item.SocialSecurityDirectoryCode,
  6274. List_type_code: "301",
  6275. }
  6276. queryResult = append(queryResult, result)
  6277. }
  6278. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6279. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6280. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6281. for _, item := range queryResult {
  6282. 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)
  6283. //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)
  6284. }
  6285. }
  6286. func (c *HisApiController) Projectcheck() {
  6287. admin_user_id, _ := c.GetInt64("admin_user_id")
  6288. adminUser := c.GetAdminUserInfo()
  6289. var queryResult []QueryResult
  6290. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6291. for _, item := range projects {
  6292. result := QueryResult{
  6293. ID: item.ID,
  6294. Name: item.ProjectName,
  6295. Code: item.MedicalCode,
  6296. List_type_code: "201",
  6297. }
  6298. queryResult = append(queryResult, result)
  6299. }
  6300. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6301. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6302. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6303. for _, item := range queryResult {
  6304. 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)
  6305. }
  6306. }
  6307. //func (c *HisApiController)CancleDia(){
  6308. //
  6309. // id, _ := c.GetInt64("id")
  6310. // record_time := c.GetString("record_time")
  6311. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6312. //
  6313. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6314. //
  6315. // diagnosis_id := c.GetString("diagnosis")
  6316. // sick_type, _ := c.GetInt64("sick_type")
  6317. // reg_type, _ := c.GetInt64("p_type")
  6318. // begin_time := c.GetString("begin_time")
  6319. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6320. //
  6321. //
  6322. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6323. //
  6324. // fmt.Println(acct_used_flag)
  6325. //
  6326. //
  6327. // timeLayout := "2006-01-02"
  6328. // loc, _ := time.LoadLocation("Local")
  6329. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6330. // if err != nil {
  6331. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6332. // return
  6333. // }
  6334. // recordDateTime := theTime.Unix()
  6335. // adminUser := c.GetAdminUserInfo()
  6336. //
  6337. //
  6338. //
  6339. //
  6340. //
  6341. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6342. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6343. // var patientPrescription models.HisPrescriptionInfo
  6344. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6345. // if patientPrescription.ID == 0 {
  6346. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6347. // }
  6348. // //if patientPrescription.Do
  6349. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6350. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6351. //
  6352. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6353. //
  6354. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6355. //
  6356. // var config []*models.HisXtDiagnoseConfig
  6357. // for _, item := range diagnosis_ids {
  6358. // id, _ := strconv.ParseInt(item, 10, 64)
  6359. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6360. // config = append(config, &diagnosisConfig)
  6361. // }
  6362. //
  6363. // sickConfig, _ := service.FindSickById(sick_type)
  6364. //
  6365. //
  6366. // data := make(map[string]interface{})
  6367. // client := &http.Client{}
  6368. // data["psn_no"] = his.PsnNo
  6369. // data["mdtrt_id"] = his.Number
  6370. // data["doctor"] = roles.UserName
  6371. // data["department"] = department.Name
  6372. // data["org_name"] = miConfig.OrgName
  6373. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6374. // data["doctor_id"] = doctor_info.DoctorNumber
  6375. // data["new_doctor_name"] = doctor_info.UserName
  6376. // data["fixmedins_code"] = miConfig.Code
  6377. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6378. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6379. // data["secret_key"] = miConfig.SecretKey
  6380. // data["sick_code"] = sickConfig.CountryCode
  6381. // data["sick_name"] = sickConfig.ClassName
  6382. // data["url"] = miConfig.Url
  6383. // data["ak"] = miConfig.AccessKey
  6384. // data["begin_time"] = begin_time
  6385. // data["cainfo"] = miConfig.Cainfo
  6386. // data["is_vaild"] = "0"
  6387. //
  6388. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6389. // data["config"] = config
  6390. // bytesData, _ := json.Marshal(data)
  6391. //
  6392. // var req *http.Request
  6393. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6394. // resp, _ := client.Do(req)
  6395. // defer resp.Body.Close()
  6396. // body, ioErr := ioutil.ReadAll(resp.Body)
  6397. // if ioErr != nil {
  6398. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6400. // return
  6401. // }
  6402. // var respJSON map[string]interface{}
  6403. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6404. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6406. // return
  6407. // }
  6408. //
  6409. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6410. // userJSONBytes, _ := json.Marshal(respJSON)
  6411. // fmt.Println("log")
  6412. // fmt.Println(string(userJSONBytes))
  6413. //
  6414. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6415. // utils.ErrorLog("解析失败:%v", err)
  6416. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6417. // return
  6418. // }
  6419. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6420. // res2.Output = ressix10265.Output
  6421. // res2.ErrMsg = ressix10265.ErrMsg
  6422. // res2.Cainfo = ressix10265.Cainfo
  6423. // res2.WarnMsg = ressix10265.WarnMsg
  6424. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6425. // res2.Infcode = infocode
  6426. //
  6427. //}
  6428. func (c *HisApiController) Get4102() {
  6429. order_id, _ := c.GetInt64("order_id")
  6430. admin_user_id, _ := c.GetInt64("admin_user_id")
  6431. stas_type := c.GetString("stas_type")
  6432. order, _ := service.GetHisOrderByIDTwo(order_id)
  6433. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6434. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6435. var pp models.PublicParams
  6436. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6437. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6438. pp.FixmedinsName = miConfig.OrgName
  6439. pp.FixmedinsCode = miConfig.Code
  6440. pp.RequestUrl = miConfig.Url
  6441. pp.Cainfo = miConfig.Cainfo
  6442. pp.SecretKey = miConfig.SecretKey
  6443. pp.AccessKey = miConfig.AccessKey
  6444. pp.OpterName = curRoles.UserName
  6445. if miConfig.MdtrtareaAdmvs == "350500" {
  6446. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6447. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6448. saveLog(result, request, "4102", "清单确认")
  6449. var dat map[string]interface{}
  6450. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6451. fmt.Println(dat)
  6452. } else {
  6453. fmt.Println(err)
  6454. }
  6455. var empty ResultFourteen
  6456. userJSONBytes, _ := json.Marshal(dat)
  6457. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6458. utils.ErrorLog("解析失败:%v", err)
  6459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6460. return
  6461. }
  6462. if empty.Infcode == 0 {
  6463. c.ServeSuccessJSON(map[string]interface{}{
  6464. "msg": "确认成功",
  6465. })
  6466. return
  6467. }
  6468. } else {
  6469. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6470. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6471. result3, request3 := service.Jxyb4105(pp)
  6472. saveLog(result, request, "4102", "清单确认")
  6473. saveLog(result2, request2, "4103", "清单确认")
  6474. saveLog(result3, request3, "4105", "清单统计")
  6475. var dat map[string]interface{}
  6476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6477. fmt.Println(dat)
  6478. } else {
  6479. fmt.Println(err)
  6480. }
  6481. var empty ResultFourteen
  6482. userJSONBytes, _ := json.Marshal(dat)
  6483. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6484. utils.ErrorLog("解析失败:%v", err)
  6485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6486. return
  6487. }
  6488. if empty.Infcode == 0 {
  6489. c.ServeSuccessJSON(map[string]interface{}{
  6490. "msg": "确认成功",
  6491. })
  6492. return
  6493. }
  6494. }
  6495. }
  6496. // 对账权限查询
  6497. func (c *HisApiController) Get3260() {
  6498. admin_user_id, _ := c.GetInt64("admin_user_id")
  6499. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6500. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6501. var api string
  6502. var res models.JSResult3260
  6503. if miConfig.MdtrtareaAdmvs == "320830" {
  6504. api = miConfig.AppSecret + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6505. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6506. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6507. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6508. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6509. } else {
  6510. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6511. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6512. }
  6513. resp, requestErr := http.Get(api)
  6514. if requestErr != nil {
  6515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6516. return
  6517. }
  6518. body, ioErr := ioutil.ReadAll(resp.Body)
  6519. if ioErr != nil {
  6520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6522. return
  6523. }
  6524. var respJSON map[string]interface{}
  6525. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6528. return
  6529. }
  6530. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6531. result, _ := json.Marshal(respJSON)
  6532. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6533. utils.ErrorLog("解析失败:%v", err)
  6534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6535. return
  6536. }
  6537. if res.Infcode == "0" {
  6538. c.ServeSuccessJSON(map[string]interface{}{
  6539. "result": res.Output.Data,
  6540. })
  6541. } else {
  6542. c.ServeSuccessJSON(map[string]interface{}{
  6543. "failed_code": -10,
  6544. "msg": res.ErrMsg,
  6545. })
  6546. return
  6547. }
  6548. }
  6549. func (c *HisApiController) Get3261() {
  6550. admin_user_id, _ := c.GetInt64("admin_user_id")
  6551. //month := c.GetString("month")
  6552. startTime := c.GetString("start_time")
  6553. //endTime, _ := c.GetString("end_time")
  6554. times := strings.Split(startTime, "-")
  6555. stmt_mon := times[0] + times[1]
  6556. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6557. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6558. var api string
  6559. var res models.JSResult3261
  6560. //var res10265 Result5301For10265
  6561. if miConfig.MdtrtareaAdmvs == "320830" {
  6562. api = miConfig.AppSecret + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6563. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6564. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6565. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6566. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6567. } else {
  6568. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6569. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6570. }
  6571. resp, requestErr := http.Get(api)
  6572. if requestErr != nil {
  6573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6574. return
  6575. }
  6576. body, ioErr := ioutil.ReadAll(resp.Body)
  6577. if ioErr != nil {
  6578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6580. return
  6581. }
  6582. var respJSON map[string]interface{}
  6583. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6586. return
  6587. }
  6588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6589. result, _ := json.Marshal(respJSON)
  6590. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6591. utils.ErrorLog("解析失败:%v", err)
  6592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6593. return
  6594. }
  6595. if res.Infcode == "0" {
  6596. c.ServeSuccessJSON(map[string]interface{}{
  6597. "result": res.Output,
  6598. })
  6599. } else {
  6600. c.ServeSuccessJSON(map[string]interface{}{
  6601. "failed_code": -10,
  6602. "msg": res.ErrMsg,
  6603. })
  6604. return
  6605. }
  6606. }
  6607. type TempFun struct {
  6608. FundKey string
  6609. FundCode string
  6610. }
  6611. func (c *HisApiController) Get3262() {
  6612. admin_user_id, _ := c.GetInt64("admin_user_id")
  6613. startTime := c.GetString("start_time")
  6614. endTime := c.GetString("end_time")
  6615. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6616. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6617. //timeLayout := "2006-01-02"
  6618. //loc, _ := time.LoadLocation("Local")
  6619. //var theStartTIme int64
  6620. //if len(startTime) > 0 {
  6621. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6622. // if err != nil {
  6623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6624. // return
  6625. // }
  6626. // theStartTIme = theTime.Unix()
  6627. //}
  6628. //var theEndtTIme int64
  6629. //if len(endTime) > 0 {
  6630. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6631. // if err != nil {
  6632. // utils.ErrorLog(err.Error())
  6633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6634. // return
  6635. // }
  6636. // theEndtTIme = theTime.Unix()
  6637. //}
  6638. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6639. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6640. for _, team := range datas {
  6641. fmt.Println(team.PsnTime)
  6642. for _, team_two := range datas_two {
  6643. fmt.Println(team_two.PsnTime)
  6644. if team.FundKey == team_two.FundKey {
  6645. fmt.Println(team_two.PsnTime)
  6646. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6647. fmt.Println(team.PsnTime)
  6648. }
  6649. }
  6650. }
  6651. fmt.Println("1111")
  6652. fmt.Println(datas)
  6653. fmt.Println("1111")
  6654. var twos []models.FixMonRecDetailFileInTwo
  6655. for _, team := range datas {
  6656. var two models.FixMonRecDetailFileInTwo
  6657. two.MedType = team.MedType
  6658. two.Insutype = team.Insutype
  6659. two.PsnType = team.PsnType
  6660. two.MedType = team.MedType
  6661. two.FixBlngAdmdvs = "999999"
  6662. two.InsuAdmdvs = "555555"
  6663. two.PsnTime = team.PsnTime
  6664. two.PsnCnt = team.PsnCnt
  6665. two.FundKey = team.FundKey
  6666. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6667. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6668. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6669. two.MedfeeSumAmt = ms
  6670. two.InscpAmt = ia
  6671. two.FundPaySumAmt = fps
  6672. twos = append(twos, two)
  6673. }
  6674. //startTime := c.GetString("start_time")
  6675. //endTime, _ := c.GetString("end_time")
  6676. times := strings.Split(startTime, "-")
  6677. stmt_mon := times[0] + times[1]
  6678. var funs []models.FundDetail
  6679. for _, item := range datas {
  6680. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6681. funs = append(funs, fun...)
  6682. }
  6683. var funInfos []models.Fund
  6684. //for _, item := range funs {
  6685. // var rf []models.FundInfo
  6686. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6687. // for _, subitem := range rf {
  6688. // var fund models.Fund
  6689. // fund.FundCode = subitem.FundPayType
  6690. // fund.FundName = subitem.FundPayTypeName
  6691. // fund.FundAmt = subitem.FundPayAmt
  6692. // fund.FundKey = item.FundKey
  6693. // fund.InsuAdmdvs = "555555"
  6694. // fund.FixBlngAdmdvs = "999999"
  6695. // funInfos = append(funInfos, fund)
  6696. // }
  6697. //}
  6698. var tempFuns []TempFun
  6699. for _, funInfo := range funInfos {
  6700. var tempFun TempFun
  6701. tempFun.FundKey = funInfo.FundKey
  6702. tempFun.FundCode = funInfo.FundCode
  6703. tempFuns = append(tempFuns, tempFun)
  6704. }
  6705. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6706. fmt.Println(tempFuns)
  6707. var funInfosTwo []models.Fund
  6708. decimal.DivisionPrecision = 2
  6709. for _, item := range tempFuns {
  6710. var fund models.Fund
  6711. for _, subItem := range funInfos {
  6712. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6713. fund.FundKey = subItem.FundKey
  6714. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6715. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6716. fund.FundName = subItem.FundName
  6717. fund.FundCode = subItem.FundCode
  6718. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6719. }
  6720. }
  6721. funInfosTwo = append(funInfosTwo, fund)
  6722. }
  6723. fmt.Println("funInfosTwo")
  6724. fmt.Println(funInfosTwo)
  6725. var upld_btch string
  6726. var empty models.JSResultEmpty
  6727. data := make(map[string]interface{})
  6728. data["org_name"] = miConfig.OrgName
  6729. data["doctor"] = curRoles.UserName
  6730. data["doctor_name"] = curRoles.UserName
  6731. data["fixmedins_code"] = miConfig.Code
  6732. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6733. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6734. data["secret_key"] = miConfig.SecretKey
  6735. data["url"] = miConfig.Url
  6736. data["ak"] = miConfig.AccessKey
  6737. data["cainfo"] = miConfig.Cainfo
  6738. data["datas"] = twos
  6739. data["fund"] = funInfosTwo
  6740. fmt.Println(twos)
  6741. month := time.Unix(1557042972, 0).Format("1")
  6742. year := time.Now().Format("2006")
  6743. month = time.Now().Format("01")
  6744. day := time.Now().Format("02")
  6745. hour := time.Now().Format("15")
  6746. min := time.Now().Format("04")
  6747. sec := time.Now().Format("05")
  6748. fix_fill_date := year + month + day + hour + min + sec
  6749. data["fix_fill_dept"] = miConfig.OrgName
  6750. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6751. data["fix_fill_psn"] = curRoles.UserName
  6752. data["fix_fill_date"] = fix_fill_date
  6753. data["stmt_loc"] = "2"
  6754. data["setl_mon"] = stmt_mon
  6755. upld_btch = "0"
  6756. data["upld_btch"] = upld_btch
  6757. //fmt.Println(data)
  6758. client := &http.Client{}
  6759. bytesData, _ := json.Marshal(data)
  6760. var req *http.Request
  6761. if miConfig.MdtrtareaAdmvs == "320830" {
  6762. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3262", bytes.NewReader(bytesData))
  6763. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6764. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6765. } else {
  6766. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6767. }
  6768. resp, _ := client.Do(req)
  6769. defer resp.Body.Close()
  6770. body, ioErr := ioutil.ReadAll(resp.Body)
  6771. if ioErr != nil {
  6772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6774. }
  6775. var respJSON map[string]interface{}
  6776. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6779. }
  6780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6781. //fmt.Println(respJSON)
  6782. result, _ := json.Marshal(respJSON)
  6783. //fmt.Println(result)
  6784. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6785. utils.ErrorLog("解析失败:%v", err)
  6786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6787. }
  6788. if empty.Infcode != "0" {
  6789. c.ServeSuccessJSON(map[string]interface{}{
  6790. "failed_code": -10,
  6791. "msg": empty.ErrMsg,
  6792. })
  6793. return
  6794. } else {
  6795. c.ServeSuccessJSON(map[string]interface{}{
  6796. "msg": "上传成功",
  6797. })
  6798. return
  6799. }
  6800. }
  6801. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6802. newArr = make([]TempFun, 0)
  6803. for i := 0; i < len(arr); i++ {
  6804. repeat := false
  6805. for j := i + 1; j < len(arr); j++ {
  6806. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6807. repeat = true
  6808. break
  6809. }
  6810. }
  6811. if !repeat {
  6812. newArr = append(newArr, arr[i])
  6813. }
  6814. }
  6815. return
  6816. }
  6817. func (c *HisApiController) Get3263() {
  6818. admin_user_id, _ := c.GetInt64("admin_user_id")
  6819. startTime := c.GetString("start_time")
  6820. //endTime, _ := c.GetString("end_time")
  6821. times := strings.Split(startTime, "-")
  6822. setl_mon := times[0] + times[1]
  6823. upld_btch := "0"
  6824. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6825. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6826. var result3263 models.JSResult3263
  6827. data := make(map[string]interface{})
  6828. data["org_name"] = miConfig.OrgName
  6829. data["doctor"] = curRoles.UserName
  6830. data["doctor_name"] = curRoles.UserName
  6831. data["fixmedins_code"] = miConfig.Code
  6832. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6833. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6834. data["secret_key"] = miConfig.SecretKey
  6835. data["url"] = miConfig.Url
  6836. data["ak"] = miConfig.AccessKey
  6837. data["cainfo"] = miConfig.Cainfo
  6838. data["setl_mon"] = setl_mon
  6839. data["stmt_loc"] = "2"
  6840. data["upld_btch"] = upld_btch
  6841. client := &http.Client{}
  6842. bytesData, _ := json.Marshal(data)
  6843. var req *http.Request
  6844. if miConfig.MdtrtareaAdmvs == "320830" {
  6845. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6846. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6847. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6848. } else {
  6849. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6850. }
  6851. resp, _ := client.Do(req)
  6852. defer resp.Body.Close()
  6853. body, ioErr := ioutil.ReadAll(resp.Body)
  6854. if ioErr != nil {
  6855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6857. }
  6858. var respJSON map[string]interface{}
  6859. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6862. }
  6863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6864. fmt.Println(respJSON)
  6865. result, _ := json.Marshal(respJSON)
  6866. fmt.Println(result)
  6867. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6868. utils.ErrorLog("解析失败:%v", err)
  6869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6870. }
  6871. if result3263.Infcode != "0" {
  6872. c.ServeSuccessJSON(map[string]interface{}{
  6873. "failed_code": -10,
  6874. "msg": result3263.ErrMsg,
  6875. })
  6876. return
  6877. } else {
  6878. c.ServeSuccessJSON(map[string]interface{}{
  6879. "list": result3263.Output,
  6880. })
  6881. return
  6882. }
  6883. }
  6884. func (c *HisApiController) Get3264() {
  6885. admin_user_id, _ := c.GetInt64("admin_user_id")
  6886. startTime := c.GetString("start_time")
  6887. //endTime, _ := c.GetString("end_time")
  6888. times := strings.Split(startTime, "-")
  6889. setl_mon := times[0] + times[1]
  6890. upld_btch := "0"
  6891. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6892. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6893. //solidify_id := []
  6894. var result3263 models.JSResult3263
  6895. data := make(map[string]interface{})
  6896. data["org_name"] = miConfig.OrgName
  6897. data["doctor"] = curRoles.UserName
  6898. data["doctor_name"] = curRoles.UserName
  6899. data["fixmedins_code"] = miConfig.Code
  6900. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6901. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6902. data["secret_key"] = miConfig.SecretKey
  6903. data["url"] = miConfig.Url
  6904. data["ak"] = miConfig.AccessKey
  6905. data["cainfo"] = miConfig.Cainfo
  6906. data["setl_mon"] = setl_mon
  6907. data["stmt_loc"] = "2"
  6908. data["upld_btch"] = upld_btch
  6909. client := &http.Client{}
  6910. bytesData, _ := json.Marshal(data)
  6911. var req3263 *http.Request
  6912. if miConfig.MdtrtareaAdmvs == "320830" {
  6913. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6914. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6915. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6916. } else {
  6917. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6918. }
  6919. resp, _ := client.Do(req3263)
  6920. defer resp.Body.Close()
  6921. body, ioErr := ioutil.ReadAll(resp.Body)
  6922. if ioErr != nil {
  6923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6925. }
  6926. var respJSON3263 map[string]interface{}
  6927. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6930. }
  6931. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6932. fmt.Println(respJSON3263)
  6933. result, _ := json.Marshal(respJSON3263)
  6934. fmt.Println(result)
  6935. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6936. utils.ErrorLog("解析失败:%v", err)
  6937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6938. }
  6939. var ids []string
  6940. for _, item := range result3263.Output {
  6941. ids = append(ids, item.SolidifyID)
  6942. }
  6943. var empty models.JSResultEmpty
  6944. data2 := make(map[string]interface{})
  6945. data2["org_name"] = miConfig.OrgName
  6946. data2["doctor"] = curRoles.UserName
  6947. data2["doctor_name"] = curRoles.UserName
  6948. data2["fixmedins_code"] = miConfig.Code
  6949. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6950. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6951. data2["secret_key"] = miConfig.SecretKey
  6952. data2["url"] = miConfig.Url
  6953. data2["ak"] = miConfig.AccessKey
  6954. data2["cainfo"] = miConfig.Cainfo
  6955. data2["setl_mon"] = setl_mon
  6956. data2["stmt_loc"] = "2"
  6957. data2["upld_btch"] = upld_btch
  6958. data2["solidify_id"] = ids
  6959. client2 := &http.Client{}
  6960. bytesData2, _ := json.Marshal(data2)
  6961. var req *http.Request
  6962. if miConfig.MdtrtareaAdmvs == "320830" {
  6963. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3264", bytes.NewReader(bytesData))
  6964. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6965. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6966. } else {
  6967. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6968. }
  6969. resp2, _ := client2.Do(req)
  6970. defer resp.Body.Close()
  6971. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6972. if ioErr2 != nil {
  6973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6975. }
  6976. var respJSON map[string]interface{}
  6977. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6980. }
  6981. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6982. fmt.Println(respJSON)
  6983. result2, _ := json.Marshal(respJSON)
  6984. fmt.Println(result2)
  6985. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6986. utils.ErrorLog("解析失败:%v", err)
  6987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6988. }
  6989. if empty.Infcode != "0" {
  6990. c.ServeSuccessJSON(map[string]interface{}{
  6991. "failed_code": -10,
  6992. "msg": empty.ErrMsg,
  6993. })
  6994. return
  6995. } else {
  6996. c.ServeSuccessJSON(map[string]interface{}{
  6997. "msg": "",
  6998. })
  6999. return
  7000. }
  7001. }
  7002. func (c *HisApiController) Get3265() {
  7003. admin_user_id, _ := c.GetInt64("admin_user_id")
  7004. startTime := c.GetString("start_time")
  7005. //endTime, _ := c.GetString("end_time")
  7006. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7008. times := strings.Split(startTime, "-")
  7009. setl_mon := times[0] + times[1]
  7010. var upld_btch string
  7011. upld_btch = "0"
  7012. //var empty models.JSResultEmpty
  7013. var result3265 models.JSResult3264
  7014. var result3263 models.JSResult3263
  7015. data2 := make(map[string]interface{})
  7016. data2["org_name"] = miConfig.OrgName
  7017. data2["doctor"] = curRoles.UserName
  7018. data2["doctor_name"] = curRoles.UserName
  7019. data2["fixmedins_code"] = miConfig.Code
  7020. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7021. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7022. data2["secret_key"] = miConfig.SecretKey
  7023. data2["url"] = miConfig.Url
  7024. data2["ak"] = miConfig.AccessKey
  7025. data2["cainfo"] = miConfig.Cainfo
  7026. data2["setl_mon"] = setl_mon
  7027. data2["stmt_loc"] = "2"
  7028. data2["upld_btch"] = upld_btch
  7029. client2 := &http.Client{}
  7030. bytesData2, _ := json.Marshal(data2)
  7031. var req3263 *http.Request
  7032. if miConfig.MdtrtareaAdmvs == "320830" {
  7033. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData2))
  7034. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7035. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  7036. } else {
  7037. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  7038. }
  7039. resp2, _ := client2.Do(req3263)
  7040. defer resp2.Body.Close()
  7041. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7042. if ioErr2 != nil {
  7043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7045. }
  7046. var respJSON3263 map[string]interface{}
  7047. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7050. }
  7051. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7052. fmt.Println(respJSON3263)
  7053. result2, _ := json.Marshal(respJSON3263)
  7054. fmt.Println(result2)
  7055. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7056. utils.ErrorLog("解析失败:%v", err)
  7057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7058. }
  7059. var ids []string
  7060. for _, item := range result3263.Output {
  7061. ids = append(ids, item.SolidifyID)
  7062. }
  7063. data := make(map[string]interface{})
  7064. data["org_name"] = miConfig.OrgName
  7065. data["doctor"] = curRoles.UserName
  7066. data["doctor_name"] = curRoles.UserName
  7067. data["fixmedins_code"] = miConfig.Code
  7068. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7069. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7070. data["secret_key"] = miConfig.SecretKey
  7071. data["url"] = miConfig.Url
  7072. data["ak"] = miConfig.AccessKey
  7073. data["cainfo"] = miConfig.Cainfo
  7074. data["setl_mon"] = setl_mon
  7075. data["solidify_id"] = ids
  7076. month := time.Unix(1557042972, 0).Format("1")
  7077. year := time.Now().Format("2006")
  7078. month = time.Now().Format("01")
  7079. day := time.Now().Format("02")
  7080. hour := time.Now().Format("15")
  7081. min := time.Now().Format("04")
  7082. sec := time.Now().Format("05")
  7083. fix_fill_date := year + month + day + hour + min + sec
  7084. data["fix_fill_dept"] = miConfig.OrgName
  7085. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7086. data["fix_fill_psn"] = curRoles.UserName
  7087. data["fix_fill_date"] = fix_fill_date
  7088. data["stmt_loc"] = "2"
  7089. data["upld_btch"] = upld_btch
  7090. client := &http.Client{}
  7091. bytesData, _ := json.Marshal(data)
  7092. var req *http.Request
  7093. if miConfig.MdtrtareaAdmvs == "320830" {
  7094. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3265", bytes.NewReader(bytesData2))
  7095. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7096. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  7097. } else {
  7098. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  7099. }
  7100. resp, _ := client.Do(req)
  7101. defer resp.Body.Close()
  7102. body, ioErr := ioutil.ReadAll(resp.Body)
  7103. if ioErr != nil {
  7104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7106. }
  7107. var respJSON map[string]interface{}
  7108. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7111. }
  7112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7113. fmt.Println(respJSON)
  7114. result, _ := json.Marshal(respJSON)
  7115. fmt.Println(result)
  7116. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7117. utils.ErrorLog("解析失败:%v", err)
  7118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7119. }
  7120. if result3265.Infcode != "0" {
  7121. c.ServeSuccessJSON(map[string]interface{}{
  7122. "failed_code": -10,
  7123. "msg": result3265.ErrMsg,
  7124. })
  7125. return
  7126. } else {
  7127. c.ServeSuccessJSON(map[string]interface{}{
  7128. "info": result3265.Output,
  7129. })
  7130. return
  7131. }
  7132. }
  7133. func (c *HisApiController) Get3266() {
  7134. admin_user_id, _ := c.GetInt64("admin_user_id")
  7135. startTime := c.GetString("start_time")
  7136. //endTime, _ := c.GetString("end_time")
  7137. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7138. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7139. times := strings.Split(startTime, "-")
  7140. stmt_mon := times[0] + times[1]
  7141. var upld_btch string
  7142. //var empty models.JSResultEmpty
  7143. var result3265 models.JSResult3264
  7144. data := make(map[string]interface{})
  7145. data["org_name"] = miConfig.OrgName
  7146. data["doctor"] = curRoles.UserName
  7147. data["doctor_name"] = curRoles.UserName
  7148. data["fixmedins_code"] = miConfig.Code
  7149. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7150. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7151. data["secret_key"] = miConfig.SecretKey
  7152. data["url"] = miConfig.Url
  7153. data["ak"] = miConfig.AccessKey
  7154. data["cainfo"] = miConfig.Cainfo
  7155. data["setl_mon"] = stmt_mon
  7156. month := time.Unix(1557042972, 0).Format("1")
  7157. year := time.Now().Format("2006")
  7158. month = time.Now().Format("01")
  7159. day := time.Now().Format("02")
  7160. hour := time.Now().Format("15")
  7161. min := time.Now().Format("04")
  7162. sec := time.Now().Format("05")
  7163. fix_fill_date := year + month + day + hour + min + sec
  7164. data["fix_fill_dept"] = miConfig.OrgName
  7165. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7166. data["fix_fill_psn"] = curRoles.UserName
  7167. data["fix_fill_date"] = fix_fill_date
  7168. data["stmt_loc"] = "2"
  7169. upld_btch = "0"
  7170. data["upld_btch"] = upld_btch
  7171. client := &http.Client{}
  7172. bytesData, _ := json.Marshal(data)
  7173. var req *http.Request
  7174. if miConfig.MdtrtareaAdmvs == "320830" {
  7175. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3266", bytes.NewReader(bytesData))
  7176. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7177. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7178. } else {
  7179. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7180. }
  7181. resp, _ := client.Do(req)
  7182. defer resp.Body.Close()
  7183. body, ioErr := ioutil.ReadAll(resp.Body)
  7184. if ioErr != nil {
  7185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7187. }
  7188. var respJSON map[string]interface{}
  7189. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7192. }
  7193. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7194. fmt.Println(respJSON)
  7195. result, _ := json.Marshal(respJSON)
  7196. fmt.Println(result)
  7197. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7198. utils.ErrorLog("解析失败:%v", err)
  7199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7200. }
  7201. if result3265.Infcode != "0" {
  7202. c.ServeSuccessJSON(map[string]interface{}{
  7203. "failed_code": -10,
  7204. "msg": result3265.ErrMsg,
  7205. })
  7206. return
  7207. } else {
  7208. c.ServeSuccessJSON(map[string]interface{}{
  7209. "info": result3265.Output,
  7210. })
  7211. return
  7212. }
  7213. }
  7214. func (c *HisApiController) Get3267() {
  7215. admin_user_id, _ := c.GetInt64("admin_user_id")
  7216. startTime := c.GetString("start_time")
  7217. //endTime, _ := c.GetString("end_time")
  7218. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7219. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7220. times := strings.Split(startTime, "-")
  7221. setl_mon := times[0] + times[1]
  7222. var upld_btch string
  7223. //var empty models.JSResultEmpty
  7224. var result3265 models.JSResult3264
  7225. upld_btch = "0"
  7226. data := make(map[string]interface{})
  7227. data["org_name"] = miConfig.OrgName
  7228. data["doctor"] = curRoles.UserName
  7229. data["doctor_name"] = curRoles.UserName
  7230. data["fixmedins_code"] = miConfig.Code
  7231. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7232. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7233. data["secret_key"] = miConfig.SecretKey
  7234. data["url"] = miConfig.Url
  7235. data["ak"] = miConfig.AccessKey
  7236. data["cainfo"] = miConfig.Cainfo
  7237. data["setl_mon"] = setl_mon
  7238. data["stmt_loc"] = "2"
  7239. data["upld_btch"] = upld_btch
  7240. client := &http.Client{}
  7241. bytesData, _ := json.Marshal(data)
  7242. var req *http.Request
  7243. if miConfig.MdtrtareaAdmvs == "320830" {
  7244. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3267", bytes.NewReader(bytesData))
  7245. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7246. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7247. } else {
  7248. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7249. }
  7250. resp, _ := client.Do(req)
  7251. defer resp.Body.Close()
  7252. body, ioErr := ioutil.ReadAll(resp.Body)
  7253. if ioErr != nil {
  7254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7256. }
  7257. var respJSON map[string]interface{}
  7258. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7261. }
  7262. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7263. fmt.Println(respJSON)
  7264. result, _ := json.Marshal(respJSON)
  7265. fmt.Println(result)
  7266. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7267. utils.ErrorLog("解析失败:%v", err)
  7268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7269. }
  7270. if result3265.Infcode != "0" {
  7271. c.ServeSuccessJSON(map[string]interface{}{
  7272. "failed_code": -10,
  7273. "msg": result3265.ErrMsg,
  7274. })
  7275. return
  7276. } else {
  7277. c.ServeSuccessJSON(map[string]interface{}{
  7278. "info": result3265.Output.Data,
  7279. })
  7280. return
  7281. }
  7282. }
  7283. func (c *HisApiController) Get3268() {
  7284. admin_user_id, _ := c.GetInt64("admin_user_id")
  7285. startTime := c.GetString("start_time")
  7286. endTime := c.GetString("end_time")
  7287. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7288. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7289. times := strings.Split(startTime, "-")
  7290. setl_mon := times[0] + times[1]
  7291. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7292. var twos []models.FixMonRecDetailFileInTwo
  7293. var funs []models.FundDetail
  7294. for _, item := range datas {
  7295. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7296. funs = append(funs, fun...)
  7297. }
  7298. var funInfos []models.Fund
  7299. //for _, item := range funs {
  7300. // var rf []models.FundInfo
  7301. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7302. // for _, subitem := range rf {
  7303. // var fund models.Fund
  7304. // fund.FundCode = subitem.FundPayType
  7305. // fund.FundName = subitem.FundPayTypeName
  7306. // fund.FundAmt = subitem.FundPayAmt
  7307. // fund.FundKey = item.FundKey
  7308. // fund.InsuAdmdvs = "555555"
  7309. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7310. // funInfos = append(funInfos, fund)
  7311. // }
  7312. //}
  7313. for _, team := range datas {
  7314. var two models.FixMonRecDetailFileInTwo
  7315. two.SetlDate = time.Now().Format("2006-01-02")
  7316. two.MedType = team.MedType
  7317. two.Insutype = team.Insutype
  7318. two.PsnType = team.PsnType
  7319. two.MedType = team.MedType
  7320. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7321. two.InsuAdmdvs = team.InsuAdmdvs
  7322. two.PsnTime = team.PsnTime
  7323. two.PsnCnt = team.PsnCnt
  7324. two.FundKey = team.FundKey
  7325. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7326. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7327. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7328. two.MedfeeSumAmt = ms
  7329. two.InscpAmt = ia
  7330. two.FundPaySumAmt = fps
  7331. twos = append(twos, two)
  7332. }
  7333. var upld_btch string
  7334. upld_btch = "0"
  7335. var empty models.JSResultEmpty
  7336. data := make(map[string]interface{})
  7337. data["org_name"] = miConfig.OrgName
  7338. data["doctor"] = curRoles.UserName
  7339. data["doctor_name"] = curRoles.UserName
  7340. data["fixmedins_code"] = miConfig.Code
  7341. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7342. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7343. data["secret_key"] = miConfig.SecretKey
  7344. data["url"] = miConfig.Url
  7345. data["ak"] = miConfig.AccessKey
  7346. data["cainfo"] = miConfig.Cainfo
  7347. data["datas"] = twos
  7348. data["fund"] = funInfos
  7349. data["setl_mon"] = setl_mon
  7350. month := time.Unix(1557042972, 0).Format("1")
  7351. year := time.Now().Format("2006")
  7352. month = time.Now().Format("01")
  7353. day := time.Now().Format("02")
  7354. hour := time.Now().Format("15")
  7355. min := time.Now().Format("04")
  7356. sec := time.Now().Format("05")
  7357. fix_fill_date := year + month + day + hour + min + sec
  7358. data["fix_fill_dept"] = miConfig.OrgName
  7359. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7360. data["fix_fill_psn"] = curRoles.UserName
  7361. data["fix_fill_date"] = fix_fill_date
  7362. data["stmt_loc"] = "2"
  7363. data["upld_btch"] = upld_btch
  7364. client := &http.Client{}
  7365. bytesData, _ := json.Marshal(data)
  7366. var req *http.Request
  7367. if miConfig.MdtrtareaAdmvs == "320830" {
  7368. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3268", bytes.NewReader(bytesData))
  7369. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7370. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7371. } else {
  7372. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7373. }
  7374. resp, _ := client.Do(req)
  7375. defer resp.Body.Close()
  7376. body, ioErr := ioutil.ReadAll(resp.Body)
  7377. if ioErr != nil {
  7378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7380. }
  7381. var respJSON map[string]interface{}
  7382. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7385. }
  7386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7387. fmt.Println(respJSON)
  7388. result, _ := json.Marshal(respJSON)
  7389. fmt.Println(result)
  7390. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7391. utils.ErrorLog("解析失败:%v", err)
  7392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7393. }
  7394. if empty.Infcode != "0" {
  7395. c.ServeSuccessJSON(map[string]interface{}{
  7396. "failed_code": -10,
  7397. "msg": empty.ErrMsg,
  7398. })
  7399. return
  7400. } else {
  7401. c.ServeSuccessJSON(map[string]interface{}{
  7402. "msg": "上传成功",
  7403. })
  7404. return
  7405. }
  7406. }
  7407. func (c *HisApiController) Get3269() {
  7408. admin_user_id, _ := c.GetInt64("admin_user_id")
  7409. startTime := c.GetString("start_time")
  7410. //endTime, _ := c.GetString("end_time")
  7411. times := strings.Split(startTime, "-")
  7412. setl_mon := times[0] + times[1]
  7413. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7414. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7415. var result3263 models.JSResult3263
  7416. data := make(map[string]interface{})
  7417. data["org_name"] = miConfig.OrgName
  7418. data["doctor"] = curRoles.UserName
  7419. data["doctor_name"] = curRoles.UserName
  7420. data["fixmedins_code"] = miConfig.Code
  7421. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7422. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7423. data["secret_key"] = miConfig.SecretKey
  7424. data["url"] = miConfig.Url
  7425. data["ak"] = miConfig.AccessKey
  7426. data["cainfo"] = miConfig.Cainfo
  7427. data["setl_mon"] = setl_mon
  7428. data["stmt_loc"] = "2"
  7429. client := &http.Client{}
  7430. bytesData, _ := json.Marshal(data)
  7431. var req *http.Request
  7432. if miConfig.MdtrtareaAdmvs == "320830" {
  7433. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData))
  7434. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7435. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7436. } else {
  7437. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7438. }
  7439. resp, _ := client.Do(req)
  7440. defer resp.Body.Close()
  7441. body, ioErr := ioutil.ReadAll(resp.Body)
  7442. if ioErr != nil {
  7443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7445. }
  7446. var respJSON map[string]interface{}
  7447. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7450. }
  7451. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7452. fmt.Println(respJSON)
  7453. result, _ := json.Marshal(respJSON)
  7454. fmt.Println(result)
  7455. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7456. utils.ErrorLog("解析失败:%v", err)
  7457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7458. }
  7459. if result3263.Infcode != "0" {
  7460. c.ServeSuccessJSON(map[string]interface{}{
  7461. "failed_code": -10,
  7462. "msg": result3263.ErrMsg,
  7463. })
  7464. return
  7465. } else {
  7466. c.ServeSuccessJSON(map[string]interface{}{
  7467. "msg": "上传成功",
  7468. })
  7469. return
  7470. }
  7471. }
  7472. func (c *HisApiController) Get3270() {
  7473. admin_user_id, _ := c.GetInt64("admin_user_id")
  7474. startTime := c.GetString("start_time")
  7475. //endTime, _ := c.GetString("end_time")
  7476. times := strings.Split(startTime, "-")
  7477. setl_mon := times[0] + times[1]
  7478. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7479. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7480. var result3263 models.JSResult3263
  7481. data2 := make(map[string]interface{})
  7482. data2["org_name"] = miConfig.OrgName
  7483. data2["doctor"] = curRoles.UserName
  7484. data2["doctor_name"] = curRoles.UserName
  7485. data2["fixmedins_code"] = miConfig.Code
  7486. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7487. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7488. data2["secret_key"] = miConfig.SecretKey
  7489. data2["url"] = miConfig.Url
  7490. data2["ak"] = miConfig.AccessKey
  7491. data2["cainfo"] = miConfig.Cainfo
  7492. data2["setl_mon"] = setl_mon
  7493. data2["stmt_loc"] = "2"
  7494. client2 := &http.Client{}
  7495. bytesData2, _ := json.Marshal(data2)
  7496. var req3263 *http.Request
  7497. if miConfig.MdtrtareaAdmvs == "320830" {
  7498. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7499. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7500. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7501. } else {
  7502. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7503. }
  7504. resp2, _ := client2.Do(req3263)
  7505. defer resp2.Body.Close()
  7506. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7507. if ioErr2 != nil {
  7508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7510. }
  7511. var respJSON3263 map[string]interface{}
  7512. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7515. }
  7516. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7517. fmt.Println(respJSON3263)
  7518. result2, _ := json.Marshal(respJSON3263)
  7519. fmt.Println(result2)
  7520. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7521. utils.ErrorLog("解析失败:%v", err)
  7522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7523. }
  7524. var ids []string
  7525. for _, item := range result3263.Output {
  7526. ids = append(ids, item.SolidifyID)
  7527. }
  7528. var result3264 models.JSResult3264
  7529. data := make(map[string]interface{})
  7530. data["org_name"] = miConfig.OrgName
  7531. data["doctor"] = curRoles.UserName
  7532. data["doctor_name"] = curRoles.UserName
  7533. data["fixmedins_code"] = miConfig.Code
  7534. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7535. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7536. data["secret_key"] = miConfig.SecretKey
  7537. data["url"] = miConfig.Url
  7538. data["ak"] = miConfig.AccessKey
  7539. data["cainfo"] = miConfig.Cainfo
  7540. data["setl_mon"] = setl_mon
  7541. data["stmt_loc"] = "2"
  7542. data["solidify_id"] = ids
  7543. client := &http.Client{}
  7544. bytesData, _ := json.Marshal(data)
  7545. var req *http.Request
  7546. if miConfig.MdtrtareaAdmvs == "320830" {
  7547. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3270", bytes.NewReader(bytesData))
  7548. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7549. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7550. } else {
  7551. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7552. }
  7553. resp, _ := client.Do(req)
  7554. defer resp.Body.Close()
  7555. body, ioErr := ioutil.ReadAll(resp.Body)
  7556. if ioErr != nil {
  7557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7559. }
  7560. var respJSON map[string]interface{}
  7561. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7564. }
  7565. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7566. fmt.Println(respJSON)
  7567. result, _ := json.Marshal(respJSON)
  7568. fmt.Println(result)
  7569. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7570. utils.ErrorLog("解析失败:%v", err)
  7571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7572. }
  7573. if result3264.Infcode != "0" {
  7574. c.ServeSuccessJSON(map[string]interface{}{
  7575. "failed_code": -10,
  7576. "msg": result3264.ErrMsg,
  7577. })
  7578. return
  7579. } else {
  7580. c.ServeSuccessJSON(map[string]interface{}{
  7581. "info": result3264.Output,
  7582. })
  7583. return
  7584. }
  7585. }
  7586. func (c *HisApiController) Get3271() {
  7587. admin_user_id, _ := c.GetInt64("admin_user_id")
  7588. startTime := c.GetString("start_time")
  7589. //endTime, _ := c.GetString("end_time")
  7590. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7591. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7592. times := strings.Split(startTime, "-")
  7593. setl_mon := times[0] + times[1]
  7594. //var empty models.JSResultEmpty
  7595. var result3265 models.JSResult3264
  7596. var result3263 models.JSResult3263
  7597. data2 := make(map[string]interface{})
  7598. data2["org_name"] = miConfig.OrgName
  7599. data2["doctor"] = curRoles.UserName
  7600. data2["doctor_name"] = curRoles.UserName
  7601. data2["fixmedins_code"] = miConfig.Code
  7602. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7603. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7604. data2["secret_key"] = miConfig.SecretKey
  7605. data2["url"] = miConfig.Url
  7606. data2["ak"] = miConfig.AccessKey
  7607. data2["cainfo"] = miConfig.Cainfo
  7608. data2["setl_mon"] = setl_mon
  7609. data2["stmt_loc"] = "2"
  7610. client2 := &http.Client{}
  7611. bytesData2, _ := json.Marshal(data2)
  7612. var req3263 *http.Request
  7613. if miConfig.MdtrtareaAdmvs == "320830" {
  7614. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7615. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7616. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7617. } else {
  7618. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7619. }
  7620. resp2, _ := client2.Do(req3263)
  7621. defer resp2.Body.Close()
  7622. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7623. if ioErr2 != nil {
  7624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7626. }
  7627. var respJSON3263 map[string]interface{}
  7628. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7631. }
  7632. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7633. fmt.Println(respJSON3263)
  7634. result2, _ := json.Marshal(respJSON3263)
  7635. fmt.Println(result2)
  7636. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7637. utils.ErrorLog("解析失败:%v", err)
  7638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7639. }
  7640. var ids []string
  7641. for _, item := range result3263.Output {
  7642. ids = append(ids, item.SolidifyID)
  7643. }
  7644. data := make(map[string]interface{})
  7645. data["org_name"] = miConfig.OrgName
  7646. data["doctor"] = curRoles.UserName
  7647. data["doctor_name"] = curRoles.UserName
  7648. data["fixmedins_code"] = miConfig.Code
  7649. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7650. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7651. data["secret_key"] = miConfig.SecretKey
  7652. data["url"] = miConfig.Url
  7653. data["ak"] = miConfig.AccessKey
  7654. data["cainfo"] = miConfig.Cainfo
  7655. data["setl_mon"] = setl_mon
  7656. data["solidify_id"] = ids
  7657. month := time.Unix(1557042972, 0).Format("1")
  7658. year := time.Now().Format("2006")
  7659. month = time.Now().Format("01")
  7660. day := time.Now().Format("02")
  7661. hour := time.Now().Format("15")
  7662. min := time.Now().Format("04")
  7663. sec := time.Now().Format("05")
  7664. fix_fill_date := year + month + day + hour + min + sec
  7665. data["fix_fill_dept"] = miConfig.OrgName
  7666. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7667. data["fix_fill_psn"] = curRoles.UserName
  7668. data["fix_fill_date"] = fix_fill_date
  7669. data["stmt_loc"] = "2"
  7670. client := &http.Client{}
  7671. bytesData, _ := json.Marshal(data)
  7672. var req *http.Request
  7673. if miConfig.MdtrtareaAdmvs == "320830" {
  7674. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3271", bytes.NewReader(bytesData2))
  7675. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7676. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7677. } else {
  7678. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7679. }
  7680. resp, _ := client.Do(req)
  7681. defer resp.Body.Close()
  7682. body, ioErr := ioutil.ReadAll(resp.Body)
  7683. if ioErr != nil {
  7684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7686. }
  7687. var respJSON map[string]interface{}
  7688. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7691. }
  7692. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7693. fmt.Println(respJSON)
  7694. result, _ := json.Marshal(respJSON)
  7695. fmt.Println(result)
  7696. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7697. utils.ErrorLog("解析失败:%v", err)
  7698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7699. }
  7700. if result3265.Infcode != "0" {
  7701. c.ServeSuccessJSON(map[string]interface{}{
  7702. "failed_code": -10,
  7703. "msg": result3265.ErrMsg,
  7704. })
  7705. return
  7706. } else {
  7707. c.ServeSuccessJSON(map[string]interface{}{
  7708. "info": result3265.Output.Data,
  7709. })
  7710. return
  7711. }
  7712. }
  7713. func (c *HisApiController) Get3272() {
  7714. admin_user_id, _ := c.GetInt64("admin_user_id")
  7715. startTime := c.GetString("start_time")
  7716. //endTime, _ := c.GetString("end_time")
  7717. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7718. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7719. times := strings.Split(startTime, "-")
  7720. setl_mon := times[0] + times[1]
  7721. var upld_btch string
  7722. //var empty models.JSResultEmpty
  7723. var result3265 models.JSResult3264
  7724. data := make(map[string]interface{})
  7725. data["org_name"] = miConfig.OrgName
  7726. data["doctor"] = curRoles.UserName
  7727. data["doctor_name"] = curRoles.UserName
  7728. data["fixmedins_code"] = miConfig.Code
  7729. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7730. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7731. data["secret_key"] = miConfig.SecretKey
  7732. data["url"] = miConfig.Url
  7733. data["ak"] = miConfig.AccessKey
  7734. data["cainfo"] = miConfig.Cainfo
  7735. data["setl_mon"] = setl_mon
  7736. month := time.Unix(1557042972, 0).Format("1")
  7737. year := time.Now().Format("2006")
  7738. month = time.Now().Format("01")
  7739. day := time.Now().Format("02")
  7740. hour := time.Now().Format("15")
  7741. min := time.Now().Format("04")
  7742. sec := time.Now().Format("05")
  7743. fix_fill_date := year + month + day + hour + min + sec
  7744. data["fix_fill_dept"] = miConfig.OrgName
  7745. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7746. data["fix_fill_psn"] = curRoles.UserName
  7747. data["fix_fill_date"] = fix_fill_date
  7748. data["stmt_loc"] = "2"
  7749. data["upld_btch"] = upld_btch
  7750. client := &http.Client{}
  7751. bytesData, _ := json.Marshal(data)
  7752. var req *http.Request
  7753. if miConfig.MdtrtareaAdmvs == "320830" {
  7754. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3272", bytes.NewReader(bytesData))
  7755. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7756. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7757. } else {
  7758. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7759. }
  7760. resp, _ := client.Do(req)
  7761. defer resp.Body.Close()
  7762. body, ioErr := ioutil.ReadAll(resp.Body)
  7763. if ioErr != nil {
  7764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7766. }
  7767. var respJSON map[string]interface{}
  7768. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7771. }
  7772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7773. fmt.Println(respJSON)
  7774. result, _ := json.Marshal(respJSON)
  7775. fmt.Println(result)
  7776. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7777. utils.ErrorLog("解析失败:%v", err)
  7778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7779. }
  7780. if result3265.Infcode != "0" {
  7781. c.ServeSuccessJSON(map[string]interface{}{
  7782. "failed_code": -10,
  7783. "msg": result3265.ErrMsg,
  7784. })
  7785. return
  7786. } else {
  7787. c.ServeSuccessJSON(map[string]interface{}{
  7788. "info": result3265.Output,
  7789. })
  7790. return
  7791. }
  7792. }
  7793. func (c *HisApiController) Get3273() {
  7794. admin_user_id, _ := c.GetInt64("admin_user_id")
  7795. startTime := c.GetString("start_time")
  7796. //endTime, _ := c.GetString("end_time")
  7797. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7798. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7799. times := strings.Split(startTime, "-")
  7800. setl_mon := times[0] + times[1]
  7801. var result3265 models.JSResult3264
  7802. data := make(map[string]interface{})
  7803. data["org_name"] = miConfig.OrgName
  7804. data["doctor"] = curRoles.UserName
  7805. data["doctor_name"] = curRoles.UserName
  7806. data["fixmedins_code"] = miConfig.Code
  7807. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7808. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7809. data["secret_key"] = miConfig.SecretKey
  7810. data["url"] = miConfig.Url
  7811. data["ak"] = miConfig.AccessKey
  7812. data["cainfo"] = miConfig.Cainfo
  7813. data["setl_mon"] = setl_mon
  7814. data["stmt_loc"] = "2"
  7815. client := &http.Client{}
  7816. bytesData, _ := json.Marshal(data)
  7817. var req *http.Request
  7818. if miConfig.MdtrtareaAdmvs == "320921" {
  7819. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7820. } else {
  7821. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7822. }
  7823. resp, _ := client.Do(req)
  7824. defer resp.Body.Close()
  7825. body, ioErr := ioutil.ReadAll(resp.Body)
  7826. if ioErr != nil {
  7827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7829. }
  7830. var respJSON map[string]interface{}
  7831. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7834. }
  7835. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7836. fmt.Println(respJSON)
  7837. result, _ := json.Marshal(respJSON)
  7838. fmt.Println(result)
  7839. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7840. utils.ErrorLog("解析失败:%v", err)
  7841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7842. }
  7843. if result3265.Infcode != "0" {
  7844. c.ServeSuccessJSON(map[string]interface{}{
  7845. "failed_code": -10,
  7846. "msg": result3265.ErrMsg,
  7847. })
  7848. return
  7849. } else {
  7850. c.ServeSuccessJSON(map[string]interface{}{
  7851. "info": result3265.Output.Data,
  7852. })
  7853. return
  7854. }
  7855. }
  7856. func (c *HisApiController) Get3274() {
  7857. //if miConfig.MdtrtareaAdmvs == "320921" {
  7858. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7859. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7860. // "&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
  7861. //
  7862. //} else {
  7863. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7864. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7865. // "&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
  7866. //
  7867. //}
  7868. }
  7869. func (c *HisApiController) Get3275() {
  7870. //if miConfig.MdtrtareaAdmvs == "320921" {
  7871. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7872. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7873. // "&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
  7874. //
  7875. //} else {
  7876. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7877. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7878. // "&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
  7879. //
  7880. //}
  7881. }
  7882. func (c *HisApiController) Get3276() {
  7883. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7884. //month := c.GetString("month")
  7885. //
  7886. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7887. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7888. //var api string
  7889. //var res Result5301
  7890. //
  7891. //if miConfig.MdtrtareaAdmvs == "320921" {
  7892. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7893. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7894. //} else {
  7895. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7896. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7897. //}
  7898. //
  7899. //resp, requestErr := http.Get(api)
  7900. //if requestErr != nil {
  7901. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7902. // return
  7903. //}
  7904. //
  7905. //body, ioErr := ioutil.ReadAll(resp.Body)
  7906. //if ioErr != nil {
  7907. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7908. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7909. // return
  7910. //}
  7911. //var respJSON map[string]interface{}
  7912. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7913. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7915. // return
  7916. //}
  7917. //
  7918. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7919. //result, _ := json.Marshal(respJSON)
  7920. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7921. // utils.ErrorLog("解析失败:%v", err)
  7922. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7923. // return
  7924. //}
  7925. }
  7926. func (c *HisApiController) Get3277() {
  7927. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7928. //month := c.GetString("month")
  7929. //
  7930. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7931. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7932. //var api string
  7933. //var res Result5301
  7934. //
  7935. //if miConfig.MdtrtareaAdmvs == "320921" {
  7936. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7937. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7938. //} else {
  7939. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7940. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7941. //}
  7942. //
  7943. //resp, requestErr := http.Get(api)
  7944. //if requestErr != nil {
  7945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7946. // return
  7947. //}
  7948. //
  7949. //body, ioErr := ioutil.ReadAll(resp.Body)
  7950. //if ioErr != nil {
  7951. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7952. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7953. // return
  7954. //}
  7955. //var respJSON map[string]interface{}
  7956. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7957. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7958. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7959. // return
  7960. //}
  7961. //
  7962. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7963. //result, _ := json.Marshal(respJSON)
  7964. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7965. // utils.ErrorLog("解析失败:%v", err)
  7966. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7967. // return
  7968. //}
  7969. }
  7970. func (c *HisApiController) GetCFYLJG001() {
  7971. admin_user_id, _ := c.GetInt64("admin_user_id")
  7972. patient_id, _ := c.GetInt64("patient_id")
  7973. his_patient_id, _ := c.GetInt64("his_patient_id")
  7974. record_time := c.GetString("record_time")
  7975. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7976. psn, _ := service.GetPsnByPatientId(patient_id)
  7977. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7978. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7979. var cFYLJG001 models.CFYLJG001
  7980. timeLayout := "2006-01-02"
  7981. loc, _ := time.LoadLocation("Local")
  7982. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7983. if err != nil {
  7984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7985. return
  7986. }
  7987. recordDateTime := theTime.Unix()
  7988. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7989. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7990. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7991. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7992. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7993. for _, item := range prescriptions {
  7994. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7995. if his.IdCardType == 1 {
  7996. bas := strings.Split(psn.CardInfo, "|")
  7997. basNumber := bas[1]
  7998. fmt.Println(basNumber)
  7999. card_sn := bas[3]
  8000. card_no := bas[2]
  8001. cFYLJG001.MdtrtCertType = "03"
  8002. cFYLJG001.CardSn = card_sn
  8003. cFYLJG001.MdtrtCertNo = card_no
  8004. cFYLJG001.EcToken = ""
  8005. cFYLJG001.AuthNo = ""
  8006. } else if his.IdCardType == 2 {
  8007. cFYLJG001.MdtrtCertType = "02"
  8008. cFYLJG001.CardSn = ""
  8009. cFYLJG001.MdtrtCertNo = his.IdCardNo
  8010. cFYLJG001.EcToken = ""
  8011. cFYLJG001.AuthNo = ""
  8012. } else if his.IdCardType == 4 {
  8013. cFYLJG001.MdtrtCertType = "01"
  8014. cFYLJG001.CardSn = ""
  8015. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  8016. cFYLJG001.EcToken = psn.VerifyNumber
  8017. cFYLJG001.AuthNo = ""
  8018. }
  8019. cFYLJG001.BizTypeCode = "01"
  8020. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  8021. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  8022. cFYLJG001.RxTypeCode = "1"
  8023. tempTime := time.Unix(item.PreTime, 0)
  8024. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  8025. cFYLJG001.PrscTime = timeFormatOne
  8026. var count float64
  8027. if item.Type == 1 {
  8028. for _, sumItem := range item.HisDoctorAdviceInfo {
  8029. count = count + sumItem.PrescribingNumber
  8030. }
  8031. }
  8032. cFYLJG001.RxDrugCnt = count
  8033. cFYLJG001.ValiDays = "2"
  8034. ts := time.Unix(item.PreTime, 0)
  8035. record_time2 := ts.AddDate(0, 0, int(2)).Unix()
  8036. tempTime3 := time.Unix(record_time2, 0)
  8037. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  8038. cFYLJG001.ValiEndTime = timeFormat3
  8039. cFYLJG001.RxCotnFlag = "0"
  8040. for _, subItem := range item.HisDoctorAdviceInfo {
  8041. var drug models.RxDrug
  8042. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  8043. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  8044. drug.RxItemTypeCode = "11"
  8045. drug.DrugDosform = "剂" //TODO
  8046. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  8047. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  8048. }
  8049. drug.MedcWayDscr = subItem.DeliveryWay
  8050. tempTime2 := time.Unix(subItem.StartTime, 0)
  8051. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8052. drug.MedcBegntime = timeFormatTwo
  8053. if subItem.Day > 0 {
  8054. ts := time.Unix(subItem.StartTime, 0)
  8055. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  8056. tempTime4 := time.Unix(record_time, 0)
  8057. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  8058. drug.MedcEndtime = timeFormat5
  8059. } else {
  8060. tempTime2 := time.Unix(subItem.StartTime, 0)
  8061. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8062. drug.MedcEndtime = timeFormatTwo
  8063. }
  8064. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  8065. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  8066. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  8067. drug.DrugCnt = subItem.PrescribingNumber
  8068. drug.DrugDosunt = subItem.PrescribingNumberUnit
  8069. drug.DrugGenname = subItem.AdviceName
  8070. drug.MedcWayCodg = subItem.DeliveryWay
  8071. //drug.DrugTotlcnt = subItem.PrescribingNumber
  8072. drug.SinDoscnt = subItem.SingleDose
  8073. drug.SinDosunt = subItem.SingleDoseUnit
  8074. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  8075. drug.UsedFrquName = subItem.ExecutionFrequency
  8076. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  8077. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  8078. drug.HospApprFlag = "1"
  8079. cFYLJG001.List = append(cFYLJG001.List, drug)
  8080. }
  8081. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  8082. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  8083. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  8084. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  8085. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  8086. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  8087. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  8088. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  8089. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  8090. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  8091. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  8092. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  8093. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  8094. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  8095. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  8096. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  8097. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  8098. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  8099. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  8100. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  8101. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  8102. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  8103. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  8104. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  8105. tempTime2 := time.Now().Unix()
  8106. tempTime6 := time.Unix(tempTime2, 0)
  8107. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  8108. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  8109. cFYLJG001.Mdtrtinfo.DiseCodg = ""
  8110. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  8111. cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
  8112. cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
  8113. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  8114. var config []*models.HisXtDiagnoseConfig
  8115. for _, item := range diagnosis_ids {
  8116. id, _ := strconv.ParseInt(item, 10, 64)
  8117. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8118. config = append(config, &diagnosisConfig)
  8119. }
  8120. for index, subitem := range config {
  8121. if index == 0 {
  8122. var dia models.DiseInfo
  8123. dia.DiagType = "1"
  8124. dia.MaindiagFlag = "1"
  8125. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8126. dia.DiagCode = subitem.CountryCode
  8127. dia.DiagName = subitem.ClassName
  8128. dia.DiagDept = "肾内科"
  8129. dia.DiagDrNo = doctor.DoctorNumber
  8130. dia.DiagDrName = doctor.UserName
  8131. tempTime3 := time.Unix(item.PreTime, 0)
  8132. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8133. dia.DiagTime = timeFormatTwo
  8134. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8135. } else {
  8136. var dia models.DiseInfo
  8137. dia.DiagType = "1"
  8138. dia.MaindiagFlag = "0"
  8139. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8140. dia.DiagCode = subitem.CountryCode
  8141. dia.DiagName = subitem.ClassName
  8142. dia.DiagDept = "肾内科"
  8143. dia.DiagDrNo = doctor.DoctorNumber
  8144. dia.DiagDrName = doctor.UserName
  8145. tempTime3 := time.Unix(item.PreTime, 0)
  8146. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8147. dia.DiagTime = timeFormatTwo
  8148. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8149. }
  8150. }
  8151. if miConfig.MdtrtareaAdmvs == "340699" {
  8152. result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
  8153. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8154. var res ResultCFYLJG001AH
  8155. var respJSON2 map[string]interface{}
  8156. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8159. return
  8160. }
  8161. userJSONBytes2, _ := json.Marshal(respJSON2)
  8162. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8163. utils.ErrorLog("解析失败:%v", err)
  8164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8165. return
  8166. }
  8167. var flow models.HisPrescriptionFlow
  8168. flow.Ctime = time.Now().Unix()
  8169. flow.SignDigest = ""
  8170. flow.RxTraceCode = res.RxTraceCode
  8171. flow.HiRxno = res.HiRxno
  8172. flow.MID = his.Number
  8173. flow.Status = 1
  8174. flow.DCode = doctor_info.DoctorNumber
  8175. flow.OriginalRxFile = ""
  8176. flow.OriginalValue = ""
  8177. flow.SignCertDn = ""
  8178. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8179. flow.SignCertSn = ""
  8180. flow.Mtime = time.Now().Unix()
  8181. service.Createflow(&flow)
  8182. c.ServeSuccessJSON(map[string]interface{}{
  8183. "msg": "上传成功",
  8184. })
  8185. } else {
  8186. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  8187. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8188. var res ResultCFYLJG001
  8189. var respJSON2 map[string]interface{}
  8190. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8193. return
  8194. }
  8195. userJSONBytes2, _ := json.Marshal(respJSON2)
  8196. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8197. utils.ErrorLog("解析失败:%v", err)
  8198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8199. return
  8200. }
  8201. if res.Infcode == -1 {
  8202. c.ServeSuccessJSON(map[string]interface{}{
  8203. "failed_code": -10,
  8204. "msg": res.ErrMsg,
  8205. })
  8206. return
  8207. } else {
  8208. var flow models.HisPrescriptionFlow
  8209. flow.Ctime = time.Now().Unix()
  8210. flow.SignDigest = ""
  8211. flow.RxTraceCode = res.Output.RxTraceCode
  8212. flow.HiRxno = res.Output.HiRxno
  8213. flow.MID = his.Number
  8214. flow.Status = 1
  8215. flow.DCode = doctor_info.DoctorNumber
  8216. flow.OriginalRxFile = ""
  8217. flow.OriginalValue = ""
  8218. flow.SignCertDn = ""
  8219. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8220. flow.SignCertSn = ""
  8221. flow.Mtime = time.Now().Unix()
  8222. service.Createflow(&flow)
  8223. c.ServeSuccessJSON(map[string]interface{}{
  8224. "msg": "上传成功",
  8225. })
  8226. }
  8227. }
  8228. }
  8229. }
  8230. func (c *HisApiController) GetCFYLJG12() {
  8231. admin_user_id, _ := c.GetInt64("admin_user_id")
  8232. his_patient_id, _ := c.GetInt64("his_patient_id")
  8233. record_time := c.GetString("record_time")
  8234. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8235. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8236. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8237. flow, _ := service.Getflowtwo(his.Number)
  8238. patient_id, _ := c.GetInt64("patient_id")
  8239. timeLayout := "2006-01-02"
  8240. loc, _ := time.LoadLocation("Local")
  8241. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8242. if err != nil {
  8243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8244. return
  8245. }
  8246. recordDateTime := theTime.Unix()
  8247. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8248. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8249. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8250. dept, _ := service.GetDepartMentDetail(info.Departments)
  8251. inputData := make(map[string]interface{})
  8252. inputData["rxTraceCode"] = flow.RxTraceCode
  8253. inputData["hiRxno"] = flow.HiRxno
  8254. inputData["mdtrtId"] = flow.MID
  8255. inputData["patnName"] = his.PsnName
  8256. inputData["psnCertType"] = his.PsnCertType
  8257. inputData["certno"] = his.Certno
  8258. inputData["fixmedinsName"] = miConfig.OrgName
  8259. inputData["fixmedinsCode"] = miConfig.Code
  8260. inputData["drCode"] = doctor_info.DoctorNumber
  8261. inputData["prscDrName"] = doctor_info.UserName
  8262. inputData["pharDeptName"] = dept.Name
  8263. inputData["pharDeptCode"] = dept.Number
  8264. inputData["pharProfttlCodg"] = ""
  8265. inputData["pharProfttlName"] = ""
  8266. inputData["pharCode"] = "HY340621000425"
  8267. inputData["pharCertType"] = "01"
  8268. inputData["pharCertno"] = ""
  8269. inputData["pharName"] = "孙莉侠"
  8270. inputData["pharPracCertNo"] = ""
  8271. tempTime2 := time.Unix(info.Ctime, 0)
  8272. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8273. inputData["pharChkTime"] = timeFormatTwo
  8274. bytesData, _ := json.Marshal(inputData)
  8275. fmt.Println(string(bytesData))
  8276. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8277. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8278. if err != nil {
  8279. fmt.Println("Error reading PDF file:", err)
  8280. return
  8281. }
  8282. // 将 PDF 文件内容进行 Base64 编码
  8283. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8284. fmt.Println(err)
  8285. if miConfig.MdtrtareaAdmvs == "340699" {
  8286. data := make(map[string]interface{})
  8287. data["rx_encoded"] = rx_encoded
  8288. data["code"] = miConfig.Code
  8289. data["url"] = "http://10.66.149.64:8080/epc/api"
  8290. data["encoded"] = encoded
  8291. client := &http.Client{}
  8292. bytesData, _ := json.Marshal(data)
  8293. var req *http.Request
  8294. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/02", bytes.NewReader(bytesData))
  8295. resp, _ := client.Do(req)
  8296. defer resp.Body.Close()
  8297. body, ioErr := ioutil.ReadAll(resp.Body)
  8298. if ioErr != nil {
  8299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8300. }
  8301. var respJSON map[string]interface{}
  8302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8305. return
  8306. }
  8307. var resSix10265 ResultSix10265 //1101结果
  8308. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8309. result, _ := json.Marshal(respJSON)
  8310. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8311. utils.ErrorLog("解析失败:%v", err)
  8312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8313. return
  8314. }
  8315. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8316. //saveLog(result, "", "GetCFYLJG002", "GetCFYLJG002")
  8317. } else {
  8318. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8319. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8320. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8321. var res2 AhResult002
  8322. var respJSON2 map[string]interface{}
  8323. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8326. return
  8327. }
  8328. userJSONBytes2, _ := json.Marshal(respJSON2)
  8329. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8330. utils.ErrorLog("解析失败:%v", err)
  8331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8332. return
  8333. }
  8334. flow.Ctime = time.Now().Unix()
  8335. flow.SignDigest = res2.SignDigest
  8336. flow.RxFile = res2.RxFile
  8337. flow.MID = his.Number
  8338. flow.Status = 1
  8339. flow.DCode = doctor_info.DoctorNumber
  8340. flow.OriginalRxFile = rx_encoded
  8341. flow.OriginalValue = encoded
  8342. flow.SignCertDn = res2.SignCertDn
  8343. flow.SignCertSn = res2.SignCertSn
  8344. flow.Mtime = time.Now().Unix()
  8345. service.Saveflow(flow)
  8346. c.ServeSuccessJSON(map[string]interface{}{
  8347. "msg": "预签名成功",
  8348. })
  8349. }
  8350. }
  8351. func (c *HisApiController) GetCFYLJG13() {
  8352. admin_user_id, _ := c.GetInt64("admin_user_id")
  8353. his_patient_id, _ := c.GetInt64("his_patient_id")
  8354. record_time := c.GetString("record_time")
  8355. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8356. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8357. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8358. flow, _ := service.Getflowtwo(his.Number)
  8359. patient_id, _ := c.GetInt64("patient_id")
  8360. timeLayout := "2006-01-02"
  8361. loc, _ := time.LoadLocation("Local")
  8362. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8363. if err != nil {
  8364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8365. return
  8366. }
  8367. recordDateTime := theTime.Unix()
  8368. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8369. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8370. dept, _ := service.GetDepartMentDetail(info.Departments)
  8371. var cFYLJG003 models.CFYLJG003
  8372. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8373. cFYLJG003.HiRxno = flow.HiRxno
  8374. cFYLJG003.MdtrtID = flow.MID
  8375. cFYLJG003.PatnName = his.Name
  8376. cFYLJG003.Certno = his.Certno
  8377. cFYLJG003.FixmedinsName = miConfig.OrgName
  8378. cFYLJG003.FixmedinsCode = miConfig.Code
  8379. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8380. cFYLJG003.PrscDrName = doctor_info.UserName
  8381. cFYLJG003.PharDeptName = dept.Name
  8382. cFYLJG003.PharDeptCode = dept.Number
  8383. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8384. cFYLJG003.PharName = "孙莉侠"
  8385. cFYLJG003.PharPracCertNo = "060399"
  8386. cFYLJG003.PharCode = "HY340621000425"
  8387. cFYLJG003.PharCertType = "01"
  8388. cFYLJG003.PharCertno = ""
  8389. } else {
  8390. cFYLJG003.PharName = "彭斯遥"
  8391. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8392. cFYLJG003.PharCode = "HY440309002107"
  8393. cFYLJG003.PharCertType = "01"
  8394. cFYLJG003.PharCertno = "430482199408260023"
  8395. }
  8396. cFYLJG003.PsnCertType = "01"
  8397. cFYLJG003.RxFile = flow.RxFile
  8398. cFYLJG003.SignDigest = flow.SignDigest
  8399. cFYLJG003.FixmedinsCode = miConfig.Code
  8400. cFYLJG003.PsnCertType = "01"
  8401. cFYLJG003.PharProfttlCodg = dept.Name
  8402. tempTime2 := time.Unix(info.Ctime, 0)
  8403. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8404. cFYLJG003.PharChkTime = timeFormatTwo
  8405. if miConfig.MdtrtareaAdmvs == "340699" {
  8406. data := make(map[string]interface{})
  8407. data["url"] = "http://10.66.149.64:8080/epc/api"
  8408. data["13"] = cFYLJG003
  8409. client := &http.Client{}
  8410. bytesData, _ := json.Marshal(data)
  8411. var req *http.Request
  8412. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/03", bytes.NewReader(bytesData))
  8413. resp, _ := client.Do(req)
  8414. defer resp.Body.Close()
  8415. body, ioErr := ioutil.ReadAll(resp.Body)
  8416. if ioErr != nil {
  8417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8418. }
  8419. var respJSON map[string]interface{}
  8420. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8423. return
  8424. }
  8425. var resSix10265 ResultSix10265 //1101结果
  8426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8427. result, _ := json.Marshal(respJSON)
  8428. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8429. utils.ErrorLog("解析失败:%v", err)
  8430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8431. return
  8432. }
  8433. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8434. //saveLog(result, "", "GetCFYLJG013", "GetCFYLJG013")
  8435. } else {
  8436. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8437. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8438. var res ResultCFYLJG003
  8439. var respJSON2 map[string]interface{}
  8440. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8441. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8443. return
  8444. }
  8445. userJSONBytes2, _ := json.Marshal(respJSON2)
  8446. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8447. utils.ErrorLog("解析失败:%v", err)
  8448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8449. return
  8450. }
  8451. if res.Infcode == -1 {
  8452. c.ServeSuccessJSON(map[string]interface{}{
  8453. "failed_code": -10,
  8454. "msg": res.ErrMsg,
  8455. })
  8456. return
  8457. } else {
  8458. c.ServeSuccessJSON(map[string]interface{}{
  8459. "info": res.Output,
  8460. })
  8461. }
  8462. }
  8463. }
  8464. func (c *HisApiController) GetCFYLJG002() {
  8465. admin_user_id, _ := c.GetInt64("admin_user_id")
  8466. his_patient_id, _ := c.GetInt64("his_patient_id")
  8467. record_time := c.GetString("record_time")
  8468. admin_user_id = 3626
  8469. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8470. //id, _ := c.GetInt64("id")
  8471. admin_user_id = 3626
  8472. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8473. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8474. flow, _ := service.Getflowtwo(his.Number)
  8475. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8476. //record_time := c.GetString("record_time")
  8477. patient_id, _ := c.GetInt64("patient_id")
  8478. //patient_id = 23834
  8479. //record_time = "2023-09-18"
  8480. timeLayout := "2006-01-02"
  8481. loc, _ := time.LoadLocation("Local")
  8482. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8483. if err != nil {
  8484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8485. return
  8486. }
  8487. recordDateTime := theTime.Unix()
  8488. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8489. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8490. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8491. dept, _ := service.GetDepartMentDetail(info.Departments)
  8492. inputData := make(map[string]interface{})
  8493. inputData["rxTraceCode"] = flow.RxTraceCode
  8494. inputData["hiRxno"] = flow.HiRxno
  8495. inputData["mdtrtId"] = flow.MID
  8496. inputData["patnName"] = his.PsnName
  8497. inputData["psnCertType"] = his.PsnCertType
  8498. inputData["certno"] = his.Certno
  8499. inputData["fixmedinsName"] = miConfig.OrgName
  8500. inputData["fixmedinsCode"] = miConfig.Code
  8501. inputData["drCode"] = doctor_info.DoctorNumber
  8502. inputData["prscDrName"] = doctor_info.UserName
  8503. inputData["pharDeptName"] = dept.Name
  8504. inputData["pharDeptCode"] = dept.Number
  8505. inputData["pharProfttlCodg"] = ""
  8506. inputData["pharProfttlName"] = ""
  8507. inputData["pharCode"] = "HY340621000425"
  8508. inputData["pharCertType"] = "01"
  8509. inputData["pharCertno"] = ""
  8510. inputData["pharName"] = "孙莉侠"
  8511. inputData["pharPracCertNo"] = "060399"
  8512. tempTime2 := time.Unix(info.Ctime, 0)
  8513. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8514. inputData["pharChkTime"] = timeFormatTwo
  8515. bytesData, _ := json.Marshal(inputData)
  8516. fmt.Println(string(bytesData))
  8517. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8518. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8519. if err != nil {
  8520. fmt.Println("Error reading PDF file:", err)
  8521. return
  8522. }
  8523. // 将 PDF 文件内容进行 Base64 编码
  8524. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8525. fmt.Println(err)
  8526. if miConfig.MdtrtareaAdmvs == "340699" {
  8527. result, request := service.GetAHCFYLJG002(miConfig.Code, "http://10.66.149.64:8080/epc/api", encoded, rx_encoded, "")
  8528. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8529. var res2 AhResult002
  8530. var respJSON2 map[string]interface{}
  8531. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8534. return
  8535. }
  8536. userJSONBytes2, _ := json.Marshal(respJSON2)
  8537. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8538. utils.ErrorLog("解析失败:%v", err)
  8539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8540. return
  8541. }
  8542. flow.Ctime = time.Now().Unix()
  8543. flow.SignDigest = res2.SignDigest
  8544. flow.RxFile = res2.RxFile
  8545. flow.MID = his.Number
  8546. flow.Status = 1
  8547. flow.DCode = doctor_info.DoctorNumber
  8548. flow.OriginalRxFile = rx_encoded
  8549. flow.OriginalValue = encoded
  8550. flow.SignCertDn = res2.SignCertDn
  8551. flow.SignCertSn = res2.SignCertSn
  8552. flow.Mtime = time.Now().Unix()
  8553. service.Saveflow(flow)
  8554. c.ServeSuccessJSON(map[string]interface{}{
  8555. "msg": "预签名成功",
  8556. })
  8557. } else {
  8558. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8559. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8560. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8561. var res2 Result002
  8562. var respJSON2 map[string]interface{}
  8563. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8566. return
  8567. }
  8568. userJSONBytes2, _ := json.Marshal(respJSON2)
  8569. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8570. utils.ErrorLog("解析失败:%v", err)
  8571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8572. return
  8573. }
  8574. if res2.Infcode == 0 {
  8575. flow.Ctime = time.Now().Unix()
  8576. flow.SignDigest = res2.Output.SignDigest
  8577. flow.RxFile = res2.Output.RxFile
  8578. flow.MID = his.Number
  8579. flow.Status = 1
  8580. flow.DCode = doctor_info.DoctorNumber
  8581. flow.OriginalRxFile = rx_encoded
  8582. flow.OriginalValue = encoded
  8583. flow.SignCertDn = res2.Output.SignCertDn
  8584. flow.SignCertSn = res2.Output.SignCertSn
  8585. flow.Mtime = time.Now().Unix()
  8586. service.Saveflow(flow)
  8587. c.ServeSuccessJSON(map[string]interface{}{
  8588. "msg": "预签名成功",
  8589. })
  8590. } else {
  8591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8592. return
  8593. }
  8594. }
  8595. }
  8596. func (c *HisApiController) GetCFYLJG003() {
  8597. admin_user_id, _ := c.GetInt64("admin_user_id")
  8598. his_patient_id, _ := c.GetInt64("his_patient_id")
  8599. record_time := c.GetString("record_time")
  8600. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8601. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8602. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8603. flow, _ := service.Getflowtwo(his.Number)
  8604. patient_id, _ := c.GetInt64("patient_id")
  8605. timeLayout := "2006-01-02"
  8606. loc, _ := time.LoadLocation("Local")
  8607. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8608. if err != nil {
  8609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8610. return
  8611. }
  8612. recordDateTime := theTime.Unix()
  8613. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8614. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8615. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8616. dept, _ := service.GetDepartMentDetail(info.Departments)
  8617. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8618. var cFYLJG003 models.CFYLJG003
  8619. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8620. cFYLJG003.HiRxno = flow.HiRxno
  8621. cFYLJG003.MdtrtID = flow.MID
  8622. cFYLJG003.PatnName = his.PsnName
  8623. cFYLJG003.Certno = his.Certno
  8624. cFYLJG003.FixmedinsName = miConfig.OrgName
  8625. cFYLJG003.FixmedinsCode = miConfig.Code
  8626. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8627. cFYLJG003.PrscDrName = doctor_info.UserName
  8628. cFYLJG003.PharDeptName = dept.Name
  8629. cFYLJG003.PharDeptCode = dept.Number
  8630. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8631. cFYLJG003.PharName = "孙莉侠"
  8632. cFYLJG003.PharPracCertNo = "060399"
  8633. cFYLJG003.PharCode = "HY340621000425"
  8634. cFYLJG003.PharCertType = "01"
  8635. cFYLJG003.PharCertno = ""
  8636. } else {
  8637. cFYLJG003.PharName = "彭斯遥"
  8638. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8639. cFYLJG003.PharCode = "HY440309002107"
  8640. cFYLJG003.PharCertType = "01"
  8641. cFYLJG003.PharCertno = "430482199408260023"
  8642. }
  8643. cFYLJG003.RxFile = flow.RxFile
  8644. cFYLJG003.SignDigest = flow.SignDigest
  8645. cFYLJG003.FixmedinsCode = miConfig.Code
  8646. cFYLJG003.PsnCertType = his.PsnCertType
  8647. tempTime2 := time.Unix(info.Ctime, 0)
  8648. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8649. cFYLJG003.PharChkTime = timeFormatTwo
  8650. if miConfig.MdtrtareaAdmvs == "340699" {
  8651. result, request := service.GetAHCFYLJG003("http://10.66.149.64:8080/epc/api", cFYLJG003)
  8652. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  8653. var res AHResult003
  8654. var respJSON2 map[string]interface{}
  8655. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8658. return
  8659. }
  8660. userJSONBytes2, _ := json.Marshal(respJSON2)
  8661. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8662. utils.ErrorLog("解析失败:%v", err)
  8663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8664. return
  8665. }
  8666. {
  8667. c.ServeSuccessJSON(map[string]interface{}{
  8668. "info": res,
  8669. })
  8670. }
  8671. } else {
  8672. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8673. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8674. var res ResultCFYLJG003
  8675. var respJSON2 map[string]interface{}
  8676. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8679. return
  8680. }
  8681. userJSONBytes2, _ := json.Marshal(respJSON2)
  8682. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8683. utils.ErrorLog("解析失败:%v", err)
  8684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8685. return
  8686. }
  8687. if res.Infcode == -1 {
  8688. c.ServeSuccessJSON(map[string]interface{}{
  8689. "failed_code": -10,
  8690. "msg": res.ErrMsg,
  8691. })
  8692. return
  8693. } else {
  8694. c.ServeSuccessJSON(map[string]interface{}{
  8695. "info": res.Output,
  8696. })
  8697. }
  8698. }
  8699. }
  8700. func (c *HisApiController) GetCFYLJG004() {
  8701. admin_user_id, _ := c.GetInt64("admin_user_id")
  8702. his_patient_id, _ := c.GetInt64("his_patient_id")
  8703. record_time := c.GetString("record_time")
  8704. admin_user_id = 3626
  8705. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8706. //id, _ := c.GetInt64("id")
  8707. admin_user_id = 3626
  8708. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8709. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8710. flow, _ := service.Getflowtwo(his.Number)
  8711. //id = 3
  8712. patient_id, _ := c.GetInt64("patient_id")
  8713. //patient_id = 23834
  8714. //record_time = "2023-09-18"
  8715. timeLayout := "2006-01-02"
  8716. loc, _ := time.LoadLocation("Local")
  8717. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8718. if err != nil {
  8719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8720. return
  8721. }
  8722. recordDateTime := theTime.Unix()
  8723. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8724. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8725. var cFYLJG004 models.CFYLJG004
  8726. cFYLJG004.HiRxno = flow.HiRxno
  8727. cFYLJG004.FixmedinsCode = miConfig.Code
  8728. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8729. cFYLJG004.UndoDrCertType = "01"
  8730. cFYLJG004.UndoRea = "撤销处方"
  8731. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8732. cFYLJG004.UndoDrName = doctor_info.UserName
  8733. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8734. if miConfig.MdtrtareaAdmvs == "340699" {
  8735. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8736. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8737. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  8738. } else {
  8739. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8740. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8741. var res ResultCFYLJG004
  8742. var respJSON2 map[string]interface{}
  8743. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8746. return
  8747. }
  8748. userJSONBytes2, _ := json.Marshal(respJSON2)
  8749. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8750. utils.ErrorLog("解析失败:%v", err)
  8751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8752. return
  8753. }
  8754. if res.Infcode == -1 {
  8755. c.ServeSuccessJSON(map[string]interface{}{
  8756. "failed_code": -10,
  8757. "msg": res.ErrMsg,
  8758. })
  8759. return
  8760. } else {
  8761. flow.Status = 0
  8762. service.Saveflow(flow)
  8763. c.ServeSuccessJSON(map[string]interface{}{
  8764. "msg": "撤销成功",
  8765. })
  8766. return
  8767. }
  8768. }
  8769. }
  8770. func (c *HisApiController) GetCFYLJG005() {
  8771. admin_user_id, _ := c.GetInt64("admin_user_id")
  8772. his_patient_id, _ := c.GetInt64("his_patient_id")
  8773. //record_time := c.GetString("record_time")
  8774. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8775. //id, _ := c.GetInt64("id")
  8776. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8777. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8778. flow, _ := service.Getflowtwo(his.Number)
  8779. //id = 3
  8780. var cFYLJG005 models.CFYLJG005
  8781. //patient_id, _ := c.GetInt64("patient_id")
  8782. cFYLJG005.HiRxno = flow.HiRxno
  8783. cFYLJG005.MdtrtID = flow.MID
  8784. cFYLJG005.EcToken = ""
  8785. cFYLJG005.PsnName = his.Name
  8786. cFYLJG005.PsnCertType = "01"
  8787. cFYLJG005.Certno = his.IdCardNo
  8788. if miConfig.MdtrtareaAdmvs == "340699" {
  8789. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8790. result, request := service.GetAHCFYLJG005(miConfig.Code, cFYLJG005)
  8791. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8792. } else {
  8793. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8794. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8795. var res ResultCFYLJG005
  8796. var respJSON2 map[string]interface{}
  8797. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8800. return
  8801. }
  8802. userJSONBytes2, _ := json.Marshal(respJSON2)
  8803. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8804. utils.ErrorLog("解析失败:%v", err)
  8805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8806. return
  8807. }
  8808. if res.Infcode == -1 {
  8809. c.ServeSuccessJSON(map[string]interface{}{
  8810. "failed_code": -10,
  8811. "msg": res.ErrMsg,
  8812. })
  8813. return
  8814. } else {
  8815. c.ServeSuccessJSON(map[string]interface{}{
  8816. "info": res.Output,
  8817. })
  8818. return
  8819. }
  8820. }
  8821. }
  8822. func (c *HisApiController) GetCFYLJG006() {
  8823. admin_user_id, _ := c.GetInt64("admin_user_id")
  8824. his_patient_id, _ := c.GetInt64("his_patient_id")
  8825. admin_user_id = 3626
  8826. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8827. //id, _ := c.GetInt64("id")
  8828. admin_user_id = 3626
  8829. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8830. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8831. flow, _ := service.Getflowtwo(his.Number)
  8832. //id = 3
  8833. patient_id, _ := c.GetInt64("patient_id")
  8834. var cFYLJG006 models.CFYLJG006
  8835. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8836. cFYLJG006.HiRxno = flow.HiRxno
  8837. cFYLJG006.MdtrtID = flow.MID
  8838. cFYLJG006.PsnName = patient.Name
  8839. cFYLJG006.PsnCertType = "01"
  8840. cFYLJG006.Certno = patient.IdCardNo
  8841. if miConfig.MdtrtareaAdmvs == "340699" {
  8842. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8843. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8844. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8845. } else {
  8846. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8847. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8848. var res ResultCFYLJG006
  8849. var respJSON2 map[string]interface{}
  8850. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8853. return
  8854. }
  8855. userJSONBytes2, _ := json.Marshal(respJSON2)
  8856. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8857. utils.ErrorLog("解析失败:%v", err)
  8858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8859. return
  8860. }
  8861. if res.Infcode == -1 {
  8862. c.ServeSuccessJSON(map[string]interface{}{
  8863. "failed_code": -10,
  8864. "msg": res.ErrMsg,
  8865. })
  8866. return
  8867. } else {
  8868. c.ServeSuccessJSON(map[string]interface{}{
  8869. "info": res.Output,
  8870. })
  8871. return
  8872. }
  8873. }
  8874. }
  8875. func (c *HisApiController) GetCFYLJG007() {
  8876. admin_user_id, _ := c.GetInt64("admin_user_id")
  8877. his_patient_id, _ := c.GetInt64("his_patient_id")
  8878. admin_user_id = 3626
  8879. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8880. //id, _ := c.GetInt64("id")
  8881. admin_user_id = 3626
  8882. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8883. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8884. flow, _ := service.Getflowtwo(his.Number)
  8885. //id = 3
  8886. patient_id, _ := c.GetInt64("patient_id")
  8887. var cFYLJG007 models.CFYLJG007
  8888. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8889. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8890. cFYLJG007.HiRxno = flow.HiRxno
  8891. cFYLJG007.MdtrtID = flow.MID
  8892. cFYLJG007.PsnNo = his.PsnNo
  8893. cFYLJG007.PsnCertType = "01"
  8894. cFYLJG007.Certno = patient.IdCardNo
  8895. cFYLJG007.PsnName = patient.Name
  8896. if miConfig.MdtrtareaAdmvs == "340699" {
  8897. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8898. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8899. } else {
  8900. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8901. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8902. var res ResultCFYLJG007
  8903. var respJSON2 map[string]interface{}
  8904. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8907. return
  8908. }
  8909. userJSONBytes2, _ := json.Marshal(respJSON2)
  8910. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8911. utils.ErrorLog("解析失败:%v", err)
  8912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8913. return
  8914. }
  8915. if res.Infcode == -1 {
  8916. c.ServeSuccessJSON(map[string]interface{}{
  8917. "failed_code": -10,
  8918. "msg": res.ErrMsg,
  8919. })
  8920. return
  8921. } else {
  8922. c.ServeSuccessJSON(map[string]interface{}{
  8923. "info": res,
  8924. })
  8925. return
  8926. }
  8927. }
  8928. }
  8929. func (c *HisApiController) GetCFYLJG008() {
  8930. admin_user_id, _ := c.GetInt64("admin_user_id")
  8931. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8932. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8933. var cFYLJG008 models.CFYLJG008
  8934. //id, _ := c.GetInt64("id")
  8935. patient_id, _ := c.GetInt64("patient_id")
  8936. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8937. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8938. //id = 3
  8939. //flow, _ := service.Getflow(id)
  8940. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8941. //
  8942. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8943. //patient_id, _ := c.GetInt64("patient_id")
  8944. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8945. record_time := c.GetString("record_time")
  8946. admin_user_id = 3626
  8947. patient_id = 19424
  8948. //his_patient_id = 263947
  8949. record_time = "2023-08-29"
  8950. timeLayout := "2006-01-02"
  8951. loc, _ := time.LoadLocation("Local")
  8952. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8953. if err != nil {
  8954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8955. return
  8956. }
  8957. recordDateTime := theTime.Unix()
  8958. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8959. cFYLJG008.FixmedinsName = ""
  8960. cFYLJG008.Lat = ""
  8961. cFYLJG008.Lng = ""
  8962. cFYLJG008.OrderType = "1"
  8963. cFYLJG008.PoolareaNo = ""
  8964. cFYLJG008.Lng = ""
  8965. cFYLJG008.PageNum = 1
  8966. cFYLJG008.PageSize = 10
  8967. var MPI models.MedinsProdInvChgDDTO
  8968. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8969. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8970. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8971. if miConfig.MdtrtareaAdmvs == "340699" {
  8972. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8973. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8974. } else {
  8975. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8976. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8977. var res ResultCFYLJG008
  8978. var respJSON2 map[string]interface{}
  8979. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8982. return
  8983. }
  8984. userJSONBytes2, _ := json.Marshal(respJSON2)
  8985. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8986. utils.ErrorLog("解析失败:%v", err)
  8987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8988. return
  8989. }
  8990. if res.Infcode == -1 {
  8991. c.ServeSuccessJSON(map[string]interface{}{
  8992. "failed_code": -10,
  8993. "msg": res.ErrMsg,
  8994. })
  8995. return
  8996. } else {
  8997. c.ServeSuccessJSON(map[string]interface{}{
  8998. "info": res.Output,
  8999. })
  9000. return
  9001. }
  9002. }
  9003. }
  9004. func (c *HisApiController) GetBL4201A() {
  9005. order_id, _ := c.GetInt64("order_id")
  9006. admin_user_id, _ := c.GetInt64("admin_user_id")
  9007. order, _ := service.GetHisOrderByIDTwo(order_id)
  9008. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9009. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9010. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9011. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9012. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9013. department, _ := service.GetDepartMentDetail(his.Departments)
  9014. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9015. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9016. if order.ID == 0 {
  9017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9018. return
  9019. }
  9020. var struct4201A models.Struct4201A
  9021. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9022. for _, items := range order_info {
  9023. memo := make(map[string]interface{})
  9024. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9025. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9026. fsiOPFLD.MedType = "14"
  9027. fsiOPFLD.BkkpSn = items.FeedetlSn
  9028. fsiOPFLD.FixmedinsCode = miConfig.Code
  9029. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9030. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9031. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9032. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9033. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9034. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9035. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9036. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9037. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9038. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9039. fsiOPFLD.BilgDeptName = department.Name
  9040. fsiOPFLD.BilgDeptCodg = department.Number
  9041. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9042. fsiOPFLD.BilgDrName = doctor.UserName
  9043. fsiOPFLD.MedChrgitmType = "09"
  9044. memo["hosp_appr_flag"] = "1"
  9045. memo["invoice_no"] = order.MdtrtId
  9046. memo["memo"] = "自费"
  9047. bytesData, _ := json.Marshal(memo)
  9048. fsiOPFLD.Memo = string(bytesData)
  9049. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9050. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9051. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9052. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9053. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9054. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9055. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9056. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9057. fsiOPFLD.BilgDeptName = department.Name
  9058. fsiOPFLD.BilgDeptCodg = department.Number
  9059. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9060. fsiOPFLD.BilgDrName = doctor.UserName
  9061. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9062. case 0:
  9063. break
  9064. case 1:
  9065. fsiOPFLD.MedChrgitmType = "14"
  9066. break
  9067. case 2:
  9068. fsiOPFLD.MedChrgitmType = "05"
  9069. break
  9070. case 3:
  9071. fsiOPFLD.MedChrgitmType = "03"
  9072. break
  9073. case 4:
  9074. fsiOPFLD.MedChrgitmType = "03"
  9075. break
  9076. case 5:
  9077. fsiOPFLD.MedChrgitmType = "08"
  9078. break
  9079. case 6:
  9080. fsiOPFLD.MedChrgitmType = "14"
  9081. break
  9082. case 7:
  9083. fsiOPFLD.MedChrgitmType = "14"
  9084. break
  9085. case 8:
  9086. fsiOPFLD.MedChrgitmType = "03"
  9087. break
  9088. case 9:
  9089. fsiOPFLD.MedChrgitmType = "14"
  9090. break
  9091. case 10:
  9092. fsiOPFLD.MedChrgitmType = "14"
  9093. break
  9094. case 11:
  9095. fsiOPFLD.MedChrgitmType = "06"
  9096. break
  9097. case 12:
  9098. fsiOPFLD.MedChrgitmType = "12"
  9099. break
  9100. case 13:
  9101. fsiOPFLD.MedChrgitmType = "01"
  9102. break
  9103. case 14:
  9104. fsiOPFLD.MedChrgitmType = "04"
  9105. break
  9106. case 15:
  9107. fsiOPFLD.MedChrgitmType = "14"
  9108. break
  9109. }
  9110. memo["hosp_appr_flag"] = "1"
  9111. memo["invoice_no"] = order.MdtrtId
  9112. memo["memo"] = "自费"
  9113. bytesData, _ := json.Marshal(memo)
  9114. fsiOPFLD.Memo = string(bytesData)
  9115. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9116. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9117. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9118. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9119. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9120. fsiOPFLD.BilgDeptName = department.Name
  9121. fsiOPFLD.BilgDeptCodg = department.Number
  9122. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9123. fsiOPFLD.BilgDrName = doctor.UserName
  9124. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9125. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9126. fsiOPFLD.MedChrgitmType = "08"
  9127. memo["hosp_appr_flag"] = "1"
  9128. memo["invoice_no"] = order.MdtrtId
  9129. memo["memo"] = "自费"
  9130. bytesData, _ := json.Marshal(memo)
  9131. fsiOPFLD.Memo = string(bytesData)
  9132. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9133. }
  9134. }
  9135. }
  9136. for _, items := range order_info_two {
  9137. memo := make(map[string]interface{})
  9138. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9139. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9140. fsiOPFLD.MedType = "14"
  9141. fsiOPFLD.BkkpSn = items.FeedetlSn
  9142. fsiOPFLD.FixmedinsCode = miConfig.Code
  9143. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9144. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9145. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9146. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9147. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9148. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9149. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9150. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9151. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9152. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9153. fsiOPFLD.BilgDeptName = department.Name
  9154. fsiOPFLD.BilgDeptCodg = department.Number
  9155. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9156. fsiOPFLD.BilgDrName = doctor.UserName
  9157. fsiOPFLD.MedChrgitmType = "09"
  9158. memo["hosp_appr_flag"] = "1"
  9159. memo["invoice_no"] = order.MdtrtId
  9160. memo["memo"] = "自费"
  9161. bytesData, _ := json.Marshal(memo)
  9162. fsiOPFLD.Memo = string(bytesData)
  9163. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9164. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9165. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9166. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9167. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9168. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9169. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9170. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9171. fsiOPFLD.BilgDeptName = department.Name
  9172. fsiOPFLD.BilgDeptCodg = department.Number
  9173. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9174. fsiOPFLD.BilgDrName = doctor.UserName
  9175. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9176. case 0:
  9177. break
  9178. case 1:
  9179. fsiOPFLD.MedChrgitmType = "14"
  9180. break
  9181. case 2:
  9182. fsiOPFLD.MedChrgitmType = "05"
  9183. break
  9184. case 3:
  9185. fsiOPFLD.MedChrgitmType = "03"
  9186. break
  9187. case 4:
  9188. fsiOPFLD.MedChrgitmType = "03"
  9189. break
  9190. case 5:
  9191. fsiOPFLD.MedChrgitmType = "08"
  9192. break
  9193. case 6:
  9194. fsiOPFLD.MedChrgitmType = "14"
  9195. break
  9196. case 7:
  9197. fsiOPFLD.MedChrgitmType = "14"
  9198. break
  9199. case 8:
  9200. fsiOPFLD.MedChrgitmType = "03"
  9201. break
  9202. case 9:
  9203. fsiOPFLD.MedChrgitmType = "14"
  9204. break
  9205. case 10:
  9206. fsiOPFLD.MedChrgitmType = "14"
  9207. break
  9208. case 11:
  9209. fsiOPFLD.MedChrgitmType = "06"
  9210. break
  9211. case 12:
  9212. fsiOPFLD.MedChrgitmType = "12"
  9213. break
  9214. case 13:
  9215. fsiOPFLD.MedChrgitmType = "01"
  9216. break
  9217. case 14:
  9218. fsiOPFLD.MedChrgitmType = "04"
  9219. break
  9220. case 15:
  9221. fsiOPFLD.MedChrgitmType = "14"
  9222. break
  9223. }
  9224. memo["hosp_appr_flag"] = "1"
  9225. memo["invoice_no"] = order.MdtrtId
  9226. memo["memo"] = "自费"
  9227. bytesData, _ := json.Marshal(memo)
  9228. fsiOPFLD.Memo = string(bytesData)
  9229. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9230. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9231. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9232. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9233. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9234. fsiOPFLD.BilgDeptName = department.Name
  9235. fsiOPFLD.BilgDeptCodg = department.Number
  9236. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9237. fsiOPFLD.BilgDrName = doctor.UserName
  9238. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9239. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9240. fsiOPFLD.MedChrgitmType = "08"
  9241. memo["hosp_appr_flag"] = "1"
  9242. memo["invoice_no"] = order.MdtrtId
  9243. memo["memo"] = "自费"
  9244. bytesData, _ := json.Marshal(memo)
  9245. fsiOPFLD.Memo = string(bytesData)
  9246. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9247. }
  9248. }
  9249. }
  9250. fmt.Println(fsiOPFLDs)
  9251. struct4201A.Fopfd = fsiOPFLDs
  9252. fmt.Println(struct4201A.Fopfd)
  9253. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9254. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9255. var res2 ResultSix
  9256. var respJSON2 map[string]interface{}
  9257. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9260. return
  9261. }
  9262. userJSONBytes2, _ := json.Marshal(respJSON2)
  9263. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9264. utils.ErrorLog("解析失败:%v", err)
  9265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9266. return
  9267. }
  9268. if res2.Infcode != 0 {
  9269. c.ServeSuccessJSON(map[string]interface{}{
  9270. "failed_code": -10,
  9271. "msg": res2.ErrMsg,
  9272. })
  9273. return
  9274. } else {
  9275. order.IsUploadOrderInfo = 1
  9276. service.UpdateOrder(order)
  9277. c.ServeSuccessJSON(map[string]interface{}{
  9278. "msg": "上传成功",
  9279. })
  9280. }
  9281. }
  9282. func (c *HisApiController) Get3103() {
  9283. admin_user_id, _ := c.GetInt64("admin_user_id")
  9284. warm_type, _ := c.GetInt64("warm_type")
  9285. fk_state, _ := c.GetInt64("fk_state")
  9286. warm_ids := c.GetString("warm_ids")
  9287. desc := c.GetString("desc")
  9288. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9289. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9290. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  9291. saveLog(result, requestLog, "3103", "反馈")
  9292. var res2 ResultSix3103
  9293. var respJSON2 map[string]interface{}
  9294. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9297. return
  9298. }
  9299. userJSONBytes2, _ := json.Marshal(respJSON2)
  9300. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9301. utils.ErrorLog("解析失败:%v", err)
  9302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9303. return
  9304. }
  9305. if res2.Infcode != 0 {
  9306. c.ServeSuccessJSON(map[string]interface{}{
  9307. "failed_code": -10,
  9308. "msg": res2.ErrMsg,
  9309. })
  9310. return
  9311. } else {
  9312. c.ServeSuccessJSON(map[string]interface{}{
  9313. "msg": "反馈成功",
  9314. })
  9315. return
  9316. }
  9317. }
  9318. func (c *HisApiController) Get4201A() {
  9319. order_id, _ := c.GetInt64("order_id")
  9320. admin_user_id, _ := c.GetInt64("admin_user_id")
  9321. order, _ := service.GetHisOrderByIDTwo(order_id)
  9322. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9323. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9324. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9325. //order_info = append(order_info, order_info_two...)
  9326. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9327. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9328. department, _ := service.GetDepartMentDetail(his.Departments)
  9329. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9330. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9331. if order.ID == 0 {
  9332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9333. return
  9334. }
  9335. var struct4201A models.Struct4201A
  9336. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9337. for _, items := range order_info {
  9338. memo := make(map[string]interface{})
  9339. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9340. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9341. fsiOPFLD.MedType = "14"
  9342. fsiOPFLD.BkkpSn = items.FeedetlSn
  9343. fsiOPFLD.FixmedinsCode = miConfig.Code
  9344. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9345. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9346. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9347. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9348. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9349. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9350. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9351. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9352. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9353. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9354. fsiOPFLD.BilgDeptName = department.Name
  9355. fsiOPFLD.BilgDeptCodg = department.Number
  9356. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9357. fsiOPFLD.BilgDrName = doctor.UserName
  9358. fsiOPFLD.MedChrgitmType = "09"
  9359. memo["hosp_appr_flag"] = "1"
  9360. memo["invoice_no"] = order.MdtrtId
  9361. memo["memo"] = "自费"
  9362. bytesData, _ := json.Marshal(memo)
  9363. fsiOPFLD.Memo = string(bytesData)
  9364. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9365. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9366. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9367. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9368. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9369. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9370. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9371. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9372. fsiOPFLD.BilgDeptName = department.Name
  9373. fsiOPFLD.BilgDeptCodg = department.Number
  9374. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9375. fsiOPFLD.BilgDrName = doctor.UserName
  9376. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9377. case 0:
  9378. break
  9379. case 1:
  9380. fsiOPFLD.MedChrgitmType = "14"
  9381. break
  9382. case 2:
  9383. fsiOPFLD.MedChrgitmType = "05"
  9384. break
  9385. case 3:
  9386. fsiOPFLD.MedChrgitmType = "03"
  9387. break
  9388. case 4:
  9389. fsiOPFLD.MedChrgitmType = "03"
  9390. break
  9391. case 5:
  9392. fsiOPFLD.MedChrgitmType = "08"
  9393. break
  9394. case 6:
  9395. fsiOPFLD.MedChrgitmType = "14"
  9396. break
  9397. case 7:
  9398. fsiOPFLD.MedChrgitmType = "14"
  9399. break
  9400. case 8:
  9401. fsiOPFLD.MedChrgitmType = "03"
  9402. break
  9403. case 9:
  9404. fsiOPFLD.MedChrgitmType = "14"
  9405. break
  9406. case 10:
  9407. fsiOPFLD.MedChrgitmType = "14"
  9408. break
  9409. case 11:
  9410. fsiOPFLD.MedChrgitmType = "06"
  9411. break
  9412. case 12:
  9413. fsiOPFLD.MedChrgitmType = "12"
  9414. break
  9415. case 13:
  9416. fsiOPFLD.MedChrgitmType = "01"
  9417. break
  9418. case 14:
  9419. fsiOPFLD.MedChrgitmType = "04"
  9420. break
  9421. case 15:
  9422. fsiOPFLD.MedChrgitmType = "14"
  9423. break
  9424. }
  9425. memo["hosp_appr_flag"] = "1"
  9426. memo["invoice_no"] = order.MdtrtId
  9427. memo["memo"] = "自费"
  9428. bytesData, _ := json.Marshal(memo)
  9429. fsiOPFLD.Memo = string(bytesData)
  9430. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9431. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9432. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9433. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9434. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9435. fsiOPFLD.BilgDeptName = department.Name
  9436. fsiOPFLD.BilgDeptCodg = department.Number
  9437. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9438. fsiOPFLD.BilgDrName = doctor.UserName
  9439. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9440. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9441. fsiOPFLD.MedChrgitmType = "08"
  9442. memo["hosp_appr_flag"] = "1"
  9443. memo["invoice_no"] = order.MdtrtId
  9444. memo["memo"] = "自费"
  9445. bytesData, _ := json.Marshal(memo)
  9446. fsiOPFLD.Memo = string(bytesData)
  9447. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9448. }
  9449. }
  9450. }
  9451. for _, items := range order_info_two {
  9452. memo := make(map[string]interface{})
  9453. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9454. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9455. fsiOPFLD.MedType = "14"
  9456. fsiOPFLD.BkkpSn = items.FeedetlSn
  9457. fsiOPFLD.FixmedinsCode = miConfig.Code
  9458. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9459. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9460. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9461. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9462. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9463. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9464. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9465. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9466. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9467. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9468. fsiOPFLD.BilgDeptName = department.Name
  9469. fsiOPFLD.BilgDeptCodg = department.Number
  9470. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9471. fsiOPFLD.BilgDrName = doctor.UserName
  9472. fsiOPFLD.MedChrgitmType = "09"
  9473. memo["hosp_appr_flag"] = "1"
  9474. memo["invoice_no"] = order.MdtrtId
  9475. memo["memo"] = "自费"
  9476. bytesData, _ := json.Marshal(memo)
  9477. fsiOPFLD.Memo = string(bytesData)
  9478. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9479. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9480. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9481. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9482. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9483. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9484. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9485. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9486. fsiOPFLD.BilgDeptName = department.Name
  9487. fsiOPFLD.BilgDeptCodg = department.Number
  9488. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9489. fsiOPFLD.BilgDrName = doctor.UserName
  9490. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9491. case 0:
  9492. break
  9493. case 1:
  9494. fsiOPFLD.MedChrgitmType = "14"
  9495. break
  9496. case 2:
  9497. fsiOPFLD.MedChrgitmType = "05"
  9498. break
  9499. case 3:
  9500. fsiOPFLD.MedChrgitmType = "03"
  9501. break
  9502. case 4:
  9503. fsiOPFLD.MedChrgitmType = "03"
  9504. break
  9505. case 5:
  9506. fsiOPFLD.MedChrgitmType = "08"
  9507. break
  9508. case 6:
  9509. fsiOPFLD.MedChrgitmType = "14"
  9510. break
  9511. case 7:
  9512. fsiOPFLD.MedChrgitmType = "14"
  9513. break
  9514. case 8:
  9515. fsiOPFLD.MedChrgitmType = "03"
  9516. break
  9517. case 9:
  9518. fsiOPFLD.MedChrgitmType = "14"
  9519. break
  9520. case 10:
  9521. fsiOPFLD.MedChrgitmType = "14"
  9522. break
  9523. case 11:
  9524. fsiOPFLD.MedChrgitmType = "06"
  9525. break
  9526. case 12:
  9527. fsiOPFLD.MedChrgitmType = "12"
  9528. break
  9529. case 13:
  9530. fsiOPFLD.MedChrgitmType = "01"
  9531. break
  9532. case 14:
  9533. fsiOPFLD.MedChrgitmType = "04"
  9534. break
  9535. case 15:
  9536. fsiOPFLD.MedChrgitmType = "14"
  9537. break
  9538. }
  9539. memo["hosp_appr_flag"] = "1"
  9540. memo["invoice_no"] = order.MdtrtId
  9541. memo["memo"] = "自费"
  9542. bytesData, _ := json.Marshal(memo)
  9543. fsiOPFLD.Memo = string(bytesData)
  9544. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9545. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9546. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9547. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9548. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9549. fsiOPFLD.BilgDeptName = department.Name
  9550. fsiOPFLD.BilgDeptCodg = department.Number
  9551. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9552. fsiOPFLD.BilgDrName = doctor.UserName
  9553. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9554. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9555. fsiOPFLD.MedChrgitmType = "08"
  9556. memo["hosp_appr_flag"] = "1"
  9557. memo["invoice_no"] = order.MdtrtId
  9558. memo["memo"] = "自费"
  9559. bytesData, _ := json.Marshal(memo)
  9560. fsiOPFLD.Memo = string(bytesData)
  9561. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9562. }
  9563. }
  9564. }
  9565. fmt.Println(fsiOPFLDs)
  9566. struct4201A.Fopfd = fsiOPFLDs
  9567. fmt.Println(struct4201A.Fopfd)
  9568. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9569. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9570. var res2 ResultSix
  9571. var respJSON2 map[string]interface{}
  9572. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9575. return
  9576. }
  9577. userJSONBytes2, _ := json.Marshal(respJSON2)
  9578. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9579. utils.ErrorLog("解析失败:%v", err)
  9580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9581. return
  9582. }
  9583. if res2.Infcode != 0 {
  9584. c.ServeSuccessJSON(map[string]interface{}{
  9585. "failed_code": -10,
  9586. "msg": res2.ErrMsg,
  9587. })
  9588. return
  9589. } else {
  9590. order.IsUploadOrderInfo = 1
  9591. service.UpdateOrder(order)
  9592. c.ServeSuccessJSON(map[string]interface{}{
  9593. "msg": "上传成功",
  9594. })
  9595. }
  9596. }
  9597. func (c *HisApiController) Get4202() {
  9598. order_id, _ := c.GetInt64("order_id")
  9599. admin_user_id, _ := c.GetInt64("admin_user_id")
  9600. order, _ := service.GetHisOrderByIDTwo(order_id)
  9601. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9602. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9603. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9604. if order.ID == 0 {
  9605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9606. return
  9607. }
  9608. var struct4202 models.Struct4202
  9609. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9610. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9611. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9612. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9613. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9614. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9615. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9616. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9617. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9618. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9619. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9620. var config []*models.HisXtDiagnoseConfig
  9621. for _, item := range diagnosis_ids {
  9622. id, _ := strconv.ParseInt(item, 10, 64)
  9623. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9624. config = append(config, &diagnosisConfig)
  9625. }
  9626. var tempDiaginfos []models.OwnPayPatnDiagListD
  9627. for index, item := range config {
  9628. if index == 0 {
  9629. var tempDiaginfo models.OwnPayPatnDiagListD
  9630. tempDiaginfo.InoutDiagType = "1"
  9631. tempDiaginfo.DiagCode = item.CountryCode
  9632. tempDiaginfo.DiagName = item.CountryContentName
  9633. tempDiaginfo.DiagType = "1"
  9634. tempDiaginfo.DiagSrtNo = "1"
  9635. tempDiaginfo.MaindiagFlag = "1"
  9636. tempDiaginfo.ValiFlag = "1"
  9637. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9638. } else {
  9639. var tempDiaginfo models.OwnPayPatnDiagListD
  9640. tempDiaginfo.DiagCode = item.CountryCode
  9641. tempDiaginfo.DiagName = item.CountryContentName
  9642. tempDiaginfo.DiagType = "2"
  9643. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9644. tempDiaginfo.MaindiagFlag = "0"
  9645. tempDiaginfo.ValiFlag = "1"
  9646. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9647. }
  9648. }
  9649. struct4202.ODiagListD = tempDiaginfos
  9650. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9651. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9652. var res2 ResultSix
  9653. var respJSON2 map[string]interface{}
  9654. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9657. return
  9658. }
  9659. userJSONBytes2, _ := json.Marshal(respJSON2)
  9660. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9661. utils.ErrorLog("解析失败:%v", err)
  9662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9663. return
  9664. }
  9665. if res2.Infcode != 0 {
  9666. c.ServeSuccessJSON(map[string]interface{}{
  9667. "failed_code": -10,
  9668. "msg": res2.ErrMsg,
  9669. })
  9670. return
  9671. } else {
  9672. order.IsUploadDiagnose = 1
  9673. service.UpdateOrder(order)
  9674. c.ServeSuccessJSON(map[string]interface{}{
  9675. "msg": "上传成功",
  9676. })
  9677. }
  9678. }
  9679. func (c *HisApiController) Get4203() {
  9680. admin_user_id, _ := c.GetInt64("admin_user_id")
  9681. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9682. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9683. order_id, _ := c.GetInt64("order_id")
  9684. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9685. number := ""
  9686. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9687. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9688. if his.ID == 0 {
  9689. number = hospital.Number
  9690. } else {
  9691. number = his.Number
  9692. }
  9693. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9694. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9695. var res2 ResultSix
  9696. var respJSON2 map[string]interface{}
  9697. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9700. return
  9701. }
  9702. userJSONBytes2, _ := json.Marshal(respJSON2)
  9703. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9704. utils.ErrorLog("解析失败:%v", err)
  9705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9706. return
  9707. }
  9708. if res2.Infcode != 0 {
  9709. c.ServeSuccessJSON(map[string]interface{}{
  9710. "failed_code": -10,
  9711. "msg": res2.ErrMsg,
  9712. })
  9713. return
  9714. } else {
  9715. order.IsUploadSuccess = 1
  9716. service.UpdateOrderTwo(order)
  9717. c.ServeSuccessJSON(map[string]interface{}{
  9718. "msg": "上传成功",
  9719. })
  9720. }
  9721. }
  9722. func (c *HisApiController) Get4205() {
  9723. order_id, _ := c.GetInt64("order_id")
  9724. admin_user_id, _ := c.GetInt64("admin_user_id")
  9725. fapiao_code := c.GetString("fapiao_code")
  9726. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9727. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9728. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9729. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9730. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9731. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9732. //order_info = append(order_info, order_info_two...)
  9733. department, _ := service.GetDepartMentDetail(his.Departments)
  9734. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9735. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9736. if order.ID == 0 {
  9737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9738. return
  9739. }
  9740. var struct4201A models.Struct4201A
  9741. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9742. for _, items := range order_info {
  9743. memo := make(map[string]interface{})
  9744. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9745. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9746. fsiOPFLD.MedType = pre.MedType
  9747. fsiOPFLD.FixmedinsCode = miConfig.Code
  9748. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9749. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9750. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9751. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9752. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9753. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.StartTime, 0).Format("2006-01-02 15:04:05")
  9754. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9755. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9756. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9757. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9758. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9759. fsiOPFLD.BilgDeptName = department.Name
  9760. fsiOPFLD.BilgDeptCodg = department.Number
  9761. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9762. fsiOPFLD.BilgDrName = doctor.UserName
  9763. fsiOPFLD.MedChrgitmType = "09"
  9764. memo["hosp_appr_flag"] = "1"
  9765. memo["invoice_no"] = fapiao_code
  9766. memo["memo"] = "自费"
  9767. bytesData, _ := json.Marshal(memo)
  9768. fsiOPFLD.Memo = string(bytesData)
  9769. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9770. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9771. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9772. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9773. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.StartTime, 0).Format("2006-01-02 15:04:05")
  9774. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9775. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9776. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9777. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9778. fsiOPFLD.BilgDeptName = department.Name
  9779. fsiOPFLD.BilgDeptCodg = department.Number
  9780. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9781. fsiOPFLD.BilgDrName = doctor.UserName
  9782. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9783. case 0:
  9784. break
  9785. case 1:
  9786. fsiOPFLD.MedChrgitmType = "14"
  9787. break
  9788. case 2:
  9789. fsiOPFLD.MedChrgitmType = "05"
  9790. break
  9791. case 3:
  9792. fsiOPFLD.MedChrgitmType = "03"
  9793. break
  9794. case 4:
  9795. fsiOPFLD.MedChrgitmType = "03"
  9796. break
  9797. case 5:
  9798. fsiOPFLD.MedChrgitmType = "08"
  9799. break
  9800. case 6:
  9801. fsiOPFLD.MedChrgitmType = "14"
  9802. break
  9803. case 7:
  9804. fsiOPFLD.MedChrgitmType = "14"
  9805. break
  9806. case 8:
  9807. fsiOPFLD.MedChrgitmType = "03"
  9808. break
  9809. case 9:
  9810. fsiOPFLD.MedChrgitmType = "14"
  9811. break
  9812. case 10:
  9813. fsiOPFLD.MedChrgitmType = "14"
  9814. break
  9815. case 11:
  9816. fsiOPFLD.MedChrgitmType = "06"
  9817. break
  9818. case 12:
  9819. fsiOPFLD.MedChrgitmType = "12"
  9820. break
  9821. case 13:
  9822. fsiOPFLD.MedChrgitmType = "01"
  9823. break
  9824. case 14:
  9825. fsiOPFLD.MedChrgitmType = "04"
  9826. break
  9827. case 15:
  9828. fsiOPFLD.MedChrgitmType = "14"
  9829. break
  9830. }
  9831. memo["hosp_appr_flag"] = "1"
  9832. memo["invoice_no"] = fapiao_code
  9833. memo["memo"] = "自费"
  9834. bytesData, _ := json.Marshal(memo)
  9835. fsiOPFLD.Memo = string(bytesData)
  9836. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9837. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9838. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9839. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9840. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9841. fsiOPFLD.BilgDeptName = department.Name
  9842. fsiOPFLD.BilgDeptCodg = department.Number
  9843. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9844. fsiOPFLD.BilgDrName = doctor.UserName
  9845. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9846. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9847. fsiOPFLD.MedChrgitmType = "08"
  9848. memo["hosp_appr_flag"] = "1"
  9849. memo["invoice_no"] = fapiao_code
  9850. memo["memo"] = "自费"
  9851. bytesData, _ := json.Marshal(memo)
  9852. fsiOPFLD.Memo = string(bytesData)
  9853. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9854. }
  9855. }
  9856. }
  9857. for _, items := range order_info_two {
  9858. memo := make(map[string]interface{})
  9859. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9860. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9861. fsiOPFLD.MedType = pre.MedType
  9862. fsiOPFLD.BkkpSn = items.FeedetlSn
  9863. fsiOPFLD.FixmedinsCode = miConfig.Code
  9864. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9865. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9866. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9867. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9868. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9869. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9870. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9871. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9872. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9873. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9874. fsiOPFLD.BilgDeptName = department.Name
  9875. fsiOPFLD.BilgDeptCodg = department.Number
  9876. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9877. fsiOPFLD.BilgDrName = doctor.UserName
  9878. fsiOPFLD.MedChrgitmType = "09"
  9879. memo["hosp_appr_flag"] = "1"
  9880. memo["invoice_no"] = fapiao_code
  9881. memo["memo"] = "自费"
  9882. bytesData, _ := json.Marshal(memo)
  9883. fsiOPFLD.Memo = string(bytesData)
  9884. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9885. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9886. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9887. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9888. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9889. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9890. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9891. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9892. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9893. fsiOPFLD.BilgDeptName = department.Name
  9894. fsiOPFLD.BilgDeptCodg = department.Number
  9895. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9896. fsiOPFLD.BilgDrName = doctor.UserName
  9897. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9898. case 0:
  9899. break
  9900. case 1:
  9901. fsiOPFLD.MedChrgitmType = "14"
  9902. break
  9903. case 2:
  9904. fsiOPFLD.MedChrgitmType = "05"
  9905. break
  9906. case 3:
  9907. fsiOPFLD.MedChrgitmType = "03"
  9908. break
  9909. case 4:
  9910. fsiOPFLD.MedChrgitmType = "03"
  9911. break
  9912. case 5:
  9913. fsiOPFLD.MedChrgitmType = "08"
  9914. break
  9915. case 6:
  9916. fsiOPFLD.MedChrgitmType = "14"
  9917. break
  9918. case 7:
  9919. fsiOPFLD.MedChrgitmType = "14"
  9920. break
  9921. case 8:
  9922. fsiOPFLD.MedChrgitmType = "03"
  9923. break
  9924. case 9:
  9925. fsiOPFLD.MedChrgitmType = "14"
  9926. break
  9927. case 10:
  9928. fsiOPFLD.MedChrgitmType = "14"
  9929. break
  9930. case 11:
  9931. fsiOPFLD.MedChrgitmType = "06"
  9932. break
  9933. case 12:
  9934. fsiOPFLD.MedChrgitmType = "12"
  9935. break
  9936. case 13:
  9937. fsiOPFLD.MedChrgitmType = "01"
  9938. break
  9939. case 14:
  9940. fsiOPFLD.MedChrgitmType = "04"
  9941. break
  9942. case 15:
  9943. fsiOPFLD.MedChrgitmType = "14"
  9944. break
  9945. }
  9946. memo["hosp_appr_flag"] = "1"
  9947. memo["invoice_no"] = fapiao_code
  9948. memo["memo"] = "自费"
  9949. bytesData, _ := json.Marshal(memo)
  9950. fsiOPFLD.Memo = string(bytesData)
  9951. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9952. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9953. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9954. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9955. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9956. fsiOPFLD.BilgDeptName = department.Name
  9957. fsiOPFLD.BilgDeptCodg = department.Number
  9958. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9959. fsiOPFLD.BilgDrName = doctor.UserName
  9960. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9961. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9962. fsiOPFLD.MedChrgitmType = "08"
  9963. memo["hosp_appr_flag"] = "1"
  9964. memo["invoice_no"] = fapiao_code
  9965. memo["memo"] = "自费"
  9966. bytesData, _ := json.Marshal(memo)
  9967. fsiOPFLD.Memo = string(bytesData)
  9968. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9969. }
  9970. }
  9971. }
  9972. fmt.Println(fsiOPFLDs)
  9973. struct4201A.Fopfd = fsiOPFLDs
  9974. fmt.Println(struct4201A.Fopfd)
  9975. var struct4202 models.Struct4202
  9976. timeLayout := "2006-01-02 15:04:05"
  9977. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9978. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9979. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9980. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9981. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9982. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9983. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9984. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9985. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9986. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9987. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9988. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9989. var config []*models.HisXtDiagnoseConfig
  9990. for _, item := range diagnosis_ids {
  9991. id, _ := strconv.ParseInt(item, 10, 64)
  9992. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9993. config = append(config, &diagnosisConfig)
  9994. }
  9995. var tempDiaginfos []models.OwnPayPatnDiagListD
  9996. for index, item := range config {
  9997. if index == 0 {
  9998. var tempDiaginfo models.OwnPayPatnDiagListD
  9999. tempDiaginfo.InoutDiagType = "1"
  10000. tempDiaginfo.DiagCode = item.CountryCode
  10001. tempDiaginfo.DiagName = item.CountryContentName
  10002. tempDiaginfo.DiagType = "1"
  10003. tempDiaginfo.DiagSrtNo = "1"
  10004. tempDiaginfo.MaindiagFlag = "1"
  10005. tempDiaginfo.ValiFlag = "1"
  10006. tempDiaginfo.DiagDrName = doctor.UserName
  10007. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  10008. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  10009. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  10010. } else {
  10011. var tempDiaginfo models.OwnPayPatnDiagListD
  10012. tempDiaginfo.DiagCode = item.CountryCode
  10013. tempDiaginfo.DiagName = item.CountryContentName
  10014. tempDiaginfo.DiagType = "2"
  10015. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  10016. tempDiaginfo.MaindiagFlag = "0"
  10017. tempDiaginfo.ValiFlag = "1"
  10018. tempDiaginfo.DiagDrName = doctor.UserName
  10019. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  10020. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  10021. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  10022. }
  10023. }
  10024. struct4202.ODiagListD = tempDiaginfos
  10025. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  10026. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  10027. var res2 ResultSix
  10028. var respJSON2 map[string]interface{}
  10029. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10032. return
  10033. }
  10034. userJSONBytes2, _ := json.Marshal(respJSON2)
  10035. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10036. utils.ErrorLog("解析失败:%v", err)
  10037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10038. return
  10039. }
  10040. if res2.Infcode != 0 {
  10041. c.ServeSuccessJSON(map[string]interface{}{
  10042. "failed_code": -10,
  10043. "msg": res2.ErrMsg,
  10044. })
  10045. return
  10046. } else {
  10047. order.IsUploadDiagnose = 1
  10048. order.IsUploadOrderInfo = 1
  10049. service.UpdateOrderTwo(order)
  10050. c.ServeSuccessJSON(map[string]interface{}{
  10051. "msg": "上传成功",
  10052. })
  10053. }
  10054. }
  10055. func (c *HisApiController) Get4207() {
  10056. admin_user_id, _ := c.GetInt64("admin_user_id")
  10057. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10058. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10059. order_id, _ := c.GetInt64("order_id")
  10060. order, _ := service.GetHisOrderByIDTwo(order_id)
  10061. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10062. var struct4207 models.Struct4207
  10063. struct4207.PageNum = "1"
  10064. struct4207.PageSize = "1000"
  10065. struct4207.FixmedinsCode = miConfig.Code
  10066. struct4207.FixmedinsMdtrtID = order.Number
  10067. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  10068. saveLog(result, requestLog, "4207", "查询")
  10069. var res2 ResultSix
  10070. var respJSON2 map[string]interface{}
  10071. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10074. return
  10075. }
  10076. userJSONBytes2, _ := json.Marshal(respJSON2)
  10077. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10078. utils.ErrorLog("解析失败:%v", err)
  10079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10080. return
  10081. }
  10082. if res2.Infcode != 0 {
  10083. c.ServeSuccessJSON(map[string]interface{}{
  10084. "failed_code": -10,
  10085. "msg": res2.ErrMsg,
  10086. })
  10087. return
  10088. } else {
  10089. c.ServeSuccessJSON(map[string]interface{}{
  10090. "msg": "查询成功",
  10091. })
  10092. }
  10093. }
  10094. func (c *HisApiController) Get4208() {
  10095. admin_user_id, _ := c.GetInt64("admin_user_id")
  10096. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10097. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10098. order_id, _ := c.GetInt64("order_id")
  10099. order, _ := service.GetHisOrderByIDTwo(order_id)
  10100. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10101. var struct4208 models.Struct4208
  10102. struct4208.PageNum = "1"
  10103. struct4208.PageSize = "1000"
  10104. struct4208.PsnCertType = "01"
  10105. struct4208.Certno = his.Certno
  10106. struct4208.MedType = order.MedType
  10107. struct4208.PsnName = his.Name
  10108. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  10109. saveLog(result, requestLog, "4208", "查询")
  10110. var res2 ResultSix
  10111. var respJSON2 map[string]interface{}
  10112. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10115. return
  10116. }
  10117. userJSONBytes2, _ := json.Marshal(respJSON2)
  10118. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10119. utils.ErrorLog("解析失败:%v", err)
  10120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10121. return
  10122. }
  10123. if res2.Infcode != 0 {
  10124. c.ServeSuccessJSON(map[string]interface{}{
  10125. "failed_code": -10,
  10126. "msg": res2.ErrMsg,
  10127. })
  10128. return
  10129. } else {
  10130. c.ServeSuccessJSON(map[string]interface{}{
  10131. "msg": "查询成功",
  10132. })
  10133. }
  10134. }
  10135. func (c *HisApiController) Get4209() {
  10136. admin_user_id, _ := c.GetInt64("admin_user_id")
  10137. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10138. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10139. order_id, _ := c.GetInt64("order_id")
  10140. order, _ := service.GetHisOrderByIDTwo(order_id)
  10141. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10142. var struct4209 models.Struct4209
  10143. struct4209.FixmedinsMdtrtID = order.Number
  10144. struct4209.FixmedinsCode = miConfig.Code
  10145. struct4209.PageSize = "1000"
  10146. struct4209.PageNum = "1"
  10147. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  10148. saveLog(result, requestLog, "4209", "查询")
  10149. var res2 ResultSix
  10150. var respJSON2 map[string]interface{}
  10151. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10154. return
  10155. }
  10156. userJSONBytes2, _ := json.Marshal(respJSON2)
  10157. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10158. utils.ErrorLog("解析失败:%v", err)
  10159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10160. return
  10161. }
  10162. if res2.Infcode != 0 {
  10163. c.ServeSuccessJSON(map[string]interface{}{
  10164. "failed_code": -10,
  10165. "msg": res2.ErrMsg,
  10166. })
  10167. return
  10168. } else {
  10169. c.ServeSuccessJSON(map[string]interface{}{
  10170. "msg": "查询成功",
  10171. })
  10172. }
  10173. }
  10174. type Result3101 struct {
  10175. Infcode string `json:"infcode"`
  10176. InfRefmsgid string `json:"inf_refmsgid"`
  10177. RefmsgTime string `json:"refmsg_time"`
  10178. RespondTime string `json:"respond_time"`
  10179. Enctype string `json:"enctype"`
  10180. Signtype string `json:"signtype"`
  10181. ErrMsg string `json:"err_msg"`
  10182. Output struct {
  10183. Result []struct {
  10184. JudgeResultDetailDtos []struct {
  10185. VolaItemType string `json:"vola_item_type"`
  10186. MdtrtID string `json:"mdtrt_id"`
  10187. JrdID string `json:"jrd_id"`
  10188. PatnID string `json:"patn_id"`
  10189. RxID string `json:"rx_id"`
  10190. VolaAmt interface{} `json:"vola_amt"`
  10191. } `json:"judge_result_detail_dtos"`
  10192. RuleID string `json:"rule_id"`
  10193. VolaEvid string `json:"vola_evid"`
  10194. MdtrtID string `json:"mdtrt_id"`
  10195. RuleName string `json:"rule_name"`
  10196. VolaAmtStas string `json:"vola_amt_stas"`
  10197. JrID string `json:"jr_id"`
  10198. PatnID string `json:"patn_id"`
  10199. SevDeg string `json:"sev_deg"`
  10200. VolaAmt float64 `json:"vola_amt"`
  10201. VolaBhvrType string `json:"vola_bhvr_type"`
  10202. VolaCont string `json:"vola_cont"`
  10203. } `json:"result"`
  10204. } `json:"output"`
  10205. }
  10206. type Resultgd3101 struct {
  10207. Infcode int64 `json:"infcode"`
  10208. InfRefmsgid string `json:"inf_refmsgid"`
  10209. RefmsgTime string `json:"refmsg_time"`
  10210. RespondTime string `json:"respond_time"`
  10211. Enctype string `json:"enctype"`
  10212. Signtype string `json:"signtype"`
  10213. ErrMsg string `json:"err_msg"`
  10214. Output struct {
  10215. Result []struct {
  10216. JudgeResultDetailDtos []struct {
  10217. VolaItemType string `json:"vola_item_type"`
  10218. MdtrtID string `json:"mdtrt_id"`
  10219. JrdID string `json:"jrd_id"`
  10220. PatnID string `json:"patn_id"`
  10221. RxID string `json:"rx_id"`
  10222. VolaAmt interface{} `json:"vola_amt"`
  10223. } `json:"judge_result_detail_dtos"`
  10224. RuleID string `json:"rule_id"`
  10225. VolaEvid string `json:"vola_evid"`
  10226. MdtrtID string `json:"mdtrt_id"`
  10227. RuleName string `json:"rule_name"`
  10228. VolaAmtStas string `json:"vola_amt_stas"`
  10229. JrID string `json:"jr_id"`
  10230. PatnID string `json:"patn_id"`
  10231. SevDeg string `json:"sev_deg"`
  10232. VolaAmt float64 `json:"vola_amt"`
  10233. VolaBhvrType string `json:"vola_bhvr_type"`
  10234. VolaCont string `json:"vola_cont"`
  10235. } `json:"result"`
  10236. } `json:"output"`
  10237. }
  10238. func (c *HisApiController) ReadEleToken() {
  10239. admin_user_id, _ := c.GetInt64("admin_user_id")
  10240. his_patient_id, _ := c.GetInt64("his_patient_id")
  10241. adminUser := c.GetAdminUserInfo()
  10242. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10243. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10244. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10245. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10246. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10247. if len(tokens) > 0 {
  10248. c.ServeSuccessJSON(map[string]interface{}{
  10249. "msg": "读取成功",
  10250. })
  10251. } else {
  10252. c.ServeSuccessJSON(map[string]interface{}{
  10253. "failed_code": -10,
  10254. "msg": "读取失败",
  10255. })
  10256. }
  10257. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10258. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10259. if len(tokens) > 0 {
  10260. c.ServeSuccessJSON(map[string]interface{}{
  10261. "msg": "读取成功",
  10262. })
  10263. } else {
  10264. c.ServeSuccessJSON(map[string]interface{}{
  10265. "failed_code": -10,
  10266. "msg": "读取失败",
  10267. })
  10268. }
  10269. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10270. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10271. if len(tokens) > 0 {
  10272. c.ServeSuccessJSON(map[string]interface{}{
  10273. "msg": "读取成功",
  10274. })
  10275. } else {
  10276. c.ServeSuccessJSON(map[string]interface{}{
  10277. "failed_code": -10,
  10278. "msg": "读取失败",
  10279. })
  10280. }
  10281. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10282. var api string
  10283. 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 +
  10284. "&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"
  10285. resp, requestErr := http.Get(api)
  10286. if requestErr != nil {
  10287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10288. }
  10289. body, ioErr := ioutil.ReadAll(resp.Body)
  10290. if ioErr != nil {
  10291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10293. }
  10294. var respJSON map[string]interface{}
  10295. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10298. return
  10299. }
  10300. var status string
  10301. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10302. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10303. var token string
  10304. var res ResultTwo //1101结果
  10305. var res10265 ResultTwo10265 //1101结果
  10306. if status == "0" { //读卡成功
  10307. var card_info string //卡信息
  10308. var busi_card_info string
  10309. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10310. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10311. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10312. fmt.Println(card_info)
  10313. fmt.Println(busi_card_info)
  10314. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10315. result, _ := json.Marshal(respJSON)
  10316. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10317. utils.ErrorLog("解析失败:%v", err)
  10318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10319. return
  10320. }
  10321. res.ErrMsg = res10265.ErrMsg
  10322. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10323. res.Infcode = infocode
  10324. res.Output = res10265.Output
  10325. res.InfRefmsgid = res10265.InfRefmsgid
  10326. if res.Infcode == 0 {
  10327. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10328. if err == gorm.ErrRecordNotFound {
  10329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10330. return
  10331. } else if err != nil {
  10332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10333. return
  10334. } else {
  10335. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10336. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10337. infoStr := string(Iinfos)
  10338. idetinfoStr := string(Idetinfos)
  10339. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  10340. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10341. psn := &models.HisPsn{
  10342. PsnNo: res.Output.Baseinfo.PsnNo,
  10343. PatientId: patient.ID,
  10344. Certno: res.Output.Baseinfo.Certno,
  10345. Gend: res.Output.Baseinfo.Gend,
  10346. Naty: res.Output.Baseinfo.Naty,
  10347. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10348. PsnName: res.Output.Baseinfo.PsnName,
  10349. Age: float64(age),
  10350. Brdy: b,
  10351. Idetinfo: idetinfoStr,
  10352. Insuinfo: infoStr,
  10353. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10354. CardInfo: card_info,
  10355. VerifyNumber: token,
  10356. IdCardType: 4,
  10357. }
  10358. var rf []*ResultFive
  10359. json.Unmarshal([]byte(infoStr), &rf)
  10360. var insutypes []*ResultFive
  10361. var insutype string
  10362. var is390 int = 0
  10363. var is310 int = 0
  10364. for _, item := range rf {
  10365. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10366. insutypes = append(insutypes, item)
  10367. }
  10368. }
  10369. if len(insutypes) == 1 {
  10370. insutype = insutypes[0].Insutype
  10371. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10372. } else {
  10373. for _, i := range insutypes {
  10374. if i.Insutype == "390" {
  10375. is390 = 1
  10376. }
  10377. if i.Insutype == "310" {
  10378. is310 = 1
  10379. }
  10380. }
  10381. }
  10382. if is390 == 1 {
  10383. insutype = "390"
  10384. }
  10385. if is310 == 1 {
  10386. insutype = "310"
  10387. }
  10388. if len(insutypes) == 0 {
  10389. insutype = "310"
  10390. }
  10391. service.CreateHisPsn(psn)
  10392. c.ServeSuccessJSON(map[string]interface{}{
  10393. "patient": patient,
  10394. "number": token,
  10395. "insutype": insutype,
  10396. })
  10397. }
  10398. } else {
  10399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10400. return
  10401. }
  10402. } else { //读卡失败
  10403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10404. return
  10405. }
  10406. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10407. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  10408. if len(errMsg) == 0 {
  10409. type ELeData struct {
  10410. Data struct {
  10411. IdNo string `json:"idNo"`
  10412. IdType string `json:"idType"`
  10413. UserName string `json:"userName"`
  10414. EcToken string `json:"ecToken"`
  10415. InsuOrg string `json:"insuOrg"`
  10416. Gender string `json:"gender"`
  10417. Birthday string `json:"birthday"`
  10418. Nationality string `json:"nationality"`
  10419. Email string `json:"email"`
  10420. Extra string `json:"extra"`
  10421. } `json:"data"`
  10422. Code int `json:"code"`
  10423. Message string `json:"message"`
  10424. }
  10425. var ele ELeData
  10426. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10427. if err != nil {
  10428. utils.ErrorLog("解析失败:%v", err)
  10429. }
  10430. token := ele.Data.EcToken
  10431. if len(token) > 0 {
  10432. psn := &models.HisPsn{
  10433. PsnNo: his.PsnNo,
  10434. Age: 0,
  10435. PatientId: his.PatientId,
  10436. Certno: his.Certno,
  10437. Brdy: his.Brdy,
  10438. Gend: his.Gend,
  10439. Naty: his.Naty,
  10440. PsnCertType: his.PsnCertType,
  10441. PsnName: his.PsnName,
  10442. Idetinfo: his.Idetinfo,
  10443. Insuinfo: his.Iinfo,
  10444. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10445. CardInfo: outPutInfo,
  10446. VerifyNumber: token,
  10447. }
  10448. service.CreateHisPsn(psn)
  10449. }
  10450. if len(token) > 0 {
  10451. c.ServeSuccessJSON(map[string]interface{}{
  10452. "msg": "读取成功",
  10453. })
  10454. } else {
  10455. c.ServeSuccessJSON(map[string]interface{}{
  10456. "failed_code": -10,
  10457. "msg": "读取失败",
  10458. })
  10459. }
  10460. }
  10461. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10462. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10463. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10464. type ELeData struct {
  10465. Data struct {
  10466. IdNo string `json:"idNo"`
  10467. IdType string `json:"idType"`
  10468. UserName string `json:"userName"`
  10469. EcToken string `json:"ecToken"`
  10470. InsuOrg string `json:"insuOrg"`
  10471. Gender string `json:"gender"`
  10472. Birthday string `json:"birthday"`
  10473. Nationality string `json:"nationality"`
  10474. Email string `json:"email"`
  10475. Extra string `json:"extra"`
  10476. } `json:"data"`
  10477. Code int `json:"code"`
  10478. Message string `json:"message"`
  10479. }
  10480. var ele ELeData
  10481. err := json.Unmarshal([]byte(result), &ele)
  10482. if err != nil {
  10483. utils.ErrorLog("解析失败:%v", err)
  10484. }
  10485. token := ele.Data.EcToken
  10486. token = Remove0000(token)
  10487. fmt.Println(ele.Data.UserName)
  10488. 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)
  10489. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10490. var res ResultTwo
  10491. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10492. utils.ErrorLog("解析失败:%v", err)
  10493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10494. return
  10495. }
  10496. if res.Infcode == 0 {
  10497. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10498. if err == gorm.ErrRecordNotFound {
  10499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10500. return
  10501. } else if err != nil {
  10502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10503. return
  10504. } else {
  10505. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10506. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10507. infoStr := string(Iinfos)
  10508. idetinfoStr := string(Idetinfos)
  10509. psn := &models.HisPsn{
  10510. PsnNo: res.Output.Baseinfo.PsnNo,
  10511. PatientId: patient.ID,
  10512. Certno: res.Output.Baseinfo.Certno,
  10513. Gend: res.Output.Baseinfo.Gend,
  10514. Naty: res.Output.Baseinfo.Naty,
  10515. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10516. PsnName: res.Output.Baseinfo.PsnName,
  10517. Idetinfo: idetinfoStr,
  10518. Insuinfo: infoStr,
  10519. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10520. CardInfo: "",
  10521. VerifyNumber: token,
  10522. }
  10523. service.CreateHisPsn(psn)
  10524. c.ServeSuccessJSON(map[string]interface{}{
  10525. "patient": patient,
  10526. "number": token,
  10527. })
  10528. }
  10529. } else {
  10530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10531. return
  10532. }
  10533. } else if miConfig.MdtrtareaAdmvs == "361025" {
  10534. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10535. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10536. type ELeData struct {
  10537. Data struct {
  10538. IdNo string `json:"idNo"`
  10539. IdType string `json:"idType"`
  10540. UserName string `json:"userName"`
  10541. EcToken string `json:"ecToken"`
  10542. InsuOrg string `json:"insuOrg"`
  10543. Gender string `json:"gender"`
  10544. Birthday string `json:"birthday"`
  10545. Nationality string `json:"nationality"`
  10546. Email string `json:"email"`
  10547. Extra string `json:"extra"`
  10548. } `json:"data"`
  10549. Code int `json:"code"`
  10550. Message string `json:"message"`
  10551. }
  10552. var ele ELeData
  10553. err := json.Unmarshal([]byte(result), &ele)
  10554. if err != nil {
  10555. utils.ErrorLog("解析失败:%v", err)
  10556. }
  10557. token := ele.Data.EcToken
  10558. token = Remove0000(token)
  10559. fmt.Println(ele.Data.UserName)
  10560. 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)
  10561. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10562. var res ResultTwo
  10563. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10564. utils.ErrorLog("解析失败:%v", err)
  10565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10566. return
  10567. }
  10568. if res.Infcode == 0 {
  10569. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10570. if err == gorm.ErrRecordNotFound {
  10571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10572. return
  10573. } else if err != nil {
  10574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10575. return
  10576. } else {
  10577. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10578. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10579. infoStr := string(Iinfos)
  10580. idetinfoStr := string(Idetinfos)
  10581. psn := &models.HisPsn{
  10582. PsnNo: res.Output.Baseinfo.PsnNo,
  10583. PatientId: patient.ID,
  10584. Certno: res.Output.Baseinfo.Certno,
  10585. Gend: res.Output.Baseinfo.Gend,
  10586. Naty: res.Output.Baseinfo.Naty,
  10587. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10588. PsnName: res.Output.Baseinfo.PsnName,
  10589. Idetinfo: idetinfoStr,
  10590. Insuinfo: infoStr,
  10591. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10592. CardInfo: "",
  10593. VerifyNumber: token,
  10594. }
  10595. service.CreateHisPsn(psn)
  10596. c.ServeSuccessJSON(map[string]interface{}{
  10597. "patient": patient,
  10598. "number": token,
  10599. })
  10600. }
  10601. } else {
  10602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10603. return
  10604. }
  10605. } else if miConfig.MdtrtareaAdmvs == "360100" {
  10606. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10607. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10608. type ELeData struct {
  10609. Data struct {
  10610. IdNo string `json:"idNo"`
  10611. IdType string `json:"idType"`
  10612. UserName string `json:"userName"`
  10613. EcToken string `json:"ecToken"`
  10614. InsuOrg string `json:"insuOrg"`
  10615. Gender string `json:"gender"`
  10616. Birthday string `json:"birthday"`
  10617. Nationality string `json:"nationality"`
  10618. Email string `json:"email"`
  10619. Extra string `json:"extra"`
  10620. } `json:"data"`
  10621. Code int `json:"code"`
  10622. Message string `json:"message"`
  10623. }
  10624. var ele ELeData
  10625. err := json.Unmarshal([]byte(result), &ele)
  10626. if err != nil {
  10627. utils.ErrorLog("解析失败:%v", err)
  10628. }
  10629. token := ele.Data.EcToken
  10630. token = Remove0000(token)
  10631. fmt.Println(ele.Data.UserName)
  10632. 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)
  10633. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10634. var res ResultTwo
  10635. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10636. utils.ErrorLog("解析失败:%v", err)
  10637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10638. return
  10639. }
  10640. if res.Infcode == 0 {
  10641. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10642. if err == gorm.ErrRecordNotFound {
  10643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10644. return
  10645. } else if err != nil {
  10646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10647. return
  10648. } else {
  10649. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10650. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10651. infoStr := string(Iinfos)
  10652. idetinfoStr := string(Idetinfos)
  10653. psn := &models.HisPsn{
  10654. PsnNo: res.Output.Baseinfo.PsnNo,
  10655. PatientId: patient.ID,
  10656. Certno: res.Output.Baseinfo.Certno,
  10657. Gend: res.Output.Baseinfo.Gend,
  10658. Naty: res.Output.Baseinfo.Naty,
  10659. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10660. PsnName: res.Output.Baseinfo.PsnName,
  10661. Idetinfo: idetinfoStr,
  10662. Insuinfo: infoStr,
  10663. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10664. CardInfo: "",
  10665. VerifyNumber: token,
  10666. }
  10667. service.CreateHisPsn(psn)
  10668. c.ServeSuccessJSON(map[string]interface{}{
  10669. "patient": patient,
  10670. "number": token,
  10671. })
  10672. }
  10673. } else {
  10674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10675. return
  10676. }
  10677. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10678. //if initFlag == 0 {
  10679. //c.TestGetJiangXiBasBaseInit()
  10680. //}
  10681. //if initEleFlag == 0 {
  10682. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10683. //}
  10684. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10685. utils.ErrorLog("解析失败:%v", json_result)
  10686. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10687. type ELeData struct {
  10688. Data struct {
  10689. IdNo string `json:"idNo"`
  10690. IdType string `json:"idType"`
  10691. UserName string `json:"userName"`
  10692. EcToken string `json:"ecToken"`
  10693. InsuOrg string `json:"insuOrg"`
  10694. Gender string `json:"gender"`
  10695. Birthday string `json:"birthday"`
  10696. Nationality string `json:"nationality"`
  10697. Email string `json:"email"`
  10698. Extra string `json:"extra"`
  10699. } `json:"data"`
  10700. Code int `json:"code"`
  10701. Message string `json:"message"`
  10702. }
  10703. var ele ELeData
  10704. err := json.Unmarshal([]byte(json_result), &ele)
  10705. if err != nil {
  10706. utils.ErrorLog("解析失败:%v", err)
  10707. }
  10708. token := ele.Data.EcToken
  10709. token = Remove0000(token)
  10710. //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)
  10711. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  10712. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10713. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10714. var res ResultTwo
  10715. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10716. utils.ErrorLog("解析失败:%v", err)
  10717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10718. return
  10719. }
  10720. if res.Infcode == 0 {
  10721. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10722. if err == gorm.ErrRecordNotFound {
  10723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10724. return
  10725. } else if err != nil {
  10726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10727. return
  10728. } else {
  10729. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10730. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10731. infoStr := string(Iinfos)
  10732. idetinfoStr := string(Idetinfos)
  10733. psn := &models.HisPsn{
  10734. PsnNo: res.Output.Baseinfo.PsnNo,
  10735. PatientId: patient.ID,
  10736. Certno: res.Output.Baseinfo.Certno,
  10737. Gend: res.Output.Baseinfo.Gend,
  10738. Naty: res.Output.Baseinfo.Naty,
  10739. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10740. PsnName: res.Output.Baseinfo.PsnName,
  10741. Idetinfo: idetinfoStr,
  10742. Insuinfo: infoStr,
  10743. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10744. CardInfo: "",
  10745. VerifyNumber: token,
  10746. InsuplcAdmdvs: ele.Data.InsuOrg,
  10747. }
  10748. service.CreateHisPsn(psn)
  10749. c.ServeSuccessJSON(map[string]interface{}{
  10750. "patient": patient,
  10751. "number": token,
  10752. })
  10753. }
  10754. } else {
  10755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10756. return
  10757. }
  10758. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10759. res := c.GetoleInfo()
  10760. if res.Infcode == 0 {
  10761. var result string
  10762. if res.Output.MdtrtCertType == "01" {
  10763. 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)
  10764. } else if res.Output.MdtrtCertType == "02" {
  10765. 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)
  10766. } else if res.Output.MdtrtCertType == "03" {
  10767. 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)
  10768. }
  10769. var dat map[string]interface{}
  10770. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10771. fmt.Println(dat)
  10772. } else {
  10773. fmt.Println(err)
  10774. }
  10775. userJSONBytes, _ := json.Marshal(dat)
  10776. var res2 ResultTwo
  10777. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10778. utils.ErrorLog("解析失败:%v", err)
  10779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10780. return
  10781. }
  10782. if res2.Infcode == 0 {
  10783. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10784. if err == gorm.ErrRecordNotFound {
  10785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10786. return
  10787. } else if err != nil {
  10788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10789. return
  10790. } else {
  10791. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10792. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10793. infoStr := string(Iinfos)
  10794. idetinfoStr := string(Idetinfos)
  10795. var rf []*ResultFive
  10796. json.Unmarshal([]byte(infoStr), &rf)
  10797. var insutypes []*ResultFive
  10798. var insutype string
  10799. var is390 int = 0
  10800. var is310 int = 0
  10801. //var insuplc_admdvs string
  10802. for _, item := range rf {
  10803. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10804. insutypes = append(insutypes, item)
  10805. }
  10806. }
  10807. if len(insutypes) == 1 {
  10808. insutype = insutypes[0].Insutype
  10809. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10810. } else {
  10811. for _, i := range insutypes {
  10812. if i.Insutype == "390" {
  10813. is390 = 1
  10814. }
  10815. if i.Insutype == "310" {
  10816. is310 = 1
  10817. }
  10818. }
  10819. }
  10820. if is390 == 1 {
  10821. insutype = "390"
  10822. }
  10823. if is310 == 1 {
  10824. insutype = "310"
  10825. }
  10826. if len(insutypes) == 0 {
  10827. insutype = "310"
  10828. }
  10829. psn := &models.HisPsn{
  10830. PsnNo: res2.Output.Baseinfo.PsnNo,
  10831. PatientId: patient.ID,
  10832. Certno: res2.Output.Baseinfo.Certno,
  10833. Gend: res2.Output.Baseinfo.Gend,
  10834. Naty: res2.Output.Baseinfo.Naty,
  10835. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10836. PsnName: res2.Output.Baseinfo.PsnName,
  10837. Idetinfo: idetinfoStr,
  10838. Insuinfo: infoStr,
  10839. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10840. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10841. VerifyNumber: res.Output.EcToken,
  10842. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10843. }
  10844. service.CreateHisPsn(psn)
  10845. c.ServeSuccessJSON(map[string]interface{}{
  10846. "patient": patient,
  10847. "number": res.Output.CardNo,
  10848. "insutype": insutype,
  10849. })
  10850. }
  10851. } else {
  10852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10853. return
  10854. }
  10855. } else {
  10856. c.ServeSuccessJSON(map[string]interface{}{
  10857. "failed_code": -10,
  10858. "msg": res.ErrMsg,
  10859. })
  10860. }
  10861. } else {
  10862. //if initFlag == 0 {
  10863. // c.TestGetBasBaseInit()
  10864. //}
  10865. //token := c.GetEleBaseInfo()
  10866. //token = Remove0000(token)
  10867. type ELeData struct {
  10868. Code string `json:"code"`
  10869. Data struct {
  10870. Aac002 string `json:"aac002"`
  10871. Aaz500 string `json:"aaz500"`
  10872. ActCardNo string `json:"actCardNo"`
  10873. Bab520 string `json:"bab520"`
  10874. Bkz543 string `json:"bkz543"`
  10875. BusinessType string `json:"businessType"`
  10876. CertfCodg string `json:"certfCodg"`
  10877. EcIndexNo string `json:"ecIndexNo"`
  10878. EcToken string `json:"ecToken"`
  10879. ID0000 string `json:"id0000"`
  10880. IDNo string `json:"idNo"`
  10881. IDType string `json:"idType"`
  10882. Idcode string `json:"idcode"`
  10883. IdentityToken string `json:"identity_token"`
  10884. InsuOrg string `json:"insuOrg"`
  10885. OfficeID string `json:"officeId"`
  10886. OfficeName string `json:"officeName"`
  10887. OperatorID string `json:"operatorId"`
  10888. OperatorName string `json:"operatorName"`
  10889. OrgID string `json:"orgId"`
  10890. UserName string `json:"userName"`
  10891. } `json:"data"`
  10892. Infno interface{} `json:"infno"`
  10893. Message string `json:"message"`
  10894. OrgID string `json:"orgId"`
  10895. TransType string `json:"transType"`
  10896. }
  10897. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10898. fmt.Println(result)
  10899. outPutInfo := Remove0000(result)
  10900. fmt.Println(outPutInfo)
  10901. var ele ELeData
  10902. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10903. if err != nil {
  10904. utils.ErrorLog("解析失败:%v", err)
  10905. }
  10906. token := ele.Data.EcToken
  10907. var result2 string
  10908. var requestLog2 string
  10909. if len(token) > 0 {
  10910. if strings.Contains(ele.Data.IDNo, "HKG") {
  10911. 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)
  10912. } else {
  10913. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10914. }
  10915. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10916. var res ResultTwo
  10917. if err := json.Unmarshal([]byte(result2), &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(res.Output.Baseinfo.Certno, 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. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10932. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10933. infoStr := string(Iinfos)
  10934. idetinfoStr := string(Idetinfos)
  10935. psn := &models.HisPsn{
  10936. PsnNo: res.Output.Baseinfo.PsnNo,
  10937. PatientId: patient.ID,
  10938. Certno: res.Output.Baseinfo.Certno,
  10939. Gend: res.Output.Baseinfo.Gend,
  10940. Naty: res.Output.Baseinfo.Naty,
  10941. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10942. PsnName: res.Output.Baseinfo.PsnName,
  10943. Idetinfo: idetinfoStr,
  10944. Insuinfo: infoStr,
  10945. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10946. CardInfo: "",
  10947. VerifyNumber: token,
  10948. }
  10949. service.CreateHisPsn(psn)
  10950. c.ServeSuccessJSON(map[string]interface{}{
  10951. "msg": "读取成功",
  10952. })
  10953. }
  10954. } else {
  10955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10956. return
  10957. }
  10958. } else {
  10959. c.ServeSuccessJSON(map[string]interface{}{
  10960. "failed_code": -10,
  10961. "msg": "读取失败",
  10962. })
  10963. }
  10964. }
  10965. }
  10966. func (c *HisApiController) ReadEleFace() {
  10967. admin_user_id, _ := c.GetInt64("admin_user_id")
  10968. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10969. adminUser := c.GetAdminUserInfo()
  10970. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10971. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10972. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10973. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10974. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10975. if len(tokens) > 0 {
  10976. c.ServeSuccessJSON(map[string]interface{}{
  10977. "msg": "读取成功",
  10978. })
  10979. } else {
  10980. c.ServeSuccessJSON(map[string]interface{}{
  10981. "failed_code": -10,
  10982. "msg": "读取失败",
  10983. })
  10984. }
  10985. }
  10986. }
  10987. func timestampToBirthdayString(timestamp int64) string {
  10988. // 将时间戳转换为 time.Time
  10989. t := time.Unix(timestamp, 0)
  10990. // 格式化时间为生日字符串,例如 "2006-01-02"
  10991. birthday := t.Format("2006-01-02")
  10992. return birthday
  10993. }
  10994. func (c *HisApiController) Get9001() {
  10995. adminUser := c.GetAdminUserInfo()
  10996. admin_user_id, _ := c.GetInt64("admin_user_id")
  10997. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10998. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10999. if miConfig.MdtrtareaAdmvs == "350500" {
  11000. service.GetFjAuthorizationInfo(miConfig.Code)
  11001. } else if miConfig.MdtrtareaAdmvs == "131023" {
  11002. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  11003. var dat map[string]interface{}
  11004. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11005. fmt.Println(dat)
  11006. } else {
  11007. fmt.Println(err)
  11008. }
  11009. userJSONBytes, _ := json.Marshal(dat)
  11010. var res models.Result9001
  11011. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11012. utils.ErrorLog("解析失败:%v", err)
  11013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11014. return
  11015. }
  11016. } else if miConfig.MdtrtareaAdmvs == "341203" {
  11017. fmt.Println(miConfig.SecretKey)
  11018. var res models.Result9001Two
  11019. 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 +
  11020. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  11021. resp, requestErr := http.Get(api)
  11022. if requestErr != nil {
  11023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11024. return
  11025. }
  11026. body, ioErr := ioutil.ReadAll(resp.Body)
  11027. if ioErr != nil {
  11028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11030. return
  11031. }
  11032. var respJSON map[string]interface{}
  11033. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11036. return
  11037. }
  11038. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11039. if status == "0" {
  11040. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11041. c.ServeSuccessJSON(map[string]interface{}{
  11042. "failed_code": -10,
  11043. "msg": err_msg,
  11044. })
  11045. return
  11046. }
  11047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11048. result, _ := json.Marshal(respJSON)
  11049. fmt.Println("log")
  11050. fmt.Println(string(result))
  11051. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11052. utils.ErrorLog("解析失败:%v", err)
  11053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11054. return
  11055. }
  11056. if res.Infcode == 0 {
  11057. sign := models.HisSignIn{
  11058. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11059. SignNo: res.Output.Signinoutb.SignNo,
  11060. SignTime: "",
  11061. Ctime: time.Now().Unix(),
  11062. Mtime: time.Now().Unix(),
  11063. Status: 1,
  11064. InputLog: "",
  11065. OutputLog: "",
  11066. FixmedinsCode: miConfig.Code,
  11067. }
  11068. err := service.CreateSignIn(&sign)
  11069. if err == nil {
  11070. c.ServeSuccessJSON(map[string]interface{}{
  11071. "msg": "签到成功",
  11072. })
  11073. }
  11074. } else {
  11075. c.ServeSuccessJSON(map[string]interface{}{
  11076. "failed_code": -10,
  11077. "msg": res.ErrMsg,
  11078. })
  11079. return
  11080. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11081. //return
  11082. }
  11083. } else if miConfig.MdtrtareaAdmvs == "340699" {
  11084. fmt.Println(miConfig.SecretKey)
  11085. var res models.Result9001Two
  11086. 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 +
  11087. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  11088. resp, requestErr := http.Get(api)
  11089. if requestErr != nil {
  11090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11091. return
  11092. }
  11093. body, ioErr := ioutil.ReadAll(resp.Body)
  11094. if ioErr != nil {
  11095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11097. return
  11098. }
  11099. var respJSON map[string]interface{}
  11100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11103. return
  11104. }
  11105. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11106. if status == "0" {
  11107. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11108. c.ServeSuccessJSON(map[string]interface{}{
  11109. "failed_code": -10,
  11110. "msg": err_msg,
  11111. })
  11112. return
  11113. }
  11114. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11115. result, _ := json.Marshal(respJSON)
  11116. fmt.Println("log")
  11117. fmt.Println(string(result))
  11118. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11119. utils.ErrorLog("解析失败:%v", err)
  11120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11121. return
  11122. }
  11123. if res.Infcode == 0 {
  11124. sign := models.HisSignIn{
  11125. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11126. SignNo: res.Output.Signinoutb.SignNo,
  11127. SignTime: "",
  11128. Ctime: time.Now().Unix(),
  11129. Mtime: time.Now().Unix(),
  11130. Status: 1,
  11131. InputLog: "",
  11132. OutputLog: "",
  11133. FixmedinsCode: miConfig.Code,
  11134. }
  11135. err := service.CreateSignIn(&sign)
  11136. if err == nil {
  11137. c.ServeSuccessJSON(map[string]interface{}{
  11138. "msg": "签到成功",
  11139. })
  11140. }
  11141. } else {
  11142. c.ServeSuccessJSON(map[string]interface{}{
  11143. "failed_code": -10,
  11144. "msg": res.ErrMsg,
  11145. })
  11146. return
  11147. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11148. //return
  11149. }
  11150. } else {
  11151. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11152. var dat map[string]interface{}
  11153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11154. fmt.Println(dat)
  11155. } else {
  11156. fmt.Println(err)
  11157. }
  11158. userJSONBytes, _ := json.Marshal(dat)
  11159. var res models.Result9001
  11160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11161. utils.ErrorLog("解析失败:%v", err)
  11162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11163. return
  11164. }
  11165. if res.Infcode == 0 {
  11166. sign := models.HisSignIn{
  11167. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11168. SignNo: res.Output.Signinoutb.SignNo,
  11169. SignTime: res.Output.Signinoutb.SignTime,
  11170. Ctime: time.Now().Unix(),
  11171. Mtime: time.Now().Unix(),
  11172. Status: 1,
  11173. InputLog: "",
  11174. OutputLog: "",
  11175. FixmedinsCode: miConfig.Code,
  11176. }
  11177. err := service.CreateSignIn(&sign)
  11178. if err == nil {
  11179. c.ServeSuccessJSON(map[string]interface{}{
  11180. "msg": "签到成功",
  11181. })
  11182. }
  11183. }
  11184. }
  11185. }
  11186. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription, de models.XtHisDepartment) (res2 Result3101) {
  11187. var res Result3101
  11188. adminUser := c.GetAdminUserInfo()
  11189. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11190. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11191. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11192. //record_time := c.GetString("record_time")
  11193. //trig_scen := c.GetString("trig_scen")
  11194. timeLayout := "2006-01-02"
  11195. loc, _ := time.LoadLocation("Local")
  11196. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11197. if err != nil {
  11198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11199. return res
  11200. }
  11201. recordDateTime := theTime.Unix()
  11202. var patientPrescription models.HisPrescriptionInfo
  11203. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11204. //if patientPrescription.ID == 0 {
  11205. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11206. //}
  11207. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11208. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11209. //
  11210. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11211. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11212. var pp models.PublicParams
  11213. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11214. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11215. pp.FixmedinsName = miConfig.OrgName
  11216. pp.FixmedinsCode = miConfig.Code
  11217. pp.RequestUrl = miConfig.Url
  11218. pp.Cainfo = miConfig.Cainfo
  11219. pp.SecretKey = miConfig.SecretKey
  11220. pp.AccessKey = miConfig.AccessKey
  11221. pp.OpterName = roles.UserName
  11222. var config []*models.HisXtDiagnoseConfig
  11223. for _, item := range diagnosis_ids {
  11224. id, _ := strconv.ParseInt(item, 10, 64)
  11225. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11226. config = append(config, &diagnosisConfig)
  11227. }
  11228. var pd models.PatientDtos
  11229. pd.PatnID = his.PsnNo
  11230. pd.PatnName = his.Name
  11231. pd.Gend = his.Gend
  11232. pd.Brdy = his.Brdy
  11233. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11234. pd.CurrMdtrtID = his.Number
  11235. var fed models.FsiEncounterDtos
  11236. fed.MdtrtID = his.Number
  11237. fed.MedinsID = miConfig.Code
  11238. fed.MedinsName = miConfig.OrgName
  11239. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11240. fed.MedMdtrtType = "1"
  11241. fed.MedinsType = "1"
  11242. fed.MedinsLv = "11"
  11243. tm := time.Unix(his.RecordDate, 0)
  11244. s_tm := tm.Format("2006-01-02 15:04:05")
  11245. fed.AdmDate = s_tm
  11246. fed.DscgDate = s_tm
  11247. fed.DscgMainDiseCodg = config[0].CountryCode
  11248. fed.DscgMainDiseName = config[0].CountryContentName
  11249. //诊断信息
  11250. var fdds []*models.FsiDiagnoseDtos
  11251. for index, item := range config {
  11252. if index == 0 {
  11253. var fdd models.FsiDiagnoseDtos
  11254. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11255. fdd.InoutDiseType = "1"
  11256. fdd.MaindiseFlag = "1"
  11257. fdd.DiseDate = s_tm
  11258. fdd.DiasSrtNo = "1"
  11259. fdd.DiseName = item.CountryContentName
  11260. fdd.DiseCodg = item.CountryCode
  11261. fdds = append(fdds, &fdd)
  11262. } else {
  11263. var fdd models.FsiDiagnoseDtos
  11264. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11265. fdd.InoutDiseType = "1"
  11266. fdd.MaindiseFlag = "1"
  11267. fdd.DiseDate = s_tm
  11268. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11269. fdd.DiseName = item.CountryContentName
  11270. fdd.DiseCodg = item.CountryCode
  11271. fdds = append(fdds, &fdd)
  11272. }
  11273. }
  11274. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11275. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11276. fed.AdmDeptName = de.Name
  11277. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11278. fed.DscgDeptName = de.Name
  11279. fed.MedMdtrtType = "1"
  11280. fed.MedType = "11"
  11281. //if his.Insutype == "390" {
  11282. // fed.MedType = "1402"
  11283. //} else {
  11284. // fed.MedType = "9933"
  11285. //}
  11286. var orders []*models.FsiOrderDtos
  11287. if trig_scen == "2" {
  11288. //处方医嘱信息
  11289. for _, item := range prescriptions {
  11290. for _, subItem := range item.HisDoctorAdviceInfo {
  11291. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11292. var order models.FsiOrderDtos
  11293. order.RxID = strconv.FormatInt(item.ID, 10)
  11294. order.Rxno = strconv.FormatInt(item.ID, 10)
  11295. order.LongDrordFlag = "0"
  11296. order.HilistType = "1"
  11297. order.ChrgType = "1"
  11298. order.DrordBhvr = "-"
  11299. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11300. order.HosplistName = subItem.BaseDrugLib.DrugName
  11301. order.HilistLv = "1"
  11302. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11303. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11304. order.HosplistName = subItem.BaseDrugLib.DrugName
  11305. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11306. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11307. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11308. order.OwnpayAmt = ""
  11309. order.SelfpayAmt = ""
  11310. order.Spec = ""
  11311. order.SpecUnt = ""
  11312. order.DrordBegnDate = s_tm
  11313. order.DrordStopDate = ""
  11314. order.DrordDrCodg = doctor_info.DoctorNumber
  11315. order.DrordDeptName = department.Name
  11316. order.DrordDeptCodg = department.Number
  11317. order.DrordDrName = doctor_info.UserName
  11318. order.DrordDrProfttl = "234"
  11319. order.CurrDrordFlag = "1"
  11320. orders = append(orders, &order)
  11321. }
  11322. }
  11323. for _, subItem := range item.HisPrescriptionProject {
  11324. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11325. var order models.FsiOrderDtos
  11326. order.RxID = strconv.FormatInt(item.ID, 10)
  11327. order.Rxno = strconv.FormatInt(item.ID, 10)
  11328. order.LongDrordFlag = "0"
  11329. order.HilistType = "1"
  11330. order.ChrgType = "1"
  11331. order.DrordBhvr = "-"
  11332. order.HilistCode = subItem.HisProject.MedicalCode
  11333. order.HosplistName = subItem.HisProject.ProjectName
  11334. order.HilistLv = "1"
  11335. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11336. order.HosplistCode = subItem.HisProject.MedicalCode
  11337. order.HosplistName = subItem.HisProject.ProjectName
  11338. order.Cnt = subItem.Count
  11339. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11340. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11341. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11342. order.OwnpayAmt = ""
  11343. order.SelfpayAmt = ""
  11344. order.Spec = ""
  11345. order.SpecUnt = ""
  11346. order.DrordBegnDate = s_tm
  11347. order.DrordStopDate = ""
  11348. order.DrordDrCodg = doctor_info.DoctorNumber
  11349. order.DrordDeptName = department.Name
  11350. order.DrordDeptCodg = department.Number
  11351. order.DrordDrName = doctor_info.UserName
  11352. order.DrordDrProfttl = "234"
  11353. order.CurrDrordFlag = "1"
  11354. orders = append(orders, &order)
  11355. }
  11356. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11357. var order models.FsiOrderDtos
  11358. order.RxID = strconv.FormatInt(item.ID, 10)
  11359. order.Rxno = strconv.FormatInt(item.ID, 10)
  11360. order.LongDrordFlag = "0"
  11361. order.HilistType = "1"
  11362. order.ChrgType = "1"
  11363. order.DrordBhvr = "-"
  11364. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11365. order.HosplistName = subItem.GoodInfo.GoodName
  11366. order.HilistLv = "1"
  11367. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11368. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11369. order.HosplistName = subItem.GoodInfo.GoodName
  11370. order.Cnt = subItem.Count
  11371. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11372. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11373. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11374. order.OwnpayAmt = ""
  11375. order.SelfpayAmt = ""
  11376. order.Spec = ""
  11377. order.SpecUnt = ""
  11378. order.DrordBegnDate = s_tm
  11379. order.DrordStopDate = ""
  11380. order.DrordDrCodg = doctor_info.DoctorNumber
  11381. order.DrordDeptName = department.Name
  11382. order.DrordDeptCodg = department.Number
  11383. order.DrordDrName = doctor_info.UserName
  11384. order.DrordDrProfttl = "234"
  11385. order.CurrDrordFlag = "1"
  11386. orders = append(orders, &order)
  11387. }
  11388. }
  11389. }
  11390. //处方医嘱信息
  11391. }
  11392. fed.MatnStas = "0"
  11393. fed.MedfeeSumamt = "0"
  11394. fed.OwnpayAmt = "0"
  11395. fed.SelfpayAmt = "0"
  11396. fed.AcctPayamt = "0"
  11397. fed.MaAmt = "0"
  11398. fed.HifpPayamt = "0"
  11399. fed.SetlTotlnum = "1"
  11400. fed.Insutype = his.Insutype
  11401. fed.ReimFlag = "0"
  11402. fed.OutSetlFlag = "0"
  11403. var fopd []*models.FsiOperationDtosData
  11404. data := make(map[string]interface{})
  11405. data["fed"] = fed
  11406. data["fdd"] = fdds
  11407. data["fod"] = orders
  11408. data["pd"] = pd
  11409. data["pp"] = pp
  11410. data["fopd"] = fopd
  11411. data["trig_scen"] = trig_scen
  11412. fmt.Println(data)
  11413. fmt.Println(fed)
  11414. fmt.Println(fdds)
  11415. fmt.Println(orders)
  11416. fmt.Println(pd)
  11417. fmt.Println(pp)
  11418. fmt.Println(fopd)
  11419. client := &http.Client{}
  11420. bytesData, _ := json.Marshal(data)
  11421. var req *http.Request
  11422. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11423. if miConfig.MdtrtareaAdmvs == "320830" {
  11424. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11425. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11426. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11427. } else {
  11428. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11429. }
  11430. resp, _ := client.Do(req)
  11431. defer resp.Body.Close()
  11432. body, ioErr := ioutil.ReadAll(resp.Body)
  11433. if ioErr != nil {
  11434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11436. return res
  11437. }
  11438. var respJSON map[string]interface{}
  11439. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11442. return res
  11443. }
  11444. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11445. fmt.Println(respJSON)
  11446. result, _ := json.Marshal(respJSON)
  11447. fmt.Println(result)
  11448. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11449. utils.ErrorLog("解析失败:%v", err)
  11450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11451. return res
  11452. }
  11453. return res
  11454. } else {
  11455. //if miConfig.MdtrtareaAdmvs == "441202" {
  11456. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11457. saveLog(output, input, "3101", "事前")
  11458. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11459. utils.ErrorLog("解析失败:%v", err)
  11460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11461. return
  11462. }
  11463. return res
  11464. //}
  11465. }
  11466. }
  11467. 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) {
  11468. adminUser := c.GetAdminUserInfo()
  11469. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11470. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11471. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11472. //record_time := c.GetString("record_time")
  11473. //trig_scen := c.GetString("trig_scen")
  11474. timeLayout := "2006-01-02"
  11475. loc, _ := time.LoadLocation("Local")
  11476. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11477. if err != nil {
  11478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11479. return res
  11480. }
  11481. recordDateTime := theTime.Unix()
  11482. var patientPrescription models.HisPrescriptionInfo
  11483. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11484. if patientPrescription.ID == 0 {
  11485. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11486. }
  11487. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11488. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11489. //
  11490. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11491. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11492. var pp models.PublicParams
  11493. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11494. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11495. pp.FixmedinsName = miConfig.OrgName
  11496. pp.FixmedinsCode = miConfig.Code
  11497. pp.RequestUrl = miConfig.Url
  11498. pp.Cainfo = miConfig.Cainfo
  11499. pp.SecretKey = miConfig.SecretKey
  11500. pp.AccessKey = miConfig.AccessKey
  11501. pp.OpterName = roles.UserName
  11502. var config []*models.HisXtDiagnoseConfig
  11503. for _, item := range diagnosis_ids {
  11504. id, _ := strconv.ParseInt(item, 10, 64)
  11505. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11506. config = append(config, &diagnosisConfig)
  11507. }
  11508. var pd models.PatientDtos
  11509. pd.PatnID = his.PsnNo
  11510. pd.PatnName = his.Name
  11511. pd.Gend = his.Gend
  11512. pd.Brdy = his.Brdy
  11513. pd.Poolarea = his.InsuplcAdmdvs
  11514. pd.CurrMdtrtID = his.Number
  11515. var fed models.FsiEncounterDtos
  11516. fed.MdtrtID = his.Number
  11517. fed.MedinsID = miConfig.Code
  11518. fed.MedinsName = miConfig.OrgName
  11519. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11520. fed.MedMdtrtType = "1"
  11521. fed.MedinsType = "1"
  11522. fed.MedinsLv = "11"
  11523. tm := time.Unix(his.RecordDate, 0)
  11524. s_tm := tm.Format("2006-01-02 15:04:05")
  11525. fed.AdmDate = s_tm
  11526. fed.DscgDate = s_tm
  11527. fed.DscgMainDiseCodg = config[0].CountryCode
  11528. fed.DscgMainDiseName = config[0].CountryContentName
  11529. //诊断信息
  11530. var fdds []*models.FsiDiagnoseDtos
  11531. for index, item := range config {
  11532. if index == 0 {
  11533. var fdd models.FsiDiagnoseDtos
  11534. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11535. fdd.InoutDiseType = "1"
  11536. fdd.MaindiseFlag = "1"
  11537. fdd.DiseDate = s_tm
  11538. fdd.DiasSrtNo = "1"
  11539. fdd.DiseName = item.CountryContentName
  11540. fdd.DiseCodg = item.CountryCode
  11541. fdds = append(fdds, &fdd)
  11542. } else {
  11543. var fdd models.FsiDiagnoseDtos
  11544. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11545. fdd.InoutDiseType = "1"
  11546. fdd.MaindiseFlag = "1"
  11547. fdd.DiseDate = s_tm
  11548. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11549. fdd.DiseName = item.CountryContentName
  11550. fdd.DiseCodg = item.CountryCode
  11551. fdds = append(fdds, &fdd)
  11552. }
  11553. }
  11554. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11555. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11556. fed.AdmDeptName = department.Name
  11557. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11558. fed.DscgDeptName = department.Name
  11559. fed.MedMdtrtType = "1"
  11560. fed.MedType = "11"
  11561. //if his.Insutype == "390" {
  11562. // fed.MedType = "1402"
  11563. //} else {
  11564. // fed.MedType = "9933"
  11565. //}
  11566. var orders []*models.FsiOrderDtos
  11567. if trig_scen == "2" {
  11568. //处方医嘱信息
  11569. for _, item := range prescriptions {
  11570. for _, subItem := range item.HisDoctorAdviceInfo {
  11571. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11572. var order models.FsiOrderDtos
  11573. order.RxID = strconv.FormatInt(item.ID, 10)
  11574. order.Rxno = strconv.FormatInt(item.ID, 10)
  11575. order.LongDrordFlag = "0"
  11576. order.HilistType = "1"
  11577. order.ChrgType = "1"
  11578. order.DrordBhvr = "-"
  11579. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11580. order.HosplistName = subItem.BaseDrugLib.DrugName
  11581. order.HilistLv = "1"
  11582. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11583. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11584. order.HosplistName = subItem.BaseDrugLib.DrugName
  11585. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11586. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11587. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11588. order.OwnpayAmt = ""
  11589. order.SelfpayAmt = ""
  11590. order.Spec = ""
  11591. order.SpecUnt = ""
  11592. order.DrordBegnDate = s_tm
  11593. order.DrordStopDate = ""
  11594. order.DrordDrCodg = doctor_info.DoctorNumber
  11595. order.DrordDeptName = department.Name
  11596. order.DrordDeptCodg = department.Number
  11597. order.DrordDrName = doctor_info.UserName
  11598. order.DrordDrProfttl = "234"
  11599. order.CurrDrordFlag = "1"
  11600. orders = append(orders, &order)
  11601. }
  11602. }
  11603. for _, subItem := range item.HisPrescriptionProject {
  11604. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11605. var order models.FsiOrderDtos
  11606. order.RxID = strconv.FormatInt(item.ID, 10)
  11607. order.Rxno = strconv.FormatInt(item.ID, 10)
  11608. order.LongDrordFlag = "0"
  11609. order.HilistType = "1"
  11610. order.ChrgType = "1"
  11611. order.DrordBhvr = "-"
  11612. order.HilistCode = subItem.HisProject.MedicalCode
  11613. order.HosplistName = subItem.HisProject.ProjectName
  11614. order.HilistLv = "1"
  11615. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11616. order.HosplistCode = subItem.HisProject.MedicalCode
  11617. order.HosplistName = subItem.HisProject.ProjectName
  11618. order.Cnt = subItem.Count
  11619. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11620. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11621. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11622. order.OwnpayAmt = ""
  11623. order.SelfpayAmt = ""
  11624. order.Spec = ""
  11625. order.SpecUnt = ""
  11626. order.DrordBegnDate = s_tm
  11627. order.DrordStopDate = ""
  11628. order.DrordDrCodg = doctor_info.DoctorNumber
  11629. order.DrordDeptName = department.Name
  11630. order.DrordDeptCodg = department.Number
  11631. order.DrordDrName = doctor_info.UserName
  11632. order.DrordDrProfttl = "234"
  11633. order.CurrDrordFlag = "1"
  11634. orders = append(orders, &order)
  11635. }
  11636. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11637. var order models.FsiOrderDtos
  11638. order.RxID = strconv.FormatInt(item.ID, 10)
  11639. order.Rxno = strconv.FormatInt(item.ID, 10)
  11640. order.LongDrordFlag = "0"
  11641. order.HilistType = "1"
  11642. order.ChrgType = "1"
  11643. order.DrordBhvr = "-"
  11644. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11645. order.HosplistName = subItem.GoodInfo.GoodName
  11646. order.HilistLv = "1"
  11647. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11648. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11649. order.HosplistName = subItem.GoodInfo.GoodName
  11650. order.Cnt = subItem.Count
  11651. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11652. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11653. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11654. order.OwnpayAmt = ""
  11655. order.SelfpayAmt = ""
  11656. order.Spec = ""
  11657. order.SpecUnt = ""
  11658. order.DrordBegnDate = s_tm
  11659. order.DrordStopDate = ""
  11660. order.DrordDrCodg = doctor_info.DoctorNumber
  11661. order.DrordDeptName = department.Name
  11662. order.DrordDeptCodg = department.Number
  11663. order.DrordDrName = doctor_info.UserName
  11664. order.DrordDrProfttl = "234"
  11665. order.CurrDrordFlag = "1"
  11666. orders = append(orders, &order)
  11667. }
  11668. }
  11669. }
  11670. //处方医嘱信息
  11671. }
  11672. fed.MatnStas = "0"
  11673. fed.MedfeeSumamt = "0"
  11674. fed.OwnpayAmt = "0"
  11675. fed.SelfpayAmt = "0"
  11676. fed.AcctPayamt = "0"
  11677. fed.MaAmt = "0"
  11678. fed.HifpPayamt = "0"
  11679. fed.SetlTotlnum = "1"
  11680. fed.Insutype = his.Insutype
  11681. fed.ReimFlag = "0"
  11682. fed.OutSetlFlag = "0"
  11683. var fopd []*models.FsiOperationDtosData
  11684. data := make(map[string]interface{})
  11685. data["fed"] = fed
  11686. data["fdd"] = fdds
  11687. data["fod"] = orders
  11688. data["pd"] = pd
  11689. data["pp"] = pp
  11690. data["fopd"] = fopd
  11691. data["trig_scen"] = trig_scen
  11692. fmt.Println(data)
  11693. fmt.Println(fed)
  11694. fmt.Println(fdds)
  11695. fmt.Println(orders)
  11696. fmt.Println(pd)
  11697. fmt.Println(pp)
  11698. fmt.Println(fopd)
  11699. client := &http.Client{}
  11700. bytesData, _ := json.Marshal(data)
  11701. var req *http.Request
  11702. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11703. if miConfig.MdtrtareaAdmvs == "320830" {
  11704. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11705. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11706. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11707. } else {
  11708. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11709. }
  11710. resp, _ := client.Do(req)
  11711. defer resp.Body.Close()
  11712. body, ioErr := ioutil.ReadAll(resp.Body)
  11713. if ioErr != nil {
  11714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11716. return res
  11717. }
  11718. var respJSON map[string]interface{}
  11719. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11722. return res
  11723. }
  11724. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11725. fmt.Println(respJSON)
  11726. result, _ := json.Marshal(respJSON)
  11727. fmt.Println(result)
  11728. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11729. utils.ErrorLog("解析失败:%v", err)
  11730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11731. return res
  11732. }
  11733. return res
  11734. } else {
  11735. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11736. saveLog(output, input, "3101", "事前")
  11737. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11738. utils.ErrorLog("解析失败:%v", err)
  11739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11740. return
  11741. }
  11742. return res
  11743. }
  11744. return res
  11745. }
  11746. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11747. ////patient_id, _ := c.GetInt64("patient_id")
  11748. //order_id, _ := c.GetInt64("order_id")
  11749. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11750. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11751. //trig_scen := c.GetString("trig_scen")
  11752. adminUser := c.GetAdminUserInfo()
  11753. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11754. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11755. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11756. record_time := c.GetString("record_time")
  11757. order, _ := service.GetHisOrderByID(order_id)
  11758. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11759. timeLayout := "2006-01-02"
  11760. loc, _ := time.LoadLocation("Local")
  11761. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11762. if err != nil {
  11763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11764. return
  11765. }
  11766. recordDateTime := theTime.Unix()
  11767. var patientPrescription models.HisPrescriptionInfo
  11768. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11769. if patientPrescription.ID == 0 {
  11770. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11771. }
  11772. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11773. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11774. //
  11775. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11776. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11777. var pp models.PublicParams
  11778. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11779. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11780. pp.FixmedinsName = miConfig.OrgName
  11781. pp.FixmedinsCode = miConfig.Code
  11782. pp.RequestUrl = miConfig.Url
  11783. pp.Cainfo = miConfig.Cainfo
  11784. pp.SecretKey = miConfig.SecretKey
  11785. pp.AccessKey = miConfig.AccessKey
  11786. pp.OpterName = roles.UserName
  11787. var config []*models.HisXtDiagnoseConfig
  11788. for _, item := range diagnosis_ids {
  11789. id, _ := strconv.ParseInt(item, 10, 64)
  11790. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11791. config = append(config, &diagnosisConfig)
  11792. }
  11793. var pd models.PatientDtos
  11794. pd.PatnID = his.PsnNo
  11795. pd.PatnName = his.Name
  11796. pd.Gend = his.Gend
  11797. pd.Brdy = psn_info.Brdy
  11798. pd.Poolarea = his.InsuplcAdmdvs
  11799. pd.CurrMdtrtID = his.Number
  11800. var fed models.FsiEncounterDtos
  11801. fed.MdtrtID = his.Number
  11802. fed.MedinsID = miConfig.Code
  11803. fed.MedinsName = miConfig.OrgName
  11804. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11805. fed.MedMdtrtType = "1"
  11806. fed.MedinsType = "1"
  11807. fed.MedinsLv = "11"
  11808. tm := time.Unix(his.RecordDate, 0)
  11809. s_tm := tm.Format("2006-01-02 15:04:05")
  11810. fed.AdmDate = s_tm
  11811. fed.DscgDate = s_tm
  11812. fed.DscgMainDiseCodg = config[0].CountryCode
  11813. fed.DscgMainDiseName = config[0].CountryContentName
  11814. //诊断信息
  11815. var fdds []*models.FsiDiagnoseDtos
  11816. for index, item := range config {
  11817. if index == 0 {
  11818. var fdd models.FsiDiagnoseDtos
  11819. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11820. fdd.InoutDiseType = "1"
  11821. fdd.MaindiseFlag = "1"
  11822. fdd.DiseDate = s_tm
  11823. fdd.DiasSrtNo = "1"
  11824. fdd.DiseName = item.CountryContentName
  11825. fdd.DiseCodg = item.CountryCode
  11826. fdds = append(fdds, &fdd)
  11827. } else {
  11828. var fdd models.FsiDiagnoseDtos
  11829. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11830. fdd.InoutDiseType = "1"
  11831. fdd.MaindiseFlag = "1"
  11832. fdd.DiseDate = s_tm
  11833. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11834. fdd.DiseName = item.CountryContentName
  11835. fdd.DiseCodg = item.CountryCode
  11836. fdds = append(fdds, &fdd)
  11837. }
  11838. }
  11839. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11840. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11841. fed.AdmDeptName = department.Name
  11842. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11843. fed.DscgDeptName = department.Name
  11844. fed.MedType = order.MedType
  11845. //处方医嘱信息
  11846. var orders []*models.FsiOrderDtos
  11847. //for _, item := range prescriptions {
  11848. // for _, subItem := range item.HisDoctorAdviceInfo {
  11849. // var order models.FsiOrderDtos
  11850. // order.RxID = strconv.FormatInt(item.ID, 10)
  11851. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11852. // order.LongDrordFlag = "0"
  11853. // order.HilistType = "1"
  11854. // order.ChrgType = "1"
  11855. // order.DrordBhvr = "-"
  11856. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11857. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11858. // order.HilistLv = "1"
  11859. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11860. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11861. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11862. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11863. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11864. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11865. // order.OwnpayAmt = ""
  11866. // order.SelfpayAmt = ""
  11867. // order.Spec = ""
  11868. // order.SpecUnt = ""
  11869. // order.DrordBegnDate = s_tm
  11870. // order.DrordStopDate = ""
  11871. // order.DrordDrCodg = "1"
  11872. // order.DrordDeptName = department.Name
  11873. // order.DrordDrCodg = "1"
  11874. // order.DrordDrName = doctor_info.UserName
  11875. // order.DrordDrProfttl = ""
  11876. // order.CurrDrordFlag = "1"
  11877. // orders = append(orders, &order)
  11878. // }
  11879. // for _, subItem := range item.HisPrescriptionProject {
  11880. // if subItem.Type == 2 {
  11881. // var order models.FsiOrderDtos
  11882. // order.RxID = strconv.FormatInt(item.ID, 10)
  11883. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11884. // order.LongDrordFlag = "0"
  11885. // order.HilistType = "1"
  11886. // order.ChrgType = "1"
  11887. // order.DrordBhvr = "-"
  11888. // order.HilistCode = subItem.HisProject.MedicalCode
  11889. // order.HosplistName = subItem.HisProject.ProjectName
  11890. // order.HilistLv = "1"
  11891. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11892. // order.HosplistCode = subItem.HisProject.MedicalCode
  11893. // order.HosplistName = subItem.HisProject.ProjectName
  11894. // order.Cnt = subItem.Count
  11895. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11896. //
  11897. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11898. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11899. // order.OwnpayAmt = ""
  11900. // order.SelfpayAmt = ""
  11901. // order.Spec = ""
  11902. // order.SpecUnt = ""
  11903. // order.DrordBegnDate = s_tm
  11904. // order.DrordStopDate = ""
  11905. // order.DrordDrCodg = "1"
  11906. // order.DrordDeptName = department.Name
  11907. // order.DrordDrCodg = "1"
  11908. // order.DrordDrName = doctor_info.UserName
  11909. // order.DrordDrProfttl = ""
  11910. // order.CurrDrordFlag = "1"
  11911. // orders = append(orders, &order)
  11912. //
  11913. // }
  11914. // if subItem.Type == 3 {
  11915. //
  11916. // var order models.FsiOrderDtos
  11917. // order.RxID = strconv.FormatInt(item.ID, 10)
  11918. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11919. // order.LongDrordFlag = "0"
  11920. // order.HilistType = "1"
  11921. // order.ChrgType = "1"
  11922. // order.DrordBhvr = "-"
  11923. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11924. // order.HosplistName = subItem.GoodInfo.GoodName
  11925. // order.HilistLv = "1"
  11926. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11927. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11928. // order.HosplistName = subItem.GoodInfo.GoodName
  11929. // order.Cnt = subItem.Count
  11930. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11931. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11932. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11933. // order.OwnpayAmt = ""
  11934. // order.SelfpayAmt = ""
  11935. // order.Spec = ""
  11936. // order.SpecUnt = ""
  11937. // order.DrordBegnDate = s_tm
  11938. // order.DrordStopDate = ""
  11939. // order.DrordDrCodg = "1"
  11940. // order.DrordDeptName = department.Name
  11941. // order.DrordDrCodg = "1"
  11942. // order.DrordDrName = doctor_info.UserName
  11943. // order.DrordDrProfttl = ""
  11944. // order.CurrDrordFlag = "1"
  11945. // orders = append(orders, &order)
  11946. //
  11947. // }
  11948. // }
  11949. //}
  11950. for _, item := range prescriptions {
  11951. for _, subItem := range item.HisDoctorAdviceInfo {
  11952. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11953. var order models.FsiOrderDtos
  11954. order.RxID = strconv.FormatInt(item.ID, 10)
  11955. order.Rxno = strconv.FormatInt(item.ID, 10)
  11956. order.LongDrordFlag = "0"
  11957. order.HilistType = "101"
  11958. order.ChrgType = "1"
  11959. order.DrordBhvr = "-"
  11960. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11961. order.HosplistName = subItem.BaseDrugLib.DrugName
  11962. order.HilistLv = "1"
  11963. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11964. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11965. order.HosplistName = subItem.BaseDrugLib.DrugName
  11966. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11967. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11968. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11969. order.OwnpayAmt = ""
  11970. order.SelfpayAmt = ""
  11971. order.Spec = ""
  11972. order.SpecUnt = ""
  11973. order.DrordBegnDate = s_tm
  11974. order.DrordStopDate = ""
  11975. order.DrordDrCodg = doctor_info.DoctorNumber
  11976. order.DrordDeptName = department.Name
  11977. order.DrordDeptCodg = department.Number
  11978. order.DrordDrName = doctor_info.UserName
  11979. order.DrordDrProfttl = "234"
  11980. order.CurrDrordFlag = "1"
  11981. orders = append(orders, &order)
  11982. }
  11983. }
  11984. for _, subItem := range item.HisPrescriptionProject {
  11985. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11986. var order models.FsiOrderDtos
  11987. order.RxID = strconv.FormatInt(item.ID, 10)
  11988. order.Rxno = strconv.FormatInt(item.ID, 10)
  11989. order.LongDrordFlag = "0"
  11990. order.HilistType = "201"
  11991. order.ChrgType = "1"
  11992. order.DrordBhvr = "-"
  11993. order.HilistCode = subItem.HisProject.MedicalCode
  11994. order.HosplistName = subItem.HisProject.ProjectName
  11995. order.HilistLv = "1"
  11996. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11997. order.HosplistCode = subItem.HisProject.MedicalCode
  11998. order.HosplistName = subItem.HisProject.ProjectName
  11999. order.Cnt = subItem.Count
  12000. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12001. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12002. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12003. order.OwnpayAmt = ""
  12004. order.SelfpayAmt = ""
  12005. order.Spec = ""
  12006. order.SpecUnt = ""
  12007. order.DrordBegnDate = s_tm
  12008. order.DrordStopDate = ""
  12009. order.DrordDrCodg = doctor_info.DoctorNumber
  12010. order.DrordDeptName = department.Name
  12011. order.DrordDeptCodg = department.Number
  12012. order.DrordDrName = doctor_info.UserName
  12013. order.DrordDrProfttl = "234"
  12014. order.CurrDrordFlag = "1"
  12015. orders = append(orders, &order)
  12016. }
  12017. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12018. var order models.FsiOrderDtos
  12019. order.RxID = strconv.FormatInt(item.ID, 10)
  12020. order.Rxno = strconv.FormatInt(item.ID, 10)
  12021. order.LongDrordFlag = "0"
  12022. order.HilistType = "301"
  12023. order.ChrgType = "1"
  12024. order.DrordBhvr = "0"
  12025. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12026. order.HosplistName = subItem.GoodInfo.GoodName
  12027. order.HilistLv = "1"
  12028. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12029. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12030. order.HosplistName = subItem.GoodInfo.GoodName
  12031. order.Cnt = subItem.Count
  12032. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12033. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12034. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12035. order.OwnpayAmt = ""
  12036. order.SelfpayAmt = ""
  12037. order.Spec = ""
  12038. order.SpecUnt = ""
  12039. order.DrordBegnDate = s_tm
  12040. order.DrordStopDate = ""
  12041. order.DrordDrCodg = doctor_info.DoctorNumber
  12042. order.DrordDeptName = department.Name
  12043. order.DrordDeptCodg = department.Number
  12044. order.DrordDrName = doctor_info.UserName
  12045. order.DrordDrProfttl = "234"
  12046. order.CurrDrordFlag = "1"
  12047. orders = append(orders, &order)
  12048. }
  12049. }
  12050. }
  12051. //处方医嘱信息
  12052. fed.MatnStas = "0"
  12053. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12054. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12055. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12056. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12057. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12058. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12059. fed.SetlTotlnum = "1"
  12060. fed.Insutype = his.Insutype
  12061. fed.ReimFlag = "0"
  12062. fed.OutSetlFlag = "0"
  12063. var fopd []*models.FsiOperationDtosData
  12064. data := make(map[string]interface{})
  12065. data["fed"] = fed
  12066. data["fdd"] = fdds
  12067. data["fod"] = orders
  12068. data["pd"] = pd
  12069. data["pp"] = pp
  12070. data["fopd"] = fopd
  12071. data["trig_scen"] = trig_scen
  12072. client := &http.Client{}
  12073. bytesData, _ := json.Marshal(data)
  12074. var req *http.Request
  12075. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12076. if miConfig.MdtrtareaAdmvs == "320830" {
  12077. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  12078. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12079. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12080. } else {
  12081. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12082. }
  12083. resp, _ := client.Do(req)
  12084. defer resp.Body.Close()
  12085. body, ioErr := ioutil.ReadAll(resp.Body)
  12086. if ioErr != nil {
  12087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12089. return res
  12090. }
  12091. var respJSON map[string]interface{}
  12092. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12095. return res
  12096. }
  12097. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12098. result, _ := json.Marshal(respJSON)
  12099. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12100. utils.ErrorLog("解析失败:%v", err)
  12101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12102. return res
  12103. }
  12104. return res
  12105. } else {
  12106. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12107. saveLog(output, input, "3102", "事中")
  12108. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12109. utils.ErrorLog("解析失败:%v", err)
  12110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12111. return
  12112. }
  12113. return res
  12114. }
  12115. return res
  12116. }
  12117. func Checkgd3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription, de models.XtHisDepartment) (res2 Resultgd3101) {
  12118. var res Resultgd3101
  12119. adminUser := c.GetAdminUserInfo()
  12120. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12121. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12122. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12123. //record_time := c.GetString("record_time")
  12124. //trig_scen := c.GetString("trig_scen")
  12125. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12126. //psn_info, _ := service.GetPatientId(patient_id)
  12127. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12128. timeLayout := "2006-01-02"
  12129. loc, _ := time.LoadLocation("Local")
  12130. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12131. if err != nil {
  12132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12133. return res
  12134. }
  12135. recordDateTime := theTime.Unix()
  12136. var patientPrescription models.HisPrescriptionInfo
  12137. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12138. //if patientPrescription.ID == 0 {
  12139. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12140. //}
  12141. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12142. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12143. //
  12144. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12145. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12146. var str string
  12147. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12148. str = timestampToBirthdayString(patient.Birthday)
  12149. } else {
  12150. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12151. }
  12152. var pp models.PublicParams
  12153. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12154. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12155. pp.FixmedinsName = miConfig.OrgName
  12156. pp.FixmedinsCode = miConfig.Code
  12157. pp.RequestUrl = miConfig.Url
  12158. pp.Cainfo = miConfig.Cainfo
  12159. pp.SecretKey = miConfig.SecretKey
  12160. pp.AccessKey = miConfig.AccessKey
  12161. pp.OpterName = roles.UserName
  12162. var config []*models.HisXtDiagnoseConfig
  12163. for _, item := range diagnosis_ids {
  12164. id, _ := strconv.ParseInt(item, 10, 64)
  12165. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12166. config = append(config, &diagnosisConfig)
  12167. }
  12168. var pd models.PatientDtos
  12169. pd.PatnID = his.PsnNo
  12170. pd.PatnName = his.Name
  12171. pd.Gend = his.Gend
  12172. pd.Brdy = str
  12173. pd.Poolarea = miConfig.MdtrtareaAdmvs
  12174. pd.CurrMdtrtID = his.Number
  12175. var fed models.FsiEncounterDtos
  12176. fed.MdtrtID = his.Number
  12177. fed.MedinsID = miConfig.Code
  12178. fed.MedinsName = miConfig.OrgName
  12179. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12180. fed.MedMdtrtType = "1"
  12181. fed.MedinsType = "1"
  12182. fed.MedinsLv = "11"
  12183. tm := time.Unix(his.RecordDate, 0)
  12184. s_tm := tm.Format("2006-01-02 15:04:05")
  12185. fed.AdmDate = s_tm
  12186. fed.DscgDate = s_tm
  12187. fed.DscgMainDiseCodg = config[0].CountryCode
  12188. fed.DscgMainDiseName = config[0].CountryContentName
  12189. //诊断信息
  12190. var fdds []*models.FsiDiagnoseDtos
  12191. for index, item := range config {
  12192. if index == 0 {
  12193. var fdd models.FsiDiagnoseDtos
  12194. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12195. fdd.InoutDiseType = "1"
  12196. fdd.MaindiseFlag = "1"
  12197. fdd.DiseDate = s_tm
  12198. fdd.DiasSrtNo = "1"
  12199. fdd.DiseName = item.CountryContentName
  12200. fdd.DiseCodg = item.CountryCode
  12201. fdds = append(fdds, &fdd)
  12202. } else {
  12203. var fdd models.FsiDiagnoseDtos
  12204. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12205. fdd.InoutDiseType = "1"
  12206. fdd.MaindiseFlag = "1"
  12207. fdd.DiseDate = s_tm
  12208. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12209. fdd.DiseName = item.CountryContentName
  12210. fdd.DiseCodg = item.CountryCode
  12211. fdds = append(fdds, &fdd)
  12212. }
  12213. }
  12214. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12215. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  12216. fed.AdmDeptName = de.Name
  12217. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  12218. fed.DscgDeptName = de.Name
  12219. fed.MedMdtrtType = "1"
  12220. fed.MedType = "11"
  12221. //if his.Insutype == "390" {
  12222. // fed.MedType = "1402"
  12223. //} else {
  12224. // fed.MedType = "9933"
  12225. //}
  12226. var orders []*models.FsiOrderDtos
  12227. if trig_scen == "2" {
  12228. //处方医嘱信息
  12229. for _, item := range prescriptions {
  12230. for _, subItem := range item.HisDoctorAdviceInfo {
  12231. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12232. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12233. var order models.FsiOrderDtos
  12234. order.RxID = strconv.FormatInt(item.ID, 10)
  12235. order.Rxno = strconv.FormatInt(item.ID, 10)
  12236. order.LongDrordFlag = "0"
  12237. order.HilistType = "101"
  12238. order.ChrgType = "1"
  12239. order.DrordBhvr = "0"
  12240. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12241. order.HosplistName = subItem.BaseDrugLib.DrugName
  12242. order.HilistLv = "1"
  12243. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12244. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12245. order.HosplistName = subItem.BaseDrugLib.DrugName
  12246. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12247. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12248. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12249. order.OwnpayAmt = ""
  12250. order.SelfpayAmt = ""
  12251. order.Spec = spec
  12252. order.SpecUnt = subItem.PrescribingNumberUnit
  12253. order.DrordBegnDate = s_tm
  12254. order.DrordStopDate = ""
  12255. order.DrordDrCodg = doctor_info.DoctorNumber
  12256. order.DrordDeptName = department.Name
  12257. order.DrordDeptCodg = department.Number
  12258. order.DrordDrName = doctor_info.UserName
  12259. order.DrordDrProfttl = "234"
  12260. order.CurrDrordFlag = "1"
  12261. orders = append(orders, &order)
  12262. }
  12263. }
  12264. for _, subItem := range item.HisPrescriptionProject {
  12265. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12266. var order models.FsiOrderDtos
  12267. order.RxID = strconv.FormatInt(item.ID, 10)
  12268. order.Rxno = strconv.FormatInt(item.ID, 10)
  12269. order.LongDrordFlag = "0"
  12270. order.HilistType = "201"
  12271. order.ChrgType = "1"
  12272. order.DrordBhvr = "0"
  12273. order.HilistCode = subItem.HisProject.MedicalCode
  12274. order.HosplistName = subItem.HisProject.ProjectName
  12275. order.HilistLv = "1"
  12276. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12277. order.HosplistCode = subItem.HisProject.MedicalCode
  12278. order.HosplistName = subItem.HisProject.ProjectName
  12279. order.Cnt = subItem.Count
  12280. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12281. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12282. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12283. order.OwnpayAmt = ""
  12284. order.SelfpayAmt = ""
  12285. order.Spec = subItem.Unit
  12286. order.SpecUnt = subItem.Unit
  12287. order.DrordBegnDate = s_tm
  12288. order.DrordStopDate = ""
  12289. order.DrordDrCodg = doctor_info.DoctorNumber
  12290. order.DrordDeptName = department.Name
  12291. order.DrordDeptCodg = department.Number
  12292. order.DrordDrName = doctor_info.UserName
  12293. order.DrordDrProfttl = "234"
  12294. order.CurrDrordFlag = "1"
  12295. orders = append(orders, &order)
  12296. }
  12297. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12298. var order models.FsiOrderDtos
  12299. order.RxID = strconv.FormatInt(item.ID, 10)
  12300. order.Rxno = strconv.FormatInt(item.ID, 10)
  12301. order.LongDrordFlag = "0"
  12302. order.HilistType = "301"
  12303. order.ChrgType = "1"
  12304. order.DrordBhvr = "0"
  12305. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12306. order.HosplistName = subItem.GoodInfo.GoodName
  12307. order.HilistLv = "1"
  12308. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12309. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12310. order.HosplistName = subItem.GoodInfo.GoodName
  12311. order.Cnt = subItem.Count
  12312. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12313. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12314. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12315. order.OwnpayAmt = ""
  12316. order.SelfpayAmt = ""
  12317. order.Spec = subItem.GoodInfo.SpecificationName
  12318. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12319. order.DrordBegnDate = s_tm
  12320. order.DrordStopDate = ""
  12321. order.DrordDrCodg = doctor_info.DoctorNumber
  12322. order.DrordDeptName = department.Name
  12323. order.DrordDeptCodg = department.Number
  12324. order.DrordDrName = doctor_info.UserName
  12325. order.DrordDrProfttl = "234"
  12326. order.CurrDrordFlag = "1"
  12327. orders = append(orders, &order)
  12328. }
  12329. }
  12330. }
  12331. //处方医嘱信息
  12332. }
  12333. fed.MatnStas = "0"
  12334. fed.MedfeeSumamt = "0"
  12335. fed.OwnpayAmt = "0"
  12336. fed.SelfpayAmt = "0"
  12337. fed.AcctPayamt = "0"
  12338. fed.MaAmt = "0"
  12339. fed.HifpPayamt = "0"
  12340. fed.SetlTotlnum = "1"
  12341. fed.Insutype = his.Insutype
  12342. fed.ReimFlag = "0"
  12343. fed.OutSetlFlag = "0"
  12344. var fopd []*models.FsiOperationDtosData
  12345. data := make(map[string]interface{})
  12346. data["fed"] = fed
  12347. data["fdd"] = fdds
  12348. data["fod"] = orders
  12349. data["pd"] = pd
  12350. data["pp"] = pp
  12351. data["fopd"] = fopd
  12352. data["trig_scen"] = trig_scen
  12353. fmt.Println(data)
  12354. fmt.Println(fed)
  12355. fmt.Println(fdds)
  12356. fmt.Println(orders)
  12357. fmt.Println(pd)
  12358. fmt.Println(pp)
  12359. fmt.Println(fopd)
  12360. client := &http.Client{}
  12361. bytesData, _ := json.Marshal(data)
  12362. var req *http.Request
  12363. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12364. if miConfig.MdtrtareaAdmvs == "320830" {
  12365. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12366. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12367. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12368. } else {
  12369. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12370. }
  12371. resp, _ := client.Do(req)
  12372. defer resp.Body.Close()
  12373. body, ioErr := ioutil.ReadAll(resp.Body)
  12374. if ioErr != nil {
  12375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12377. return res
  12378. }
  12379. var respJSON map[string]interface{}
  12380. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12383. return res
  12384. }
  12385. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12386. fmt.Println(respJSON)
  12387. result, _ := json.Marshal(respJSON)
  12388. fmt.Println(result)
  12389. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12390. utils.ErrorLog("解析失败:%v", err)
  12391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12392. return res
  12393. }
  12394. return res
  12395. } else {
  12396. //if miConfig.MdtrtareaAdmvs == "441202" {
  12397. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12398. saveLog(output, input, "3101", "事前")
  12399. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12400. utils.ErrorLog("解析失败:%v", err)
  12401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12402. return
  12403. }
  12404. return res
  12405. //}
  12406. }
  12407. }
  12408. 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) {
  12409. adminUser := c.GetAdminUserInfo()
  12410. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12411. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12412. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12413. //record_time := c.GetString("record_time")
  12414. //trig_scen := c.GetString("trig_scen")
  12415. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12416. timeLayout := "2006-01-02"
  12417. loc, _ := time.LoadLocation("Local")
  12418. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12419. if err != nil {
  12420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12421. return res
  12422. }
  12423. recordDateTime := theTime.Unix()
  12424. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12425. var patientPrescription models.HisPrescriptionInfo
  12426. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12427. if patientPrescription.ID == 0 {
  12428. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12429. }
  12430. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12431. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12432. //
  12433. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12434. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12435. var pp models.PublicParams
  12436. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12437. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12438. pp.FixmedinsName = miConfig.OrgName
  12439. pp.FixmedinsCode = miConfig.Code
  12440. pp.RequestUrl = miConfig.Url
  12441. pp.Cainfo = miConfig.Cainfo
  12442. pp.SecretKey = miConfig.SecretKey
  12443. pp.AccessKey = miConfig.AccessKey
  12444. pp.OpterName = roles.UserName
  12445. var config []*models.HisXtDiagnoseConfig
  12446. for _, item := range diagnosis_ids {
  12447. id, _ := strconv.ParseInt(item, 10, 64)
  12448. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12449. config = append(config, &diagnosisConfig)
  12450. }
  12451. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12452. var str string
  12453. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12454. str = timestampToBirthdayString(patient.Birthday)
  12455. } else {
  12456. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12457. }
  12458. var pd models.PatientDtos
  12459. pd.PatnID = his.PsnNo
  12460. pd.PatnName = his.Name
  12461. pd.Gend = his.Gend
  12462. pd.Brdy = str
  12463. pd.Poolarea = his.InsuplcAdmdvs
  12464. pd.CurrMdtrtID = his.Number
  12465. var fed models.FsiEncounterDtos
  12466. fed.MdtrtID = his.Number
  12467. fed.MedinsID = miConfig.Code
  12468. fed.MedinsName = miConfig.OrgName
  12469. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12470. fed.MedMdtrtType = "1"
  12471. fed.MedinsType = "1"
  12472. fed.MedinsLv = "11"
  12473. tm := time.Unix(his.RecordDate, 0)
  12474. s_tm := tm.Format("2006-01-02 15:04:05")
  12475. fed.AdmDate = s_tm
  12476. fed.DscgDate = s_tm
  12477. fed.DscgMainDiseCodg = config[0].CountryCode
  12478. fed.DscgMainDiseName = config[0].CountryContentName
  12479. //诊断信息
  12480. var fdds []*models.FsiDiagnoseDtos
  12481. for index, item := range config {
  12482. if index == 0 {
  12483. var fdd models.FsiDiagnoseDtos
  12484. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12485. fdd.InoutDiseType = "1"
  12486. fdd.MaindiseFlag = "1"
  12487. fdd.DiseDate = s_tm
  12488. fdd.DiasSrtNo = "1"
  12489. fdd.DiseName = item.CountryContentName
  12490. fdd.DiseCodg = item.CountryCode
  12491. fdds = append(fdds, &fdd)
  12492. } else {
  12493. var fdd models.FsiDiagnoseDtos
  12494. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12495. fdd.InoutDiseType = "1"
  12496. fdd.MaindiseFlag = "1"
  12497. fdd.DiseDate = s_tm
  12498. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12499. fdd.DiseName = item.CountryContentName
  12500. fdd.DiseCodg = item.CountryCode
  12501. fdds = append(fdds, &fdd)
  12502. }
  12503. }
  12504. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12505. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12506. fed.AdmDeptName = department.Name
  12507. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12508. fed.DscgDeptName = department.Name
  12509. fed.MedMdtrtType = "1"
  12510. fed.MedType = "11"
  12511. //if his.Insutype == "390" {
  12512. // fed.MedType = "1402"
  12513. //} else {
  12514. // fed.MedType = "9933"
  12515. //}
  12516. var orders []*models.FsiOrderDtos
  12517. if trig_scen == "2" {
  12518. //处方医嘱信息
  12519. for _, item := range prescriptions {
  12520. for _, subItem := range item.HisDoctorAdviceInfo {
  12521. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12522. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "/" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit
  12523. var order models.FsiOrderDtos
  12524. order.RxID = strconv.FormatInt(item.ID, 10)
  12525. order.Rxno = strconv.FormatInt(item.ID, 10)
  12526. order.LongDrordFlag = "0"
  12527. order.HilistType = "101"
  12528. order.ChrgType = "1"
  12529. order.DrordBhvr = "0"
  12530. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12531. order.HosplistName = subItem.BaseDrugLib.DrugName
  12532. order.HilistLv = "1"
  12533. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12534. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12535. order.HosplistName = subItem.BaseDrugLib.DrugName
  12536. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12537. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12538. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12539. order.OwnpayAmt = ""
  12540. order.SelfpayAmt = ""
  12541. order.Spec = spec
  12542. order.SpecUnt = subItem.PrescribingNumberUnit
  12543. order.DrordBegnDate = s_tm
  12544. order.DrordStopDate = ""
  12545. order.DrordDrCodg = doctor_info.DoctorNumber
  12546. order.DrordDeptName = department.Name
  12547. order.DrordDeptCodg = department.Number
  12548. order.DrordDrName = doctor_info.UserName
  12549. order.DrordDrProfttl = "234"
  12550. order.CurrDrordFlag = "1"
  12551. orders = append(orders, &order)
  12552. }
  12553. }
  12554. for _, subItem := range item.HisPrescriptionProject {
  12555. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12556. var order models.FsiOrderDtos
  12557. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12558. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12559. order.LongDrordFlag = "0"
  12560. order.HilistType = "201"
  12561. order.ChrgType = "1"
  12562. order.DrordBhvr = "0"
  12563. order.HilistCode = subItem.HisProject.MedicalCode
  12564. order.HosplistName = subItem.HisProject.ProjectName
  12565. order.HilistLv = "1"
  12566. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12567. order.HosplistCode = subItem.HisProject.MedicalCode
  12568. order.HosplistName = subItem.HisProject.ProjectName
  12569. order.Cnt = subItem.Count
  12570. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12571. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12572. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12573. order.OwnpayAmt = ""
  12574. order.SelfpayAmt = ""
  12575. order.Spec = subItem.Unit
  12576. order.SpecUnt = subItem.Unit
  12577. order.DrordBegnDate = s_tm
  12578. order.DrordStopDate = ""
  12579. order.DrordDrCodg = doctor_info.DoctorNumber
  12580. order.DrordDeptName = department.Name
  12581. order.DrordDeptCodg = department.Number
  12582. order.DrordDrName = doctor_info.UserName
  12583. order.DrordDrProfttl = "234"
  12584. order.CurrDrordFlag = "1"
  12585. orders = append(orders, &order)
  12586. }
  12587. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12588. var order models.FsiOrderDtos
  12589. order.RxID = strconv.FormatInt(item.ID, 10)
  12590. order.Rxno = strconv.FormatInt(item.ID, 10)
  12591. order.LongDrordFlag = "0"
  12592. order.HilistType = "301"
  12593. order.ChrgType = "1"
  12594. order.DrordBhvr = "0"
  12595. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12596. order.HosplistName = subItem.GoodInfo.GoodName
  12597. order.HilistLv = "1"
  12598. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12599. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12600. order.HosplistName = subItem.GoodInfo.GoodName
  12601. order.Cnt = subItem.Count
  12602. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12603. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12604. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12605. order.OwnpayAmt = ""
  12606. order.SelfpayAmt = ""
  12607. order.Spec = subItem.GoodInfo.SpecificationName
  12608. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12609. order.DrordBegnDate = s_tm
  12610. order.DrordStopDate = ""
  12611. order.DrordDrCodg = doctor_info.DoctorNumber
  12612. order.DrordDeptName = department.Name
  12613. order.DrordDeptCodg = department.Number
  12614. order.DrordDrName = doctor_info.UserName
  12615. order.DrordDrProfttl = "234"
  12616. order.CurrDrordFlag = "1"
  12617. orders = append(orders, &order)
  12618. }
  12619. }
  12620. }
  12621. //处方医嘱信息
  12622. }
  12623. fed.MatnStas = "0"
  12624. fed.MedfeeSumamt = "0"
  12625. fed.OwnpayAmt = "0"
  12626. fed.SelfpayAmt = "0"
  12627. fed.AcctPayamt = "0"
  12628. fed.MaAmt = "0"
  12629. fed.HifpPayamt = "0"
  12630. fed.SetlTotlnum = "1"
  12631. fed.Insutype = his.Insutype
  12632. fed.ReimFlag = "0"
  12633. fed.OutSetlFlag = "0"
  12634. var fopd []*models.FsiOperationDtosData
  12635. data := make(map[string]interface{})
  12636. data["fed"] = fed
  12637. data["fdd"] = fdds
  12638. data["fod"] = orders
  12639. data["pd"] = pd
  12640. data["pp"] = pp
  12641. data["fopd"] = fopd
  12642. data["trig_scen"] = trig_scen
  12643. fmt.Println(data)
  12644. fmt.Println(fed)
  12645. fmt.Println(fdds)
  12646. fmt.Println(orders)
  12647. fmt.Println(pd)
  12648. fmt.Println(pp)
  12649. fmt.Println(fopd)
  12650. client := &http.Client{}
  12651. bytesData, _ := json.Marshal(data)
  12652. var req *http.Request
  12653. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12654. if miConfig.MdtrtareaAdmvs == "320830" {
  12655. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12656. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12657. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12658. } else {
  12659. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12660. }
  12661. resp, _ := client.Do(req)
  12662. defer resp.Body.Close()
  12663. body, ioErr := ioutil.ReadAll(resp.Body)
  12664. if ioErr != nil {
  12665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12667. return res
  12668. }
  12669. var respJSON map[string]interface{}
  12670. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12673. return res
  12674. }
  12675. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12676. fmt.Println(respJSON)
  12677. result, _ := json.Marshal(respJSON)
  12678. fmt.Println(result)
  12679. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12680. utils.ErrorLog("解析失败:%v", err)
  12681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12682. return res
  12683. }
  12684. return res
  12685. } else {
  12686. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12687. saveLog(output, input, "3101", "事前")
  12688. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12689. utils.ErrorLog("解析失败:%v", err)
  12690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12691. return
  12692. }
  12693. return res
  12694. }
  12695. return res
  12696. }
  12697. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12698. adminUser := c.GetAdminUserInfo()
  12699. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12700. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12701. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12702. record_time := c.GetString("record_time")
  12703. order, _ := service.GetHisOrderByID(order_id)
  12704. timeLayout := "2006-01-02"
  12705. loc, _ := time.LoadLocation("Local")
  12706. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12707. if err != nil {
  12708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12709. return
  12710. }
  12711. recordDateTime := theTime.Unix()
  12712. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12713. var patientPrescription models.HisPrescriptionInfo
  12714. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12715. if patientPrescription.ID == 0 {
  12716. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12717. }
  12718. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12719. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12720. //
  12721. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12722. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12723. var pp models.PublicParams
  12724. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12725. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12726. pp.FixmedinsName = miConfig.OrgName
  12727. pp.FixmedinsCode = miConfig.Code
  12728. pp.RequestUrl = miConfig.Url
  12729. pp.Cainfo = miConfig.Cainfo
  12730. pp.SecretKey = miConfig.SecretKey
  12731. pp.AccessKey = miConfig.AccessKey
  12732. pp.OpterName = roles.UserName
  12733. var config []*models.HisXtDiagnoseConfig
  12734. for _, item := range diagnosis_ids {
  12735. id, _ := strconv.ParseInt(item, 10, 64)
  12736. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12737. config = append(config, &diagnosisConfig)
  12738. }
  12739. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12740. var str string
  12741. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12742. str = timestampToBirthdayString(patient.Birthday)
  12743. } else {
  12744. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12745. }
  12746. var pd models.PatientDtos
  12747. pd.PatnID = his.PsnNo
  12748. pd.PatnName = his.Name
  12749. pd.Gend = his.Gend
  12750. pd.Brdy = str
  12751. pd.Poolarea = his.InsuplcAdmdvs
  12752. pd.CurrMdtrtID = his.Number
  12753. var fed models.FsiEncounterDtos
  12754. fed.MdtrtID = his.Number
  12755. fed.MedinsID = miConfig.Code
  12756. fed.MedinsName = miConfig.OrgName
  12757. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12758. fed.MedMdtrtType = "1"
  12759. fed.MedinsType = "1"
  12760. fed.MedinsLv = "11"
  12761. tm := time.Unix(his.RecordDate, 0)
  12762. s_tm := tm.Format("2006-01-02 15:04:05")
  12763. fed.AdmDate = s_tm
  12764. fed.DscgDate = s_tm
  12765. fed.DscgMainDiseCodg = config[0].CountryCode
  12766. fed.DscgMainDiseName = config[0].CountryContentName
  12767. //诊断信息
  12768. var fdds []*models.FsiDiagnoseDtos
  12769. for index, item := range config {
  12770. if index == 0 {
  12771. var fdd models.FsiDiagnoseDtos
  12772. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12773. fdd.InoutDiseType = "1"
  12774. fdd.MaindiseFlag = "1"
  12775. fdd.DiseDate = s_tm
  12776. fdd.DiasSrtNo = "1"
  12777. fdd.DiseName = item.CountryContentName
  12778. fdd.DiseCodg = item.CountryCode
  12779. fdds = append(fdds, &fdd)
  12780. } else {
  12781. var fdd models.FsiDiagnoseDtos
  12782. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12783. fdd.InoutDiseType = "1"
  12784. fdd.MaindiseFlag = "1"
  12785. fdd.DiseDate = s_tm
  12786. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12787. fdd.DiseName = item.CountryContentName
  12788. fdd.DiseCodg = item.CountryCode
  12789. fdds = append(fdds, &fdd)
  12790. }
  12791. }
  12792. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12793. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12794. fed.AdmDeptName = department.Name
  12795. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12796. fed.DscgDeptName = department.Name
  12797. fed.MedType = order.MedType
  12798. //处方医嘱信息
  12799. var orders []*models.FsiOrderDtos
  12800. //for _, item := range prescriptions {
  12801. // for _, subItem := range item.HisDoctorAdviceInfo {
  12802. // var order models.FsiOrderDtos
  12803. // order.RxID = strconv.FormatInt(item.ID, 10)
  12804. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12805. // order.LongDrordFlag = "0"
  12806. // order.HilistType = "1"
  12807. // order.ChrgType = "1"
  12808. // order.DrordBhvr = "-"
  12809. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12810. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12811. // order.HilistLv = "1"
  12812. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12813. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12814. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12815. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12816. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12817. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12818. // order.OwnpayAmt = ""
  12819. // order.SelfpayAmt = ""
  12820. // order.Spec = ""
  12821. // order.SpecUnt = ""
  12822. // order.DrordBegnDate = s_tm
  12823. // order.DrordStopDate = ""
  12824. // order.DrordDrCodg = "1"
  12825. // order.DrordDeptName = department.Name
  12826. // order.DrordDrCodg = "1"
  12827. // order.DrordDrName = doctor_info.UserName
  12828. // order.DrordDrProfttl = ""
  12829. // order.CurrDrordFlag = "1"
  12830. // orders = append(orders, &order)
  12831. // }
  12832. // for _, subItem := range item.HisPrescriptionProject {
  12833. // if subItem.Type == 2 {
  12834. // var order models.FsiOrderDtos
  12835. // order.RxID = strconv.FormatInt(item.ID, 10)
  12836. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12837. // order.LongDrordFlag = "0"
  12838. // order.HilistType = "1"
  12839. // order.ChrgType = "1"
  12840. // order.DrordBhvr = "-"
  12841. // order.HilistCode = subItem.HisProject.MedicalCode
  12842. // order.HosplistName = subItem.HisProject.ProjectName
  12843. // order.HilistLv = "1"
  12844. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12845. // order.HosplistCode = subItem.HisProject.MedicalCode
  12846. // order.HosplistName = subItem.HisProject.ProjectName
  12847. // order.Cnt = subItem.Count
  12848. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12849. //
  12850. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12851. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12852. // order.OwnpayAmt = ""
  12853. // order.SelfpayAmt = ""
  12854. // order.Spec = ""
  12855. // order.SpecUnt = ""
  12856. // order.DrordBegnDate = s_tm
  12857. // order.DrordStopDate = ""
  12858. // order.DrordDrCodg = "1"
  12859. // order.DrordDeptName = department.Name
  12860. // order.DrordDrCodg = "1"
  12861. // order.DrordDrName = doctor_info.UserName
  12862. // order.DrordDrProfttl = ""
  12863. // order.CurrDrordFlag = "1"
  12864. // orders = append(orders, &order)
  12865. //
  12866. // }
  12867. // if subItem.Type == 3 {
  12868. //
  12869. // var order models.FsiOrderDtos
  12870. // order.RxID = strconv.FormatInt(item.ID, 10)
  12871. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12872. // order.LongDrordFlag = "0"
  12873. // order.HilistType = "1"
  12874. // order.ChrgType = "1"
  12875. // order.DrordBhvr = "-"
  12876. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12877. // order.HosplistName = subItem.GoodInfo.GoodName
  12878. // order.HilistLv = "1"
  12879. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12880. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12881. // order.HosplistName = subItem.GoodInfo.GoodName
  12882. // order.Cnt = subItem.Count
  12883. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12884. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12885. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12886. // order.OwnpayAmt = ""
  12887. // order.SelfpayAmt = ""
  12888. // order.Spec = ""
  12889. // order.SpecUnt = ""
  12890. // order.DrordBegnDate = s_tm
  12891. // order.DrordStopDate = ""
  12892. // order.DrordDrCodg = "1"
  12893. // order.DrordDeptName = department.Name
  12894. // order.DrordDrCodg = "1"
  12895. // order.DrordDrName = doctor_info.UserName
  12896. // order.DrordDrProfttl = ""
  12897. // order.CurrDrordFlag = "1"
  12898. // orders = append(orders, &order)
  12899. //
  12900. // }
  12901. // }
  12902. //}
  12903. for _, item := range prescriptions {
  12904. for _, subItem := range item.HisDoctorAdviceInfo {
  12905. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12906. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12907. var order models.FsiOrderDtos
  12908. order.RxID = strconv.FormatInt(item.ID, 10)
  12909. order.Rxno = strconv.FormatInt(item.ID, 10)
  12910. order.LongDrordFlag = "0"
  12911. order.HilistType = "101"
  12912. order.ChrgType = "01"
  12913. order.DrordBhvr = "0"
  12914. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12915. order.HosplistName = subItem.BaseDrugLib.DrugName
  12916. order.HilistLv = "1"
  12917. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12918. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12919. order.HosplistName = subItem.BaseDrugLib.DrugName
  12920. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12921. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12922. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12923. order.OwnpayAmt = ""
  12924. order.SelfpayAmt = ""
  12925. order.Spec = spec
  12926. order.SpecUnt = subItem.PrescribingNumberUnit
  12927. order.DrordBegnDate = s_tm
  12928. order.DrordStopDate = ""
  12929. order.DrordDrCodg = doctor_info.DoctorNumber
  12930. order.DrordDeptName = department.Name
  12931. order.DrordDeptCodg = department.Number
  12932. order.DrordDrName = doctor_info.UserName
  12933. order.DrordDrProfttl = "234"
  12934. order.CurrDrordFlag = "1"
  12935. orders = append(orders, &order)
  12936. }
  12937. }
  12938. for _, subItem := range item.HisPrescriptionProject {
  12939. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12940. var order models.FsiOrderDtos
  12941. order.RxID = strconv.FormatInt(item.ID, 10)
  12942. order.Rxno = strconv.FormatInt(item.ID, 10)
  12943. order.LongDrordFlag = "0"
  12944. order.HilistType = "201"
  12945. order.ChrgType = "05"
  12946. order.DrordBhvr = "0"
  12947. order.HilistCode = subItem.HisProject.MedicalCode
  12948. order.HosplistName = subItem.HisProject.ProjectName
  12949. order.HilistLv = "1"
  12950. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12951. order.HosplistCode = subItem.HisProject.MedicalCode
  12952. order.HosplistName = subItem.HisProject.ProjectName
  12953. order.Cnt = subItem.Count
  12954. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12955. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12956. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12957. order.OwnpayAmt = ""
  12958. order.SelfpayAmt = ""
  12959. order.Spec = subItem.Unit
  12960. order.SpecUnt = subItem.Unit
  12961. order.DrordBegnDate = s_tm
  12962. order.DrordStopDate = ""
  12963. order.DrordDrCodg = doctor_info.DoctorNumber
  12964. order.DrordDeptName = department.Name
  12965. order.DrordDeptCodg = department.Number
  12966. order.DrordDrName = doctor_info.UserName
  12967. order.DrordDrProfttl = "234"
  12968. order.CurrDrordFlag = "1"
  12969. orders = append(orders, &order)
  12970. }
  12971. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12972. var order models.FsiOrderDtos
  12973. order.RxID = strconv.FormatInt(item.ID, 10)
  12974. order.Rxno = strconv.FormatInt(item.ID, 10)
  12975. order.LongDrordFlag = "0"
  12976. order.HilistType = "301"
  12977. order.ChrgType = "08"
  12978. order.DrordBhvr = "0"
  12979. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12980. order.HosplistName = subItem.GoodInfo.GoodName
  12981. order.HilistLv = "1"
  12982. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12983. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12984. order.HosplistName = subItem.GoodInfo.GoodName
  12985. order.Cnt = subItem.Count
  12986. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12987. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12988. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12989. order.OwnpayAmt = ""
  12990. order.SelfpayAmt = ""
  12991. order.Spec = subItem.GoodInfo.SpecificationName
  12992. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12993. order.DrordBegnDate = s_tm
  12994. order.DrordStopDate = ""
  12995. order.DrordDrCodg = doctor_info.DoctorNumber
  12996. order.DrordDeptName = department.Name
  12997. order.DrordDeptCodg = department.Number
  12998. order.DrordDrName = doctor_info.UserName
  12999. order.DrordDrProfttl = "234"
  13000. order.CurrDrordFlag = "1"
  13001. orders = append(orders, &order)
  13002. }
  13003. }
  13004. }
  13005. //处方医嘱信息
  13006. fed.MatnStas = "0"
  13007. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  13008. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  13009. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  13010. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  13011. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  13012. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  13013. fed.SetlTotlnum = "1"
  13014. fed.Insutype = his.Insutype
  13015. fed.ReimFlag = "0"
  13016. fed.OutSetlFlag = "0"
  13017. var fopd []*models.FsiOperationDtosData
  13018. data := make(map[string]interface{})
  13019. data["fed"] = fed
  13020. data["fdd"] = fdds
  13021. data["fod"] = orders
  13022. data["pd"] = pd
  13023. data["pp"] = pp
  13024. data["fopd"] = fopd
  13025. data["trig_scen"] = trig_scen
  13026. client := &http.Client{}
  13027. bytesData, _ := json.Marshal(data)
  13028. var req *http.Request
  13029. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  13030. if miConfig.MdtrtareaAdmvs == "320830" {
  13031. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  13032. } else if miConfig.MdtrtareaAdmvs == "320921" {
  13033. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  13034. } else {
  13035. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  13036. }
  13037. resp, _ := client.Do(req)
  13038. defer resp.Body.Close()
  13039. body, ioErr := ioutil.ReadAll(resp.Body)
  13040. if ioErr != nil {
  13041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13043. return res
  13044. }
  13045. var respJSON map[string]interface{}
  13046. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13049. return res
  13050. }
  13051. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13052. result, _ := json.Marshal(respJSON)
  13053. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13054. utils.ErrorLog("解析失败:%v", err)
  13055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13056. return res
  13057. }
  13058. return res
  13059. } else {
  13060. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  13061. saveLog(output, input, "3102", "事中")
  13062. if err := json.Unmarshal([]byte(output), &res); err != nil {
  13063. utils.ErrorLog("解析失败:%v", err)
  13064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13065. return
  13066. }
  13067. return res
  13068. }
  13069. return res
  13070. }
  13071. func (c *HisApiController) Check() {
  13072. psn_no := c.GetString("psn_no")
  13073. in := c.GetString("in")
  13074. mt := c.GetString("mt")
  13075. baseParams := models.BaseParams{
  13076. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  13077. FixmedinsCode: "H15049901371",
  13078. InsuplcAdmdvs: "150499",
  13079. MdtrtareaAdmvs: "150499",
  13080. OrgName: "赤峰费森血液透析中心",
  13081. Doctor: "1111",
  13082. }
  13083. service.Gdyb2001(baseParams, psn_no, in, mt)
  13084. }
  13085. func (c *HisApiController) GetPsnNcdsInfo() {
  13086. admin_user_id, _ := c.GetInt64("admin_user_id")
  13087. patient_id, _ := c.GetInt64("patient_id")
  13088. //id, _ := c.GetInt64("id")
  13089. adminUser := c.GetAdminUserInfo()
  13090. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13091. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13092. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13093. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13094. //psn_record, _ := service.GetP(id)
  13095. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13096. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  13097. //
  13098. //if psn_record.ID == 0 {
  13099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13100. // return
  13101. //}
  13102. var res Result5301
  13103. var res10265 Result5301For10265
  13104. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  13105. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13106. var api string
  13107. if miConfig.MdtrtareaAdmvs == "320830" {
  13108. api = miConfig.AppSecret + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13109. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13110. } else if miConfig.MdtrtareaAdmvs == "320921" {
  13111. 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 +
  13112. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13113. } else {
  13114. 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 +
  13115. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13116. }
  13117. resp, requestErr := http.Get(api)
  13118. if requestErr != nil {
  13119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13120. return
  13121. }
  13122. body, ioErr := ioutil.ReadAll(resp.Body)
  13123. if ioErr != nil {
  13124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13126. return
  13127. }
  13128. var respJSON map[string]interface{}
  13129. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13132. return
  13133. }
  13134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13135. result, _ := json.Marshal(respJSON)
  13136. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13137. utils.ErrorLog("解析失败:%v", err)
  13138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13139. return
  13140. }
  13141. res.ErrMsg = res10265.ErrMsg
  13142. res.Output = res10265.Output
  13143. res.InfRefmsgid = res10265.InfRefmsgid
  13144. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13145. res.Infcode = infocode
  13146. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13147. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13148. var api string
  13149. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13150. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13151. resp, requestErr := http.Get(api)
  13152. if requestErr != nil {
  13153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13154. return
  13155. }
  13156. body, ioErr := ioutil.ReadAll(resp.Body)
  13157. if ioErr != nil {
  13158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13160. return
  13161. }
  13162. var respJSON map[string]interface{}
  13163. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13166. return
  13167. }
  13168. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13169. if status == "0" {
  13170. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13171. c.ServeSuccessJSON(map[string]interface{}{
  13172. "failed_code": -10,
  13173. "msg": err_msg,
  13174. })
  13175. return
  13176. }
  13177. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13178. result, _ := json.Marshal(respJSON)
  13179. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13180. utils.ErrorLog("解析失败:%v", err)
  13181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13182. return
  13183. }
  13184. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13185. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  13186. var api string
  13187. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13188. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13189. resp, requestErr := http.Get(api)
  13190. if requestErr != nil {
  13191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13192. return
  13193. }
  13194. body, ioErr := ioutil.ReadAll(resp.Body)
  13195. if ioErr != nil {
  13196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13198. return
  13199. }
  13200. var respJSON map[string]interface{}
  13201. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13204. return
  13205. }
  13206. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13207. if status == "0" {
  13208. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13209. c.ServeSuccessJSON(map[string]interface{}{
  13210. "failed_code": -10,
  13211. "msg": err_msg,
  13212. })
  13213. return
  13214. }
  13215. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13216. result, _ := json.Marshal(respJSON)
  13217. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13218. utils.ErrorLog("解析失败:%v", err)
  13219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13220. return
  13221. }
  13222. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13223. p, _ := service.GetHisPatientById(patient_id)
  13224. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13225. var dat map[string]interface{}
  13226. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13227. fmt.Println(dat)
  13228. } else {
  13229. fmt.Println(err)
  13230. }
  13231. userJSONBytes, _ := json.Marshal(dat)
  13232. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13233. utils.ErrorLog("解析失败:%v", err)
  13234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13235. return
  13236. }
  13237. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13238. p, _ := service.GetHisPatientById(patient_id)
  13239. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13240. var dat map[string]interface{}
  13241. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13242. fmt.Println(dat)
  13243. } else {
  13244. fmt.Println(err)
  13245. }
  13246. userJSONBytes, _ := json.Marshal(dat)
  13247. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13248. utils.ErrorLog("解析失败:%v", err)
  13249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13250. return
  13251. }
  13252. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13253. p, _ := service.GetHisPatientById(patient_id)
  13254. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13255. var dat map[string]interface{}
  13256. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13257. fmt.Println(dat)
  13258. } else {
  13259. fmt.Println(err)
  13260. }
  13261. userJSONBytes, _ := json.Marshal(dat)
  13262. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13263. utils.ErrorLog("解析失败:%v", err)
  13264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13265. return
  13266. }
  13267. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13268. p, _ := service.GetHisPatientById(patient_id)
  13269. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13270. var dat map[string]interface{}
  13271. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13272. fmt.Println(dat)
  13273. } else {
  13274. fmt.Println(err)
  13275. }
  13276. userJSONBytes, _ := json.Marshal(dat)
  13277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13278. utils.ErrorLog("解析失败:%v", err)
  13279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13280. return
  13281. }
  13282. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13283. p, _ := service.GetHisPatientById(patient_id)
  13284. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13285. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13286. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13287. resp, requestErr := http.Get(api)
  13288. if requestErr != nil {
  13289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13290. return
  13291. }
  13292. body, ioErr := ioutil.ReadAll(resp.Body)
  13293. if ioErr != nil {
  13294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13296. return
  13297. }
  13298. var respJSON map[string]interface{}
  13299. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13302. return
  13303. }
  13304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13305. result, _ := json.Marshal(respJSON)
  13306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13307. utils.ErrorLog("解析失败:%v", err)
  13308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13309. return
  13310. }
  13311. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13312. p, _ := service.GetHisPatientById(patient_id)
  13313. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  13314. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13315. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13316. resp, requestErr := http.Get(api)
  13317. if requestErr != nil {
  13318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13319. return
  13320. }
  13321. body, ioErr := ioutil.ReadAll(resp.Body)
  13322. if ioErr != nil {
  13323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13325. return
  13326. }
  13327. var respJSON map[string]interface{}
  13328. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13331. return
  13332. }
  13333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13334. result, _ := json.Marshal(respJSON)
  13335. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13336. utils.ErrorLog("解析失败:%v", err)
  13337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13338. return
  13339. }
  13340. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13341. p, _ := service.GetHisPatientById(patient_id)
  13342. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13343. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13345. resp, requestErr := http.Get(api)
  13346. if requestErr != nil {
  13347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13348. return
  13349. }
  13350. body, ioErr := ioutil.ReadAll(resp.Body)
  13351. if ioErr != nil {
  13352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13354. return
  13355. }
  13356. var respJSON map[string]interface{}
  13357. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13360. return
  13361. }
  13362. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13363. result, _ := json.Marshal(respJSON)
  13364. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13365. utils.ErrorLog("解析失败:%v", err)
  13366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13367. return
  13368. }
  13369. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13370. p, _ := service.GetHisPatientById(patient_id)
  13371. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13372. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13373. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13374. resp, requestErr := http.Get(api)
  13375. if requestErr != nil {
  13376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13377. return
  13378. }
  13379. body, ioErr := ioutil.ReadAll(resp.Body)
  13380. if ioErr != nil {
  13381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13383. return
  13384. }
  13385. var respJSON map[string]interface{}
  13386. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13389. return
  13390. }
  13391. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13392. result, _ := json.Marshal(respJSON)
  13393. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13394. utils.ErrorLog("解析失败:%v", err)
  13395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13396. return
  13397. }
  13398. } else if miConfig.MdtrtareaAdmvs == "421300" {
  13399. p, _ := service.GetHisPatientById(patient_id)
  13400. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13401. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13402. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13403. resp, requestErr := http.Get(api)
  13404. if requestErr != nil {
  13405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13406. return
  13407. }
  13408. body, ioErr := ioutil.ReadAll(resp.Body)
  13409. if ioErr != nil {
  13410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13412. return
  13413. }
  13414. var respJSON map[string]interface{}
  13415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13418. return
  13419. }
  13420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13421. result, _ := json.Marshal(respJSON)
  13422. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13423. utils.ErrorLog("解析失败:%v", err)
  13424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13425. return
  13426. }
  13427. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13428. p, _ := service.GetHisPatientById(patient_id)
  13429. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  13430. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13431. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13432. resp, requestErr := http.Get(api)
  13433. if requestErr != nil {
  13434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13435. return
  13436. }
  13437. body, ioErr := ioutil.ReadAll(resp.Body)
  13438. if ioErr != nil {
  13439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13441. return
  13442. }
  13443. var respJSON map[string]interface{}
  13444. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13447. return
  13448. }
  13449. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13450. result, _ := json.Marshal(respJSON)
  13451. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13452. utils.ErrorLog("解析失败:%v", err)
  13453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13454. return
  13455. }
  13456. } else {
  13457. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  13458. var dat map[string]interface{}
  13459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13460. fmt.Println(dat)
  13461. } else {
  13462. fmt.Println(err)
  13463. }
  13464. userJSONBytes, _ := json.Marshal(dat)
  13465. if miConfig.Code == "H15049901371" {
  13466. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13467. utils.ErrorLog("解析失败:%v", err)
  13468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13469. return
  13470. }
  13471. res.InfRefmsgid = res10265.InfRefmsgid
  13472. res.Output = res10265.Output
  13473. res.ErrMsg = res10265.ErrMsg
  13474. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13475. res.Infcode = infocode
  13476. } else {
  13477. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13478. utils.ErrorLog("解析失败:%v", err)
  13479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13480. return
  13481. }
  13482. }
  13483. }
  13484. if res.Infcode == 0 {
  13485. c.ServeSuccessJSON(map[string]interface{}{
  13486. "result": res.Output.Result,
  13487. })
  13488. }
  13489. }
  13490. func (c *HisApiController) CheckInsutype() {
  13491. his_patient_id, _ := c.GetInt64("his_patient_id")
  13492. admin_user_id, _ := c.GetInt64("admin_user_id")
  13493. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13494. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13495. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13496. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13497. var dat map[string]interface{}
  13498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13499. fmt.Println(dat)
  13500. } else {
  13501. fmt.Println(err)
  13502. }
  13503. userJSONBytes, _ := json.Marshal(dat)
  13504. var res Result90100
  13505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13506. utils.ErrorLog("解析失败:%v", err)
  13507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13508. return
  13509. }
  13510. if res.Infcode != 0 {
  13511. c.ServeSuccessJSON(map[string]interface{}{
  13512. "failed_code": -10,
  13513. "msg": res.ErrMsg,
  13514. })
  13515. return
  13516. } else {
  13517. fmt.Println(res)
  13518. }
  13519. }
  13520. func (c *HisApiController) CheckCardPWD() {
  13521. card_pwd := c.GetString("card_pwd")
  13522. his_patient_id, _ := c.GetInt64("his_patient_id")
  13523. admin_user_id, _ := c.GetInt64("admin_user_id")
  13524. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13525. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13526. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13527. psn, _ := service.GetPsnByPatientId(his.PatientId)
  13528. bas := strings.Split(psn.CardInfo, "|")
  13529. basNumber := bas[2]
  13530. if psn.InsuplcAdmdvs[:4] == "4403" {
  13531. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  13532. var dat map[string]interface{}
  13533. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13534. fmt.Println(dat)
  13535. } else {
  13536. fmt.Println(err)
  13537. }
  13538. userJSONBytes, _ := json.Marshal(dat)
  13539. var res Result90991
  13540. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13541. utils.ErrorLog("解析失败:%v", err)
  13542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13543. return
  13544. }
  13545. if res.Infcode != 0 {
  13546. c.ServeSuccessJSON(map[string]interface{}{
  13547. "failed_code": -10,
  13548. "msg": res.ErrMsg,
  13549. })
  13550. return
  13551. } else {
  13552. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  13553. var msg string
  13554. switch res.Output.Result.CardStat {
  13555. case "00":
  13556. msg = "未激活"
  13557. break
  13558. case "10":
  13559. msg = "激活"
  13560. break
  13561. case "20":
  13562. msg = "窗口挂失"
  13563. break
  13564. case "21":
  13565. msg = "电话挂失"
  13566. break
  13567. case "22":
  13568. msg = "单位网上申报挂失"
  13569. break
  13570. case "23":
  13571. msg = "保健办挂失"
  13572. break
  13573. case "24":
  13574. msg = "个人网上挂失"
  13575. break
  13576. case "25":
  13577. msg = "网上服务大厅挂失"
  13578. break
  13579. case "30":
  13580. msg = "注销"
  13581. break
  13582. case "40":
  13583. msg = "回收"
  13584. break
  13585. case "99":
  13586. msg = "制卡中(无效卡)"
  13587. break
  13588. }
  13589. c.ServeSuccessJSON(map[string]interface{}{
  13590. "failed_code": -10,
  13591. "msg": msg,
  13592. })
  13593. return
  13594. } else {
  13595. c.ServeSuccessJSON(map[string]interface{}{
  13596. "msg": "校验成功",
  13597. })
  13598. return
  13599. }
  13600. }
  13601. } else {
  13602. c.ServeSuccessJSON(map[string]interface{}{
  13603. "msg": "校验成功",
  13604. })
  13605. return
  13606. }
  13607. }
  13608. func (c *HisApiController) CheckCardPWDTwo() {
  13609. //card_pwd := c.GetString("card_pwd")
  13610. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13611. admin_user_id, _ := c.GetInt64("admin_user_id")
  13612. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13613. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13614. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  13615. var dat map[string]interface{}
  13616. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13617. fmt.Println(dat)
  13618. } else {
  13619. fmt.Println(err)
  13620. }
  13621. userJSONBytes, _ := json.Marshal(dat)
  13622. var res Result90991
  13623. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13624. utils.ErrorLog("解析失败:%v", err)
  13625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13626. return
  13627. }
  13628. if res.Infcode != 0 {
  13629. c.ServeSuccessJSON(map[string]interface{}{
  13630. "failed_code": -10,
  13631. "msg": res.ErrMsg,
  13632. })
  13633. return
  13634. } else {
  13635. if res.Output.Result.SscnoCheckStat == "0" {
  13636. var msg string
  13637. switch res.Output.Result.CardStat {
  13638. case "00":
  13639. msg = "未激活"
  13640. break
  13641. case "10":
  13642. msg = "激活"
  13643. break
  13644. case "20":
  13645. msg = "窗口挂失"
  13646. break
  13647. case "21":
  13648. msg = "电话挂失"
  13649. break
  13650. case "22":
  13651. msg = "单位网上申报挂失"
  13652. break
  13653. case "23":
  13654. msg = "保健办挂失"
  13655. break
  13656. case "24":
  13657. msg = "个人网上挂失"
  13658. break
  13659. case "25":
  13660. msg = "网上服务大厅挂失"
  13661. break
  13662. case "30":
  13663. msg = "注销"
  13664. break
  13665. case "40":
  13666. msg = "回收"
  13667. break
  13668. case "99":
  13669. msg = "制卡中(无效卡)"
  13670. break
  13671. }
  13672. c.ServeSuccessJSON(map[string]interface{}{
  13673. "failed_code": -10,
  13674. "msg": msg,
  13675. })
  13676. return
  13677. } else {
  13678. c.ServeSuccessJSON(map[string]interface{}{
  13679. "msg": "校验成功",
  13680. })
  13681. return
  13682. }
  13683. }
  13684. }
  13685. type ELeCertData struct {
  13686. Data struct {
  13687. Extra string `json:"extra"`
  13688. IDNo string `json:"idNo"`
  13689. IDType string `json:"idType"`
  13690. EcToken string `json:"ecToken"`
  13691. InsuOrg string `json:"insuOrg"`
  13692. UserName string `json:"userName"`
  13693. EcIndexNo string `json:"ecIndexNo"`
  13694. Gender string `json:"gender"`
  13695. Birthday string `json:"birthday"`
  13696. Nationality string `json:"nationality"`
  13697. Email string `json:"email"`
  13698. } `json:"OutData"`
  13699. }
  13700. func (c *HisApiController) ReadCard() {
  13701. id_card_type, _ := c.GetInt64("id_card_type")
  13702. admin_user_id, _ := c.GetInt64("admin_user_id")
  13703. certificates, _ := c.GetInt64("certificates")
  13704. //
  13705. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13706. id_card_no := c.GetString("id_card_no")
  13707. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13708. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13709. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13710. switch id_card_type {
  13711. case 1:
  13712. if miConfig.MdtrtareaAdmvs == "421300" {
  13713. var res ResultTwo
  13714. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13715. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13716. "&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)
  13717. resp, requestErr := http.Get(api)
  13718. if requestErr != nil {
  13719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13720. return
  13721. }
  13722. body, ioErr := ioutil.ReadAll(resp.Body)
  13723. if ioErr != nil {
  13724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13726. return
  13727. }
  13728. var respJSON map[string]interface{}
  13729. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13732. return
  13733. }
  13734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13735. result, _ := json.Marshal(respJSON)
  13736. fmt.Println("log")
  13737. fmt.Println(string(result))
  13738. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13739. utils.ErrorLog("解析失败:%v", err)
  13740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13741. return
  13742. }
  13743. if res.Infcode == 0 {
  13744. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13745. if err == gorm.ErrRecordNotFound {
  13746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13747. return
  13748. } else if err != nil {
  13749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13750. return
  13751. } else {
  13752. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13753. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13754. infoStr := string(Iinfos)
  13755. idetinfoStr := string(Idetinfos)
  13756. var rf []*ResultFive
  13757. json.Unmarshal([]byte(infoStr), &rf)
  13758. var insutypes []*ResultFive
  13759. var insutype string
  13760. var is390 int = 0
  13761. var is310 int = 0
  13762. for _, item := range rf {
  13763. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13764. insutypes = append(insutypes, item)
  13765. }
  13766. }
  13767. if len(insutypes) == 1 {
  13768. insutype = insutypes[0].Insutype
  13769. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13770. } else {
  13771. for _, i := range insutypes {
  13772. if i.Insutype == "390" {
  13773. is390 = 1
  13774. }
  13775. if i.Insutype == "310" {
  13776. is310 = 1
  13777. }
  13778. }
  13779. }
  13780. if is390 == 1 {
  13781. insutype = "390"
  13782. }
  13783. if is310 == 1 {
  13784. insutype = "310"
  13785. }
  13786. if len(insutypes) == 0 {
  13787. insutype = "390"
  13788. }
  13789. var insuplc_admdvs string
  13790. for _, item := range rf {
  13791. if item.Insutype == insutype {
  13792. insuplc_admdvs = item.InsuplcAdmdvs
  13793. }
  13794. }
  13795. if strings.Contains(insuplc_admdvs, "4213") {
  13796. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13797. }
  13798. psn := &models.HisPsn{
  13799. PsnNo: res.Output.Baseinfo.PsnNo,
  13800. PatientId: patient.ID,
  13801. Certno: res.Output.Baseinfo.Certno,
  13802. Gend: res.Output.Baseinfo.Gend,
  13803. Naty: res.Output.Baseinfo.Naty,
  13804. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13805. PsnName: res.Output.Baseinfo.PsnName,
  13806. Idetinfo: idetinfoStr,
  13807. Insuinfo: infoStr,
  13808. InsuplcAdmdvs: insuplc_admdvs,
  13809. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13810. }
  13811. service.CreateHisPsn(psn)
  13812. c.ServeSuccessJSON(map[string]interface{}{
  13813. "patient": patient,
  13814. "number": res.Output.Baseinfo.Certno,
  13815. })
  13816. }
  13817. } else {
  13818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13819. return
  13820. }
  13821. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13822. var res ResultTwo
  13823. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13824. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13825. "&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)
  13826. resp, requestErr := http.Get(api)
  13827. if requestErr != nil {
  13828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13829. return
  13830. }
  13831. body, ioErr := ioutil.ReadAll(resp.Body)
  13832. if ioErr != nil {
  13833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13835. return
  13836. }
  13837. var respJSON map[string]interface{}
  13838. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13841. return
  13842. }
  13843. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13844. result, _ := json.Marshal(respJSON)
  13845. fmt.Println("log")
  13846. fmt.Println(string(result))
  13847. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13848. utils.ErrorLog("解析失败:%v", err)
  13849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13850. return
  13851. }
  13852. if res.Infcode == 0 {
  13853. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13854. if err == gorm.ErrRecordNotFound {
  13855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13856. return
  13857. } else if err != nil {
  13858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13859. return
  13860. } else {
  13861. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13862. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13863. infoStr := string(Iinfos)
  13864. idetinfoStr := string(Idetinfos)
  13865. psn := &models.HisPsn{
  13866. PsnNo: res.Output.Baseinfo.PsnNo,
  13867. PatientId: patient.ID,
  13868. Certno: res.Output.Baseinfo.Certno,
  13869. Gend: res.Output.Baseinfo.Gend,
  13870. Naty: res.Output.Baseinfo.Naty,
  13871. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13872. PsnName: res.Output.Baseinfo.PsnName,
  13873. Idetinfo: idetinfoStr,
  13874. Insuinfo: infoStr,
  13875. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13876. }
  13877. service.CreateHisPsn(psn)
  13878. var rf []*ResultFive
  13879. json.Unmarshal([]byte(infoStr), &rf)
  13880. var insutypes []*ResultFive
  13881. var insutype string
  13882. var is390 int = 0
  13883. var is310 int = 0
  13884. for _, item := range rf {
  13885. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13886. insutypes = append(insutypes, item)
  13887. }
  13888. }
  13889. if len(insutypes) == 1 {
  13890. insutype = insutypes[0].Insutype
  13891. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13892. } else {
  13893. for _, i := range insutypes {
  13894. if i.Insutype == "390" {
  13895. is390 = 1
  13896. }
  13897. if i.Insutype == "310" {
  13898. is310 = 1
  13899. }
  13900. }
  13901. }
  13902. if is390 == 1 {
  13903. insutype = "390"
  13904. }
  13905. if is310 == 1 {
  13906. insutype = "310"
  13907. }
  13908. if len(insutypes) == 0 {
  13909. insutype = "310"
  13910. }
  13911. c.ServeSuccessJSON(map[string]interface{}{
  13912. "patient": patient,
  13913. "number": res.Output.Baseinfo.Certno,
  13914. "insutype": insutype,
  13915. })
  13916. }
  13917. } else {
  13918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13919. return
  13920. }
  13921. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13922. var res ResultTwo
  13923. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13924. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13925. "&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)
  13926. resp, requestErr := http.Get(api)
  13927. if requestErr != nil {
  13928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13929. return
  13930. }
  13931. body, ioErr := ioutil.ReadAll(resp.Body)
  13932. if ioErr != nil {
  13933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13935. return
  13936. }
  13937. var respJSON map[string]interface{}
  13938. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13941. return
  13942. }
  13943. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13944. result, _ := json.Marshal(respJSON)
  13945. fmt.Println("log")
  13946. fmt.Println(string(result))
  13947. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13948. utils.ErrorLog("解析失败:%v", err)
  13949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13950. return
  13951. }
  13952. if res.Infcode == 0 {
  13953. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13954. if err == gorm.ErrRecordNotFound {
  13955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13956. return
  13957. } else if err != nil {
  13958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13959. return
  13960. } else {
  13961. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13962. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13963. infoStr := string(Iinfos)
  13964. idetinfoStr := string(Idetinfos)
  13965. var rf []*ResultFive
  13966. json.Unmarshal([]byte(infoStr), &rf)
  13967. var insutypes []*ResultFive
  13968. var insutype string
  13969. var is390 int = 0
  13970. var is310 int = 0
  13971. for _, item := range rf {
  13972. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13973. insutypes = append(insutypes, item)
  13974. }
  13975. }
  13976. if len(insutypes) == 1 {
  13977. insutype = insutypes[0].Insutype
  13978. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13979. } else {
  13980. for _, i := range insutypes {
  13981. if i.Insutype == "390" {
  13982. is390 = 1
  13983. }
  13984. if i.Insutype == "310" {
  13985. is310 = 1
  13986. }
  13987. }
  13988. }
  13989. if is390 == 1 {
  13990. insutype = "390"
  13991. }
  13992. if is310 == 1 {
  13993. insutype = "310"
  13994. }
  13995. if len(insutypes) == 0 {
  13996. insutype = "390"
  13997. }
  13998. var insuplc_admdvs string
  13999. for _, item := range rf {
  14000. if item.Insutype == insutype {
  14001. insuplc_admdvs = item.InsuplcAdmdvs
  14002. }
  14003. }
  14004. psn := &models.HisPsn{
  14005. PsnNo: res.Output.Baseinfo.PsnNo,
  14006. PatientId: patient.ID,
  14007. Certno: res.Output.Baseinfo.Certno,
  14008. Gend: res.Output.Baseinfo.Gend,
  14009. Naty: res.Output.Baseinfo.Naty,
  14010. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14011. PsnName: res.Output.Baseinfo.PsnName,
  14012. Idetinfo: idetinfoStr,
  14013. Insuinfo: infoStr,
  14014. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14015. InsuplcAdmdvs: insuplc_admdvs,
  14016. }
  14017. service.CreateHisPsn(psn)
  14018. for _, item := range rf {
  14019. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14020. insutypes = append(insutypes, item)
  14021. }
  14022. }
  14023. if len(insutypes) == 1 {
  14024. insutype = insutypes[0].Insutype
  14025. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14026. } else {
  14027. for _, i := range insutypes {
  14028. if i.Insutype == "390" {
  14029. is390 = 1
  14030. }
  14031. if i.Insutype == "310" {
  14032. is310 = 1
  14033. }
  14034. }
  14035. }
  14036. if is390 == 1 {
  14037. insutype = "390"
  14038. }
  14039. if is310 == 1 {
  14040. insutype = "310"
  14041. }
  14042. if len(insutypes) == 0 {
  14043. insutype = "310"
  14044. }
  14045. c.ServeSuccessJSON(map[string]interface{}{
  14046. "patient": patient,
  14047. "number": res.Output.Baseinfo.Certno,
  14048. "insutype": insutype,
  14049. })
  14050. }
  14051. } else {
  14052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14053. return
  14054. }
  14055. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14056. var res ResultTwo
  14057. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  14058. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14059. "&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)
  14060. resp, requestErr := http.Get(api)
  14061. if requestErr != nil {
  14062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14063. return
  14064. }
  14065. body, ioErr := ioutil.ReadAll(resp.Body)
  14066. if ioErr != nil {
  14067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14069. return
  14070. }
  14071. var respJSON map[string]interface{}
  14072. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14075. return
  14076. }
  14077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14078. result, _ := json.Marshal(respJSON)
  14079. fmt.Println("log")
  14080. fmt.Println(string(result))
  14081. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14082. utils.ErrorLog("解析失败:%v", err)
  14083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14084. return
  14085. }
  14086. if res.Infcode == 0 {
  14087. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14088. if err == gorm.ErrRecordNotFound {
  14089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14090. return
  14091. } else if err != nil {
  14092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14093. return
  14094. } else {
  14095. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14096. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14097. infoStr := string(Iinfos)
  14098. idetinfoStr := string(Idetinfos)
  14099. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14100. psn := &models.HisPsn{
  14101. PsnNo: res.Output.Baseinfo.PsnNo,
  14102. PatientId: patient.ID,
  14103. Certno: res.Output.Baseinfo.Certno,
  14104. Brdy: b,
  14105. Age: float64(age),
  14106. Gend: res.Output.Baseinfo.Gend,
  14107. Naty: res.Output.Baseinfo.Naty,
  14108. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14109. PsnName: res.Output.Baseinfo.PsnName,
  14110. Idetinfo: idetinfoStr,
  14111. Insuinfo: infoStr,
  14112. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14113. }
  14114. service.CreateHisPsn(psn)
  14115. var rf []*ResultFive
  14116. json.Unmarshal([]byte(infoStr), &rf)
  14117. var insutypes []*ResultFive
  14118. var insutype string
  14119. var is390 int = 0
  14120. var is310 int = 0
  14121. for _, item := range rf {
  14122. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14123. insutypes = append(insutypes, item)
  14124. }
  14125. }
  14126. if len(insutypes) == 1 {
  14127. insutype = insutypes[0].Insutype
  14128. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14129. } else {
  14130. for _, i := range insutypes {
  14131. if i.Insutype == "390" {
  14132. is390 = 1
  14133. }
  14134. if i.Insutype == "310" {
  14135. is310 = 1
  14136. }
  14137. }
  14138. }
  14139. if is390 == 1 {
  14140. insutype = "390"
  14141. }
  14142. if is310 == 1 {
  14143. insutype = "310"
  14144. }
  14145. if len(insutypes) == 0 {
  14146. insutype = "310"
  14147. }
  14148. c.ServeSuccessJSON(map[string]interface{}{
  14149. "patient": patient,
  14150. "number": res.Output.Baseinfo.Certno,
  14151. "insutype": insutype,
  14152. })
  14153. }
  14154. } else {
  14155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14156. return
  14157. }
  14158. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  14159. var api string
  14160. if miConfig.MdtrtareaAdmvs == "320830" {
  14161. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14162. "&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
  14163. fmt.Println(api)
  14164. } else if miConfig.MdtrtareaAdmvs == "320921" {
  14165. 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 +
  14166. "&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
  14167. fmt.Println(api)
  14168. } else {
  14169. 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 +
  14170. "&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)
  14171. }
  14172. resp, requestErr := http.Get(api)
  14173. if requestErr != nil {
  14174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14175. return
  14176. }
  14177. body, ioErr := ioutil.ReadAll(resp.Body)
  14178. if ioErr != nil {
  14179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14181. return
  14182. }
  14183. var respJSON map[string]interface{}
  14184. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14187. return
  14188. }
  14189. var status string
  14190. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14191. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14192. //console.log()
  14193. fmt.Println("type===")
  14194. fmt.Println(card_type)
  14195. var token string
  14196. var res ResultTwo //1101结果
  14197. var res10265 ResultTwo10265 //1101结果
  14198. var card_info string //卡信息
  14199. var busi_card_info string
  14200. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14201. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14202. if status == "0" { //读卡成功
  14203. if card_type == "1" {
  14204. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14205. result, _ := json.Marshal(respJSON)
  14206. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14207. utils.ErrorLog("解析失败:%v", err)
  14208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14209. return
  14210. }
  14211. res.ErrMsg = res10265.ErrMsg
  14212. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14213. res.Infcode = infocode
  14214. res.Output = res10265.Output
  14215. res.InfRefmsgid = res10265.InfRefmsgid
  14216. } else {
  14217. //var card_info string //卡信息
  14218. //var busi_card_info string
  14219. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14220. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14221. //fmt.Println(card_info)
  14222. //fmt.Println(busi_card_info)
  14223. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14224. result, _ := json.Marshal(respJSON)
  14225. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14226. utils.ErrorLog("解析失败:%v", err)
  14227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14228. return
  14229. }
  14230. res.ErrMsg = res10265.ErrMsg
  14231. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14232. res.Infcode = infocode
  14233. res.Output = res10265.Output
  14234. res.InfRefmsgid = res10265.InfRefmsgid
  14235. }
  14236. if res.Infcode == 0 {
  14237. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14238. if err == gorm.ErrRecordNotFound {
  14239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14240. return
  14241. } else if err != nil {
  14242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14243. return
  14244. } else {
  14245. if card_type == "1" {
  14246. bas := strings.Split(card_info, "|")
  14247. basNumber := bas[2]
  14248. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14249. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14250. infoStr := string(Iinfos)
  14251. idetinfoStr := string(Idetinfos)
  14252. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14253. psn := &models.HisPsn{
  14254. PsnNo: res.Output.Baseinfo.PsnNo,
  14255. PatientId: patient.ID,
  14256. Certno: res.Output.Baseinfo.Certno,
  14257. Brdy: b,
  14258. Age: float64(age),
  14259. Gend: res.Output.Baseinfo.Gend,
  14260. Naty: res.Output.Baseinfo.Naty,
  14261. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14262. PsnName: res.Output.Baseinfo.PsnName,
  14263. Idetinfo: idetinfoStr,
  14264. Insuinfo: infoStr,
  14265. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14266. CardInfo: card_info,
  14267. VerifyNumber: busi_card_info,
  14268. }
  14269. service.CreateHisPsn(psn)
  14270. var rf []*ResultFive
  14271. json.Unmarshal([]byte(infoStr), &rf)
  14272. var insutypes []*ResultFive
  14273. var insutype string
  14274. var is390 int = 0
  14275. var is310 int = 0
  14276. for _, item := range rf {
  14277. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14278. insutypes = append(insutypes, item)
  14279. }
  14280. }
  14281. if len(insutypes) == 1 {
  14282. insutype = insutypes[0].Insutype
  14283. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14284. } else {
  14285. for _, i := range insutypes {
  14286. if i.Insutype == "390" {
  14287. is390 = 1
  14288. }
  14289. if i.Insutype == "310" {
  14290. is310 = 1
  14291. }
  14292. }
  14293. }
  14294. if is390 == 1 {
  14295. insutype = "390"
  14296. }
  14297. if is310 == 1 {
  14298. insutype = "310"
  14299. }
  14300. if len(insutypes) == 0 {
  14301. insutype = "310"
  14302. }
  14303. c.ServeSuccessJSON(map[string]interface{}{
  14304. "patient": patient,
  14305. "number": basNumber,
  14306. "insutype": insutype,
  14307. })
  14308. } else {
  14309. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14310. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14311. infoStr := string(Iinfos)
  14312. idetinfoStr := string(Idetinfos)
  14313. psn := &models.HisPsn{
  14314. PsnNo: res.Output.Baseinfo.PsnNo,
  14315. PatientId: patient.ID,
  14316. Certno: res.Output.Baseinfo.Certno,
  14317. Gend: res.Output.Baseinfo.Gend,
  14318. Naty: res.Output.Baseinfo.Naty,
  14319. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14320. PsnName: res.Output.Baseinfo.PsnName,
  14321. Idetinfo: idetinfoStr,
  14322. Insuinfo: infoStr,
  14323. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14324. CardInfo: card_info,
  14325. VerifyNumber: token,
  14326. }
  14327. service.CreateHisPsn(psn)
  14328. c.ServeSuccessJSON(map[string]interface{}{
  14329. "patient": patient,
  14330. "number": token,
  14331. })
  14332. }
  14333. }
  14334. } else {
  14335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14336. return
  14337. }
  14338. } else { //读卡失败
  14339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14340. return
  14341. }
  14342. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14343. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  14344. cardnum = DeleteExtraSpaceTwo(cardnum)
  14345. cardCode = DeleteExtraSpaceTwo(cardCode)
  14346. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  14347. name = DeleteExtraSpaceTwo(name)
  14348. errmsg = DeleteExtraSpaceTwo(errmsg)
  14349. cardnum = Remove0000(cardnum)
  14350. cardCode = Remove0000(cardCode)
  14351. id_card_no = Remove0000(id_card_no)
  14352. name = Remove0000(name)
  14353. errmsg = Remove0000(errmsg)
  14354. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  14355. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  14356. //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)
  14357. //fmt.Println(result2)
  14358. //fmt.Println(requestLog2)
  14359. //fmt.Println(errMsgLog2)
  14360. 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)
  14361. saveLog(result, requestLog, "1101", "获取人员信息")
  14362. fmt.Println(errMsgLog)
  14363. if len(errMsgLog) > 0 {
  14364. } else {
  14365. var dat map[string]interface{}
  14366. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14367. fmt.Println(dat)
  14368. } else {
  14369. fmt.Println(err)
  14370. }
  14371. userJSONBytes, _ := json.Marshal(dat)
  14372. var res ResultTwo
  14373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14374. utils.ErrorLog("解析失败:%v", err)
  14375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14376. return
  14377. }
  14378. res.ErrMsg = errMsgLog
  14379. if res.Infcode == 0 {
  14380. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14381. if err == gorm.ErrRecordNotFound {
  14382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14383. return
  14384. } else if err != nil {
  14385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14386. return
  14387. } else {
  14388. fmt.Println(res)
  14389. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14390. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14391. infoStr := string(Iinfos)
  14392. idetinfoStr := string(Idetinfos)
  14393. var rf []*ResultFive
  14394. json.Unmarshal([]byte(infoStr), &rf)
  14395. var insutypes []*ResultFive
  14396. var insutype string
  14397. var is390 int = 0
  14398. var is310 int = 0
  14399. for _, item := range rf {
  14400. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14401. insutypes = append(insutypes, item)
  14402. }
  14403. }
  14404. if len(insutypes) == 1 {
  14405. insutype = insutypes[0].Insutype
  14406. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14407. } else {
  14408. for _, i := range insutypes {
  14409. if i.Insutype == "390" {
  14410. is390 = 1
  14411. }
  14412. if i.Insutype == "310" {
  14413. is310 = 1
  14414. }
  14415. }
  14416. }
  14417. if is390 == 1 {
  14418. insutype = "390"
  14419. }
  14420. if is310 == 1 {
  14421. insutype = "310"
  14422. }
  14423. if len(insutypes) == 0 {
  14424. insutype = "390"
  14425. }
  14426. var insuplc_admdvs string
  14427. for _, item := range rf {
  14428. if item.Insutype == insutype {
  14429. insuplc_admdvs = item.InsuplcAdmdvs
  14430. }
  14431. }
  14432. psn := &models.HisPsn{
  14433. PsnNo: res.Output.Baseinfo.PsnNo,
  14434. PatientId: patient.ID,
  14435. Certno: res.Output.Baseinfo.Certno,
  14436. Gend: res.Output.Baseinfo.Gend,
  14437. Naty: res.Output.Baseinfo.Naty,
  14438. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14439. PsnName: res.Output.Baseinfo.PsnName,
  14440. Idetinfo: idetinfoStr,
  14441. Insuinfo: infoStr,
  14442. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14443. CardInfo: basStr,
  14444. VerifyNumber: "",
  14445. InsuplcAdmdvs: insuplc_admdvs,
  14446. }
  14447. service.CreateHisPsn(psn)
  14448. c.ServeSuccessJSON(map[string]interface{}{
  14449. "patient": patient,
  14450. "number": cardnum,
  14451. "insutype": insutype,
  14452. })
  14453. }
  14454. } else {
  14455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14456. return
  14457. }
  14458. }
  14459. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14460. fmt.Println(initFlag)
  14461. fmt.Println("initFlag")
  14462. if initFlag == 0 {
  14463. c.TestGetJiangXiBasBaseInit()
  14464. }
  14465. basStr := c.GetBasBaseInfo()
  14466. if len(basStr) == 0 {
  14467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14468. return
  14469. }
  14470. fmt.Println(basStr)
  14471. bas := strings.Split(basStr, "|")
  14472. basNumber := bas[1]
  14473. fmt.Println(basNumber)
  14474. card := bas[2]
  14475. card_sn := bas[3]
  14476. fmt.Println(card_sn)
  14477. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14478. result, _ := service.Jxyb11012(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, patient.Name, card)
  14479. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14480. var dat map[string]interface{}
  14481. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14482. fmt.Println(dat)
  14483. } else {
  14484. fmt.Println(err)
  14485. }
  14486. userJSONBytes, _ := json.Marshal(dat)
  14487. var res ResultTwo
  14488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14489. utils.ErrorLog("解析失败:%v", err)
  14490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14491. return
  14492. }
  14493. if res.Infcode == 0 {
  14494. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14495. if err == gorm.ErrRecordNotFound {
  14496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14497. return
  14498. } else if err != nil {
  14499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14500. return
  14501. } else {
  14502. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14503. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14504. infoStr := string(Iinfos)
  14505. idetinfoStr := string(Idetinfos)
  14506. var rf []*ResultFive
  14507. json.Unmarshal([]byte(infoStr), &rf)
  14508. var insutypes []*ResultFive
  14509. var insutype string
  14510. var is390 int = 0
  14511. var is310 int = 0
  14512. var insuplc_admdvs string
  14513. for _, item := range rf {
  14514. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14515. insutypes = append(insutypes, item)
  14516. }
  14517. }
  14518. if len(insutypes) == 1 {
  14519. insutype = insutypes[0].Insutype
  14520. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14521. } else {
  14522. for _, i := range insutypes {
  14523. if i.Insutype == "390" {
  14524. is390 = 1
  14525. }
  14526. if i.Insutype == "310" {
  14527. is310 = 1
  14528. }
  14529. }
  14530. }
  14531. if is390 == 1 {
  14532. insutype = "390"
  14533. }
  14534. if is310 == 1 {
  14535. insutype = "310"
  14536. }
  14537. if len(insutypes) == 0 {
  14538. insutype = "310"
  14539. }
  14540. for _, item := range rf {
  14541. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14542. insuplc_admdvs = item.InsuplcAdmdvs
  14543. }
  14544. }
  14545. psn := &models.HisPsn{
  14546. PsnNo: res.Output.Baseinfo.PsnNo,
  14547. PatientId: patient.ID,
  14548. Certno: res.Output.Baseinfo.Certno,
  14549. Gend: res.Output.Baseinfo.Gend,
  14550. Naty: res.Output.Baseinfo.Naty,
  14551. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14552. PsnName: res.Output.Baseinfo.PsnName,
  14553. Idetinfo: idetinfoStr,
  14554. Insuinfo: infoStr,
  14555. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14556. CardInfo: basStr,
  14557. InsuplcAdmdvs: insuplc_admdvs,
  14558. VerifyNumber: "",
  14559. }
  14560. service.CreateHisPsn(psn)
  14561. c.ServeSuccessJSON(map[string]interface{}{
  14562. "patient": patient,
  14563. "number": basNumber,
  14564. "insutype": insutype,
  14565. })
  14566. }
  14567. } else {
  14568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14569. return
  14570. }
  14571. } else if miConfig.MdtrtareaAdmvs == "361025" {
  14572. basStr := c.GetBasBaseInfo22222()
  14573. fmt.Println(basStr)
  14574. if len(basStr) == 0 {
  14575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14576. return
  14577. }
  14578. fmt.Println(basStr)
  14579. bas := strings.Split(basStr, "|")
  14580. basNumber := bas[2] //卡号
  14581. card_sn := bas[3] //
  14582. id_card_No := bas[1] //卡号
  14583. fmt.Println(basNumber)
  14584. fmt.Println(card_sn)
  14585. fmt.Println(id_card_No)
  14586. var patient service.Patients
  14587. if len(id_card_No) == 0 {
  14588. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14589. } else {
  14590. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14591. }
  14592. result, _ := service.Jxyb1101bycard(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, patient.Name, patient.IdCardNo)
  14593. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14594. var dat map[string]interface{}
  14595. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14596. fmt.Println(dat)
  14597. } else {
  14598. fmt.Println(err)
  14599. }
  14600. userJSONBytes, _ := json.Marshal(dat)
  14601. var res ResultTwo
  14602. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14603. utils.ErrorLog("解析失败:%v", err)
  14604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14605. return
  14606. }
  14607. if res.Infcode == 0 {
  14608. var pateint2 service.Patients
  14609. var err error
  14610. if len(id_card_No) == 0 {
  14611. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14612. } else {
  14613. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14614. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14615. }
  14616. if err == gorm.ErrRecordNotFound {
  14617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14618. return
  14619. } else if err != nil {
  14620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14621. return
  14622. } else {
  14623. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14624. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14625. infoStr := string(Iinfos)
  14626. idetinfoStr := string(Idetinfos)
  14627. var rf []*ResultFive
  14628. json.Unmarshal([]byte(infoStr), &rf)
  14629. var insutypes []*ResultFive
  14630. var insutype string
  14631. var is390 int = 0
  14632. var is310 int = 0
  14633. var insuplc_admdvs string
  14634. for _, item := range rf {
  14635. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14636. insutypes = append(insutypes, item)
  14637. }
  14638. }
  14639. if len(insutypes) == 1 {
  14640. insutype = insutypes[0].Insutype
  14641. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14642. } else {
  14643. for _, i := range insutypes {
  14644. if i.Insutype == "390" {
  14645. is390 = 1
  14646. }
  14647. if i.Insutype == "310" {
  14648. is310 = 1
  14649. }
  14650. }
  14651. }
  14652. if is390 == 1 {
  14653. insutype = "390"
  14654. }
  14655. if is310 == 1 {
  14656. insutype = "310"
  14657. }
  14658. if len(insutypes) == 0 {
  14659. insutype = "310"
  14660. }
  14661. for _, item := range rf {
  14662. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14663. insuplc_admdvs = item.InsuplcAdmdvs
  14664. }
  14665. }
  14666. psn := &models.HisPsn{
  14667. PsnNo: res.Output.Baseinfo.PsnNo,
  14668. PatientId: pateint2.ID,
  14669. Certno: res.Output.Baseinfo.Certno,
  14670. Gend: res.Output.Baseinfo.Gend,
  14671. Naty: res.Output.Baseinfo.Naty,
  14672. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14673. PsnName: res.Output.Baseinfo.PsnName,
  14674. Idetinfo: idetinfoStr,
  14675. Insuinfo: infoStr,
  14676. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14677. CardInfo: basStr,
  14678. InsuplcAdmdvs: insuplc_admdvs,
  14679. VerifyNumber: "",
  14680. }
  14681. service.CreateHisPsn(psn)
  14682. c.ServeSuccessJSON(map[string]interface{}{
  14683. "patient": patient,
  14684. "number": basNumber,
  14685. "insutype": insutype,
  14686. })
  14687. }
  14688. } else {
  14689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14690. return
  14691. }
  14692. } else if miConfig.MdtrtareaAdmvs == "360100" {
  14693. fmt.Println(initFlag)
  14694. fmt.Println("initFlag")
  14695. if initFlag == 0 {
  14696. c.TestGetJiangXiBasBaseInittwo()
  14697. }
  14698. basStr := c.GetBasBaseInfo()
  14699. if len(basStr) == 0 {
  14700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14701. return
  14702. }
  14703. fmt.Println(basStr)
  14704. bas := strings.Split(basStr, "|")
  14705. basNumber := bas[1]
  14706. fmt.Println(basNumber)
  14707. card_sn := bas[3]
  14708. fmt.Println(card_sn)
  14709. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14710. 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, patient.Name)
  14711. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14712. var dat map[string]interface{}
  14713. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14714. fmt.Println(dat)
  14715. } else {
  14716. fmt.Println(err)
  14717. }
  14718. userJSONBytes, _ := json.Marshal(dat)
  14719. var res ResultTwo
  14720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14721. utils.ErrorLog("解析失败:%v", err)
  14722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14723. return
  14724. }
  14725. if res.Infcode == 0 {
  14726. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14727. if err == gorm.ErrRecordNotFound {
  14728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14729. return
  14730. } else if err != nil {
  14731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14732. return
  14733. } else {
  14734. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14735. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14736. infoStr := string(Iinfos)
  14737. idetinfoStr := string(Idetinfos)
  14738. var rf []*ResultFive
  14739. json.Unmarshal([]byte(infoStr), &rf)
  14740. var insutypes []*ResultFive
  14741. var insutype string
  14742. var is390 int = 0
  14743. var is310 int = 0
  14744. var insuplc_admdvs string
  14745. for _, item := range rf {
  14746. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14747. insutypes = append(insutypes, item)
  14748. }
  14749. }
  14750. if len(insutypes) == 1 {
  14751. insutype = insutypes[0].Insutype
  14752. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14753. } else {
  14754. for _, i := range insutypes {
  14755. if i.Insutype == "390" {
  14756. is390 = 1
  14757. }
  14758. if i.Insutype == "310" {
  14759. is310 = 1
  14760. }
  14761. }
  14762. }
  14763. if is390 == 1 {
  14764. insutype = "390"
  14765. }
  14766. if is310 == 1 {
  14767. insutype = "310"
  14768. }
  14769. if len(insutypes) == 0 {
  14770. insutype = "310"
  14771. }
  14772. for _, item := range rf {
  14773. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14774. insuplc_admdvs = item.InsuplcAdmdvs
  14775. }
  14776. }
  14777. psn := &models.HisPsn{
  14778. PsnNo: res.Output.Baseinfo.PsnNo,
  14779. PatientId: patient.ID,
  14780. Certno: res.Output.Baseinfo.Certno,
  14781. Gend: res.Output.Baseinfo.Gend,
  14782. Naty: res.Output.Baseinfo.Naty,
  14783. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14784. PsnName: res.Output.Baseinfo.PsnName,
  14785. Idetinfo: idetinfoStr,
  14786. Insuinfo: infoStr,
  14787. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14788. CardInfo: basStr,
  14789. InsuplcAdmdvs: insuplc_admdvs,
  14790. VerifyNumber: "",
  14791. }
  14792. service.CreateHisPsn(psn)
  14793. c.ServeSuccessJSON(map[string]interface{}{
  14794. "patient": patient,
  14795. "number": basNumber,
  14796. "insutype": insutype,
  14797. })
  14798. }
  14799. } else {
  14800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14801. return
  14802. }
  14803. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14804. fmt.Println(initFlag)
  14805. fmt.Println("initFlag")
  14806. if initFlag == 0 {
  14807. c.TestGetHnBasBaseInit()
  14808. }
  14809. basStr := c.GetBasBaseInfo()
  14810. if len(basStr) == 0 {
  14811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14812. return
  14813. }
  14814. fmt.Println(basStr)
  14815. bas := strings.Split(basStr, "|")
  14816. basNumber := bas[1]
  14817. fmt.Println(basNumber)
  14818. card_sn := bas[3]
  14819. card_no := bas[2]
  14820. fmt.Println(card_sn)
  14821. name := bas[4]
  14822. name = ConvertToString(name, "gbk", "utf-8")
  14823. 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)
  14824. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14825. var dat map[string]interface{}
  14826. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14827. fmt.Println(dat)
  14828. } else {
  14829. fmt.Println(err)
  14830. }
  14831. userJSONBytes, _ := json.Marshal(dat)
  14832. var res ResultTwo
  14833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14834. utils.ErrorLog("解析失败:%v", err)
  14835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14836. return
  14837. }
  14838. if res.Infcode == 0 {
  14839. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14840. if err == gorm.ErrRecordNotFound {
  14841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14842. return
  14843. } else if err != nil {
  14844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14845. return
  14846. } else {
  14847. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14848. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14849. infoStr := string(Iinfos)
  14850. idetinfoStr := string(Idetinfos)
  14851. psn := &models.HisPsn{
  14852. PsnNo: res.Output.Baseinfo.PsnNo,
  14853. PatientId: patient.ID,
  14854. Certno: res.Output.Baseinfo.Certno,
  14855. Gend: res.Output.Baseinfo.Gend,
  14856. Naty: res.Output.Baseinfo.Naty,
  14857. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14858. PsnName: res.Output.Baseinfo.PsnName,
  14859. Idetinfo: idetinfoStr,
  14860. Insuinfo: infoStr,
  14861. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14862. CardInfo: basStr,
  14863. VerifyNumber: "",
  14864. }
  14865. service.CreateHisPsn(psn)
  14866. var rf []*ResultFive
  14867. json.Unmarshal([]byte(infoStr), &rf)
  14868. var insutypes []*ResultFive
  14869. var insutype string
  14870. var is390 int = 0
  14871. var is310 int = 0
  14872. for _, item := range rf {
  14873. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14874. insutypes = append(insutypes, item)
  14875. }
  14876. }
  14877. if len(insutypes) == 1 {
  14878. insutype = insutypes[0].Insutype
  14879. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14880. } else {
  14881. for _, i := range insutypes {
  14882. if i.Insutype == "390" {
  14883. is390 = 1
  14884. }
  14885. if i.Insutype == "310" {
  14886. is310 = 1
  14887. }
  14888. }
  14889. }
  14890. if is390 == 1 {
  14891. insutype = "390"
  14892. }
  14893. if is310 == 1 {
  14894. insutype = "310"
  14895. }
  14896. if len(insutypes) == 0 {
  14897. insutype = "310"
  14898. }
  14899. c.ServeSuccessJSON(map[string]interface{}{
  14900. "patient": patient,
  14901. "number": basNumber,
  14902. "insutype": insutype,
  14903. })
  14904. }
  14905. } else {
  14906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14907. return
  14908. }
  14909. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14910. var api string
  14911. 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 +
  14912. "&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
  14913. fmt.Println(api)
  14914. resp, requestErr := http.Get(api)
  14915. if requestErr != nil {
  14916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14917. return
  14918. }
  14919. body, ioErr := ioutil.ReadAll(resp.Body)
  14920. if ioErr != nil {
  14921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14923. return
  14924. }
  14925. var respJSON map[string]interface{}
  14926. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14929. return
  14930. }
  14931. var res ResultTwo //1101结果
  14932. var res10265 ResultTwo10265 //1101结果
  14933. var card_info string //卡信息
  14934. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14935. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14936. result, _ := json.Marshal(respJSON)
  14937. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14938. utils.ErrorLog("解析失败:%v", err)
  14939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14940. return
  14941. }
  14942. res.ErrMsg = res10265.ErrMsg
  14943. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14944. res.Infcode = infocode
  14945. res.Output = res10265.Output
  14946. res.InfRefmsgid = res10265.InfRefmsgid
  14947. if res.Infcode == 0 {
  14948. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14949. if err == gorm.ErrRecordNotFound {
  14950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14951. return
  14952. } else if err != nil {
  14953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14954. return
  14955. } else {
  14956. bas := strings.Split(card_info, "|")
  14957. basNumber := bas[2]
  14958. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14959. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14960. infoStr := string(Iinfos)
  14961. idetinfoStr := string(Idetinfos)
  14962. psn := &models.HisPsn{
  14963. PsnNo: res.Output.Baseinfo.PsnNo,
  14964. PatientId: patient.ID,
  14965. Certno: res.Output.Baseinfo.Certno,
  14966. Gend: res.Output.Baseinfo.Gend,
  14967. Naty: res.Output.Baseinfo.Naty,
  14968. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14969. PsnName: res.Output.Baseinfo.PsnName,
  14970. Idetinfo: idetinfoStr,
  14971. Insuinfo: infoStr,
  14972. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14973. CardInfo: card_info,
  14974. VerifyNumber: token,
  14975. }
  14976. service.CreateHisPsn(psn)
  14977. var rf []*ResultFive
  14978. json.Unmarshal([]byte(infoStr), &rf)
  14979. var insutypes []*ResultFive
  14980. var insutype string
  14981. var is390 int = 0
  14982. var is310 int = 0
  14983. for _, item := range rf {
  14984. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14985. insutypes = append(insutypes, item)
  14986. }
  14987. }
  14988. if len(insutypes) == 1 {
  14989. insutype = insutypes[0].Insutype
  14990. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14991. } else {
  14992. for _, i := range insutypes {
  14993. if i.Insutype == "390" {
  14994. is390 = 1
  14995. }
  14996. if i.Insutype == "310" {
  14997. is310 = 1
  14998. }
  14999. }
  15000. }
  15001. if is390 == 1 {
  15002. insutype = "390"
  15003. }
  15004. if is310 == 1 {
  15005. insutype = "310"
  15006. }
  15007. if len(insutypes) == 0 {
  15008. insutype = "310"
  15009. }
  15010. c.ServeSuccessJSON(map[string]interface{}{
  15011. "patient": patient,
  15012. "number": basNumber,
  15013. "insutype": insutype,
  15014. })
  15015. }
  15016. } else {
  15017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15018. return
  15019. }
  15020. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15021. res := c.GetoleInfo()
  15022. if res.Infcode == 0 {
  15023. var result string
  15024. if res.Output.MdtrtCertType == "01" {
  15025. 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)
  15026. } else if res.Output.MdtrtCertType == "02" {
  15027. 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)
  15028. } else if res.Output.MdtrtCertType == "03" {
  15029. 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)
  15030. }
  15031. var dat map[string]interface{}
  15032. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15033. fmt.Println(dat)
  15034. } else {
  15035. fmt.Println(err)
  15036. }
  15037. userJSONBytes, _ := json.Marshal(dat)
  15038. var res2 ResultTwo
  15039. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15040. utils.ErrorLog("解析失败:%v", err)
  15041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15042. return
  15043. }
  15044. if res2.Infcode == 0 {
  15045. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15046. if err == gorm.ErrRecordNotFound {
  15047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15048. return
  15049. } else if err != nil {
  15050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15051. return
  15052. } else {
  15053. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15054. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15055. infoStr := string(Iinfos)
  15056. idetinfoStr := string(Idetinfos)
  15057. var rf []*ResultFive
  15058. json.Unmarshal([]byte(infoStr), &rf)
  15059. var insutypes []*ResultFive
  15060. var insutype string
  15061. var is390 int = 0
  15062. var is310 int = 0
  15063. //var insuplc_admdvs string
  15064. for _, item := range rf {
  15065. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15066. insutypes = append(insutypes, item)
  15067. }
  15068. }
  15069. if len(insutypes) == 1 {
  15070. insutype = insutypes[0].Insutype
  15071. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15072. } else {
  15073. for _, i := range insutypes {
  15074. if i.Insutype == "390" {
  15075. is390 = 1
  15076. }
  15077. if i.Insutype == "310" {
  15078. is310 = 1
  15079. }
  15080. }
  15081. }
  15082. if is390 == 1 {
  15083. insutype = "390"
  15084. }
  15085. if is310 == 1 {
  15086. insutype = "310"
  15087. }
  15088. if len(insutypes) == 0 {
  15089. insutype = "310"
  15090. }
  15091. psn := &models.HisPsn{
  15092. PsnNo: res2.Output.Baseinfo.PsnNo,
  15093. PatientId: patient.ID,
  15094. Certno: res2.Output.Baseinfo.Certno,
  15095. Gend: res2.Output.Baseinfo.Gend,
  15096. Naty: res2.Output.Baseinfo.Naty,
  15097. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15098. PsnName: res2.Output.Baseinfo.PsnName,
  15099. Idetinfo: idetinfoStr,
  15100. Insuinfo: infoStr,
  15101. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15102. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15103. VerifyNumber: res.Output.EcToken,
  15104. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15105. }
  15106. if res.Output.MdtrtCertType == "01" {
  15107. psn.VerifyNumber = res.Output.EcToken
  15108. //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)
  15109. } else if res.Output.MdtrtCertType == "02" {
  15110. psn.VerifyNumber = res.Output.MdtrtCertNo
  15111. //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)
  15112. } else if res.Output.MdtrtCertType == "03" {
  15113. psn.VerifyNumber = res.Output.MdtrtCertNo
  15114. //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)
  15115. }
  15116. var balc float64
  15117. for _, item := range rf {
  15118. if item.Insutype == insutype {
  15119. balc = item.Balc
  15120. }
  15121. }
  15122. service.CreateHisPsn(psn)
  15123. c.ServeSuccessJSON(map[string]interface{}{
  15124. "patient": patient,
  15125. "number": res.Output.CardNo,
  15126. "insutype": insutype,
  15127. "blac": balc,
  15128. "desc": idetinfoStr,
  15129. })
  15130. }
  15131. } else {
  15132. c.ServeSuccessJSON(map[string]interface{}{
  15133. "failed_code": -10,
  15134. "msg": res2.ErrMsg,
  15135. })
  15136. }
  15137. } else {
  15138. c.ServeSuccessJSON(map[string]interface{}{
  15139. "failed_code": -10,
  15140. "msg": res.ErrMsg,
  15141. })
  15142. }
  15143. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15144. var api string
  15145. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15146. "&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
  15147. fmt.Println(api)
  15148. resp, requestErr := http.Get(api)
  15149. if requestErr != nil {
  15150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15151. return
  15152. }
  15153. body, ioErr := ioutil.ReadAll(resp.Body)
  15154. if ioErr != nil {
  15155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15157. return
  15158. }
  15159. var respJSON map[string]interface{}
  15160. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15163. return
  15164. }
  15165. var status string
  15166. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15167. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15168. //console.log()
  15169. fmt.Println("type===")
  15170. fmt.Println(card_type)
  15171. var token string
  15172. var res ResultTwo //1101结果
  15173. //var res10265 ResultTwoesultTwo10265 //1101结果
  15174. var card_info string //卡信息
  15175. var busi_card_info string
  15176. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15177. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15178. if status == "0" { //读卡成功
  15179. if card_type == "1" {
  15180. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15181. result, _ := json.Marshal(respJSON)
  15182. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15183. utils.ErrorLog("解析失败:%v", err)
  15184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15185. return
  15186. }
  15187. } else {
  15188. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15189. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15190. result, _ := json.Marshal(respJSON)
  15191. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15192. utils.ErrorLog("解析失败:%v", err)
  15193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15194. return
  15195. }
  15196. }
  15197. if res.Infcode == 0 {
  15198. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15199. if err == gorm.ErrRecordNotFound {
  15200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15201. return
  15202. } else if err != nil {
  15203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15204. return
  15205. } else {
  15206. if card_type == "1" {
  15207. bas := strings.Split(card_info, "|")
  15208. basNumber := bas[2]
  15209. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15210. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15211. infoStr := string(Iinfos)
  15212. idetinfoStr := string(Idetinfos)
  15213. psn := &models.HisPsn{
  15214. PsnNo: res.Output.Baseinfo.PsnNo,
  15215. PatientId: patient.ID,
  15216. Certno: res.Output.Baseinfo.Certno,
  15217. Gend: res.Output.Baseinfo.Gend,
  15218. Naty: res.Output.Baseinfo.Naty,
  15219. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15220. PsnName: res.Output.Baseinfo.PsnName,
  15221. Idetinfo: idetinfoStr,
  15222. Insuinfo: infoStr,
  15223. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15224. CardInfo: card_info,
  15225. VerifyNumber: busi_card_info,
  15226. }
  15227. service.CreateHisPsn(psn)
  15228. var rf []*ResultFive
  15229. json.Unmarshal([]byte(infoStr), &rf)
  15230. var insutypes []*ResultFive
  15231. var insutype string
  15232. var is390 int = 0
  15233. var is310 int = 0
  15234. for _, item := range rf {
  15235. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15236. insutypes = append(insutypes, item)
  15237. }
  15238. }
  15239. if len(insutypes) == 1 {
  15240. insutype = insutypes[0].Insutype
  15241. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15242. } else {
  15243. for _, i := range insutypes {
  15244. if i.Insutype == "390" {
  15245. is390 = 1
  15246. }
  15247. if i.Insutype == "310" {
  15248. is310 = 1
  15249. }
  15250. }
  15251. }
  15252. if is390 == 1 {
  15253. insutype = "390"
  15254. }
  15255. if is310 == 1 {
  15256. insutype = "310"
  15257. }
  15258. if len(insutypes) == 0 {
  15259. insutype = "310"
  15260. }
  15261. c.ServeSuccessJSON(map[string]interface{}{
  15262. "patient": patient,
  15263. "number": basNumber,
  15264. "insutype": insutype,
  15265. })
  15266. } else {
  15267. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15268. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15269. infoStr := string(Iinfos)
  15270. idetinfoStr := string(Idetinfos)
  15271. psn := &models.HisPsn{
  15272. PsnNo: res.Output.Baseinfo.PsnNo,
  15273. PatientId: patient.ID,
  15274. Certno: res.Output.Baseinfo.Certno,
  15275. Gend: res.Output.Baseinfo.Gend,
  15276. Naty: res.Output.Baseinfo.Naty,
  15277. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15278. PsnName: res.Output.Baseinfo.PsnName,
  15279. Idetinfo: idetinfoStr,
  15280. Insuinfo: infoStr,
  15281. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15282. CardInfo: card_info,
  15283. VerifyNumber: token,
  15284. }
  15285. service.CreateHisPsn(psn)
  15286. c.ServeSuccessJSON(map[string]interface{}{
  15287. "patient": patient,
  15288. "number": token,
  15289. })
  15290. }
  15291. }
  15292. } else {
  15293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15294. return
  15295. }
  15296. } else { //读卡失败
  15297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15298. return
  15299. }
  15300. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15301. var api string
  15302. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15303. "&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
  15304. fmt.Println(api)
  15305. resp, requestErr := http.Get(api)
  15306. if requestErr != nil {
  15307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15308. return
  15309. }
  15310. body, ioErr := ioutil.ReadAll(resp.Body)
  15311. if ioErr != nil {
  15312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15314. return
  15315. }
  15316. var respJSON map[string]interface{}
  15317. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15320. return
  15321. }
  15322. var status string
  15323. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15324. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15325. //console.log()
  15326. fmt.Println("type===")
  15327. fmt.Println(card_type)
  15328. var token string
  15329. var res ResultTwo //1101结果
  15330. //var res10265 ResultTwoesultTwo10265 //1101结果
  15331. var card_info string //卡信息
  15332. //var busi_card_info string
  15333. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15334. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15335. if status == "0" { //读卡成功
  15336. if card_type == "1" {
  15337. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15338. result, _ := json.Marshal(respJSON)
  15339. fmt.Println(result)
  15340. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15341. utils.ErrorLog("解析失败:%v", err)
  15342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15343. return
  15344. }
  15345. fmt.Println(res)
  15346. } else {
  15347. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15348. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15349. result, _ := json.Marshal(respJSON)
  15350. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15351. utils.ErrorLog("解析失败:%v", err)
  15352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15353. return
  15354. }
  15355. }
  15356. if res.Infcode == 0 {
  15357. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15358. if err == gorm.ErrRecordNotFound {
  15359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15360. return
  15361. } else if err != nil {
  15362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15363. return
  15364. } else {
  15365. if card_type == "1" {
  15366. bas := strings.Split(card_info, "|")
  15367. basNumber := bas[2]
  15368. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15369. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15370. infoStr := string(Iinfos)
  15371. idetinfoStr := string(Idetinfos)
  15372. psn := &models.HisPsn{
  15373. PsnNo: res.Output.Baseinfo.PsnNo,
  15374. PatientId: patient.ID,
  15375. Certno: res.Output.Baseinfo.Certno,
  15376. Gend: res.Output.Baseinfo.Gend,
  15377. Naty: res.Output.Baseinfo.Naty,
  15378. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15379. PsnName: res.Output.Baseinfo.PsnName,
  15380. Idetinfo: idetinfoStr,
  15381. Insuinfo: infoStr,
  15382. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15383. CardInfo: card_info,
  15384. //VerifyNumber: busi_card_info,
  15385. }
  15386. service.CreateHisPsn(psn)
  15387. var rf []*ResultFive
  15388. json.Unmarshal([]byte(infoStr), &rf)
  15389. var insutypes []*ResultFive
  15390. var insutype string
  15391. var is390 int = 0
  15392. var is310 int = 0
  15393. for _, item := range rf {
  15394. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15395. insutypes = append(insutypes, item)
  15396. }
  15397. }
  15398. if len(insutypes) == 1 {
  15399. insutype = insutypes[0].Insutype
  15400. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15401. } else {
  15402. for _, i := range insutypes {
  15403. if i.Insutype == "390" {
  15404. is390 = 1
  15405. }
  15406. if i.Insutype == "310" {
  15407. is310 = 1
  15408. }
  15409. }
  15410. }
  15411. if is390 == 1 {
  15412. insutype = "390"
  15413. }
  15414. if is310 == 1 {
  15415. insutype = "310"
  15416. }
  15417. if len(insutypes) == 0 {
  15418. insutype = "310"
  15419. }
  15420. c.ServeSuccessJSON(map[string]interface{}{
  15421. "patient": patient,
  15422. "number": basNumber,
  15423. "insutype": insutype,
  15424. })
  15425. } else {
  15426. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15427. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15428. infoStr := string(Iinfos)
  15429. idetinfoStr := string(Idetinfos)
  15430. psn := &models.HisPsn{
  15431. PsnNo: res.Output.Baseinfo.PsnNo,
  15432. PatientId: patient.ID,
  15433. Certno: res.Output.Baseinfo.Certno,
  15434. Gend: res.Output.Baseinfo.Gend,
  15435. Naty: res.Output.Baseinfo.Naty,
  15436. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15437. PsnName: res.Output.Baseinfo.PsnName,
  15438. Idetinfo: idetinfoStr,
  15439. Insuinfo: infoStr,
  15440. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15441. CardInfo: card_info,
  15442. VerifyNumber: token,
  15443. }
  15444. service.CreateHisPsn(psn)
  15445. c.ServeSuccessJSON(map[string]interface{}{
  15446. "patient": patient,
  15447. "number": token,
  15448. })
  15449. }
  15450. }
  15451. } else {
  15452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15453. return
  15454. }
  15455. } else { //读卡失败
  15456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15457. return
  15458. }
  15459. } else {
  15460. if initFlag == 0 {
  15461. c.TestGetBasBaseInit()
  15462. }
  15463. basStr := c.GetBasBaseInfo()
  15464. if len(basStr) == 0 {
  15465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15466. return
  15467. }
  15468. fmt.Println(basStr)
  15469. bas := strings.Split(basStr, "|")
  15470. basNumber := bas[1]
  15471. fmt.Println(basNumber)
  15472. card_sn := bas[3]
  15473. fmt.Println(card_sn)
  15474. cardNumber := bas[2]
  15475. fmt.Println(cardNumber)
  15476. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  15477. var result string
  15478. if bas[0][:2] == "44" {
  15479. 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)
  15480. } else {
  15481. 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)
  15482. }
  15483. var dat map[string]interface{}
  15484. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15485. fmt.Println(dat)
  15486. } else {
  15487. fmt.Println(err)
  15488. }
  15489. userJSONBytes, _ := json.Marshal(dat)
  15490. var res ResultTwo
  15491. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15492. utils.ErrorLog("解析失败:%v", err)
  15493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15494. return
  15495. }
  15496. if res.Infcode == 0 {
  15497. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15498. if err == gorm.ErrRecordNotFound {
  15499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15500. return
  15501. } else if err != nil {
  15502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15503. return
  15504. } else {
  15505. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15506. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15507. infoStr := string(Iinfos)
  15508. idetinfoStr := string(Idetinfos)
  15509. var rf []*ResultFive
  15510. json.Unmarshal([]byte(infoStr), &rf)
  15511. var insutypes []*ResultFive
  15512. var insutype string
  15513. var is390 int = 0
  15514. var is310 int = 0
  15515. var insuplc_admdvs string
  15516. for _, item := range rf {
  15517. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15518. insutypes = append(insutypes, item)
  15519. }
  15520. }
  15521. if len(insutypes) == 1 {
  15522. insutype = insutypes[0].Insutype
  15523. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15524. } else {
  15525. for _, i := range insutypes {
  15526. if i.Insutype == "390" {
  15527. is390 = 1
  15528. }
  15529. if i.Insutype == "310" {
  15530. is310 = 1
  15531. }
  15532. }
  15533. }
  15534. if is390 == 1 {
  15535. insutype = "390"
  15536. }
  15537. if is310 == 1 {
  15538. insutype = "310"
  15539. }
  15540. if len(insutypes) == 0 {
  15541. insutype = "310"
  15542. }
  15543. for _, item := range rf {
  15544. if item.Insutype == insutype {
  15545. insuplc_admdvs = item.InsuplcAdmdvs
  15546. }
  15547. }
  15548. psn := &models.HisPsn{
  15549. PsnNo: res.Output.Baseinfo.PsnNo,
  15550. PatientId: patient.ID,
  15551. Certno: res.Output.Baseinfo.Certno,
  15552. Gend: res.Output.Baseinfo.Gend,
  15553. Naty: res.Output.Baseinfo.Naty,
  15554. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15555. PsnName: res.Output.Baseinfo.PsnName,
  15556. Idetinfo: idetinfoStr,
  15557. Insuinfo: infoStr,
  15558. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15559. CardInfo: basStr,
  15560. VerifyNumber: "",
  15561. InsuplcAdmdvs: insuplc_admdvs,
  15562. }
  15563. service.CreateHisPsn(psn)
  15564. c.ServeSuccessJSON(map[string]interface{}{
  15565. "patient": patient,
  15566. "insutype": insutype,
  15567. "number": basNumber,
  15568. })
  15569. }
  15570. } else {
  15571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15572. return
  15573. }
  15574. break
  15575. }
  15576. case 2:
  15577. if miConfig.MdtrtareaAdmvs == "430800" {
  15578. if initFlag == 0 {
  15579. c.TestGetHnBasBaseInit()
  15580. }
  15581. SFZStr := c.GetSFZBaseInfo()
  15582. if len(SFZStr) == 0 {
  15583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15584. return
  15585. }
  15586. fmt.Println(SFZStr)
  15587. id_card_str := strings.Split(SFZStr, "^")
  15588. card_no := id_card_str[0]
  15589. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15590. //name := id_card_str[1]
  15591. //name = ConvertToString(name, "gbk", "utf-8")
  15592. 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, "", "", card_no)
  15593. var dat map[string]interface{}
  15594. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15595. fmt.Println(dat)
  15596. } else {
  15597. fmt.Println(err)
  15598. }
  15599. userJSONBytes, _ := json.Marshal(dat)
  15600. var res ResultTwo
  15601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15602. utils.ErrorLog("解析失败:%v", err)
  15603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15604. return
  15605. }
  15606. if res.Infcode == 0 {
  15607. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15608. if err == gorm.ErrRecordNotFound {
  15609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15610. return
  15611. } else if err != nil {
  15612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15613. return
  15614. } else {
  15615. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15616. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15617. infoStr := string(Iinfos)
  15618. idetinfoStr := string(Idetinfos)
  15619. var rf []*ResultFive
  15620. json.Unmarshal([]byte(infoStr), &rf)
  15621. var insutypes []*ResultFive
  15622. var insutype string
  15623. var is390 int = 0
  15624. var is310 int = 0
  15625. for _, item := range rf {
  15626. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15627. insutypes = append(insutypes, item)
  15628. }
  15629. }
  15630. if len(insutypes) == 1 {
  15631. insutype = insutypes[0].Insutype
  15632. } else {
  15633. for _, i := range insutypes {
  15634. if i.Insutype == "390" {
  15635. is390 = 1
  15636. }
  15637. if i.Insutype == "310" {
  15638. is310 = 1
  15639. }
  15640. }
  15641. }
  15642. if is390 == 1 {
  15643. insutype = "390"
  15644. }
  15645. if is310 == 1 {
  15646. insutype = "310"
  15647. }
  15648. if len(insutypes) == 0 {
  15649. insutype = "310"
  15650. }
  15651. var InsuplcAdmdvs string
  15652. for _, item := range rf {
  15653. if item.Insutype == insutype {
  15654. InsuplcAdmdvs = item.InsuplcAdmdvs
  15655. }
  15656. }
  15657. psn := &models.HisPsn{
  15658. PsnNo: res.Output.Baseinfo.PsnNo,
  15659. PatientId: patient.ID,
  15660. Certno: res.Output.Baseinfo.Certno,
  15661. Gend: res.Output.Baseinfo.Gend,
  15662. Naty: res.Output.Baseinfo.Naty,
  15663. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15664. PsnName: res.Output.Baseinfo.PsnName,
  15665. Idetinfo: idetinfoStr,
  15666. Insuinfo: infoStr,
  15667. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15668. CardInfo: SFZStr,
  15669. VerifyNumber: "",
  15670. InsuplcAdmdvs: InsuplcAdmdvs,
  15671. }
  15672. service.CreateHisPsn(psn)
  15673. c.ServeSuccessJSON(map[string]interface{}{
  15674. "patient": patient,
  15675. "number": card_no,
  15676. "insutype": insutype,
  15677. })
  15678. }
  15679. } else {
  15680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15681. return
  15682. }
  15683. } else if miConfig.MdtrtareaAdmvs == "420200" {
  15684. var res ResultTwo
  15685. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  15686. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15687. "&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)
  15688. resp, requestErr := http.Get(api)
  15689. if requestErr != nil {
  15690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15691. return
  15692. }
  15693. body, ioErr := ioutil.ReadAll(resp.Body)
  15694. if ioErr != nil {
  15695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15697. return
  15698. }
  15699. var respJSON map[string]interface{}
  15700. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15703. return
  15704. }
  15705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15706. result, _ := json.Marshal(respJSON)
  15707. fmt.Println("log")
  15708. fmt.Println(string(result))
  15709. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15710. utils.ErrorLog("解析失败:%v", err)
  15711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15712. return
  15713. }
  15714. if res.Infcode == 0 {
  15715. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15716. if err == gorm.ErrRecordNotFound {
  15717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15718. return
  15719. } else if err != nil {
  15720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15721. return
  15722. } else {
  15723. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15724. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15725. infoStr := string(Iinfos)
  15726. idetinfoStr := string(Idetinfos)
  15727. psn := &models.HisPsn{
  15728. PsnNo: res.Output.Baseinfo.PsnNo,
  15729. PatientId: patient.ID,
  15730. Certno: res.Output.Baseinfo.Certno,
  15731. Gend: res.Output.Baseinfo.Gend,
  15732. Naty: res.Output.Baseinfo.Naty,
  15733. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15734. PsnName: res.Output.Baseinfo.PsnName,
  15735. Idetinfo: idetinfoStr,
  15736. Insuinfo: infoStr,
  15737. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15738. }
  15739. service.CreateHisPsn(psn)
  15740. c.ServeSuccessJSON(map[string]interface{}{
  15741. "patient": patient,
  15742. "number": res.Output.Baseinfo.Certno,
  15743. })
  15744. }
  15745. } else {
  15746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15747. return
  15748. }
  15749. } else if miConfig.MdtrtareaAdmvs == "421182" {
  15750. var res ResultTwo
  15751. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15752. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15753. "&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)
  15754. resp, requestErr := http.Get(api)
  15755. if requestErr != nil {
  15756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15757. return
  15758. }
  15759. body, ioErr := ioutil.ReadAll(resp.Body)
  15760. if ioErr != nil {
  15761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15763. return
  15764. }
  15765. var respJSON map[string]interface{}
  15766. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15769. return
  15770. }
  15771. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15772. result, _ := json.Marshal(respJSON)
  15773. fmt.Println("log")
  15774. fmt.Println(string(result))
  15775. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15776. utils.ErrorLog("解析失败:%v", err)
  15777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15778. return
  15779. }
  15780. if res.Infcode == 0 {
  15781. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15782. if err == gorm.ErrRecordNotFound {
  15783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15784. return
  15785. } else if err != nil {
  15786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15787. return
  15788. } else {
  15789. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15790. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15791. infoStr := string(Iinfos)
  15792. idetinfoStr := string(Idetinfos)
  15793. psn := &models.HisPsn{
  15794. PsnNo: res.Output.Baseinfo.PsnNo,
  15795. PatientId: patient.ID,
  15796. Certno: res.Output.Baseinfo.Certno,
  15797. Gend: res.Output.Baseinfo.Gend,
  15798. Naty: res.Output.Baseinfo.Naty,
  15799. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15800. PsnName: res.Output.Baseinfo.PsnName,
  15801. Idetinfo: idetinfoStr,
  15802. Insuinfo: infoStr,
  15803. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15804. }
  15805. service.CreateHisPsn(psn)
  15806. c.ServeSuccessJSON(map[string]interface{}{
  15807. "patient": patient,
  15808. "number": res.Output.Baseinfo.Certno,
  15809. })
  15810. }
  15811. } else {
  15812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15813. return
  15814. }
  15815. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15816. var res ResultTwo
  15817. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15818. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15819. "&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)
  15820. resp, requestErr := http.Get(api)
  15821. if requestErr != nil {
  15822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15823. return
  15824. }
  15825. body, ioErr := ioutil.ReadAll(resp.Body)
  15826. if ioErr != nil {
  15827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15829. return
  15830. }
  15831. var respJSON map[string]interface{}
  15832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15835. return
  15836. }
  15837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15838. result, _ := json.Marshal(respJSON)
  15839. fmt.Println("log")
  15840. fmt.Println(string(result))
  15841. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15842. utils.ErrorLog("解析失败:%v", err)
  15843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15844. return
  15845. }
  15846. if res.Infcode == 0 {
  15847. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15848. if err == gorm.ErrRecordNotFound {
  15849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15850. return
  15851. } else if err != nil {
  15852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15853. return
  15854. } else {
  15855. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15856. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15857. infoStr := string(Iinfos)
  15858. idetinfoStr := string(Idetinfos)
  15859. var rf []*ResultFive
  15860. json.Unmarshal([]byte(infoStr), &rf)
  15861. var insutypes []*ResultFive
  15862. var insutype string
  15863. var is390 int = 0
  15864. var is310 int = 0
  15865. for _, item := range rf {
  15866. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15867. insutypes = append(insutypes, item)
  15868. }
  15869. }
  15870. if len(insutypes) == 1 {
  15871. insutype = insutypes[0].Insutype
  15872. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15873. } else {
  15874. for _, i := range insutypes {
  15875. if i.Insutype == "390" {
  15876. is390 = 1
  15877. }
  15878. if i.Insutype == "310" {
  15879. is310 = 1
  15880. }
  15881. }
  15882. }
  15883. if is390 == 1 {
  15884. insutype = "390"
  15885. }
  15886. if is310 == 1 {
  15887. insutype = "310"
  15888. }
  15889. if len(insutypes) == 0 {
  15890. insutype = "390"
  15891. }
  15892. var insuplc_admdvs string
  15893. for _, item := range rf {
  15894. if item.Insutype == insutype {
  15895. insuplc_admdvs = item.InsuplcAdmdvs
  15896. }
  15897. }
  15898. psn := &models.HisPsn{
  15899. PsnNo: res.Output.Baseinfo.PsnNo,
  15900. PatientId: patient.ID,
  15901. Certno: res.Output.Baseinfo.Certno,
  15902. Gend: res.Output.Baseinfo.Gend,
  15903. Naty: res.Output.Baseinfo.Naty,
  15904. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15905. PsnName: res.Output.Baseinfo.PsnName,
  15906. Idetinfo: idetinfoStr,
  15907. Insuinfo: infoStr,
  15908. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15909. InsuplcAdmdvs: insuplc_admdvs,
  15910. }
  15911. service.CreateHisPsn(psn)
  15912. c.ServeSuccessJSON(map[string]interface{}{
  15913. "patient": patient,
  15914. "number": res.Output.Baseinfo.Certno,
  15915. })
  15916. }
  15917. } else {
  15918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15919. return
  15920. }
  15921. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15922. res := c.GetoleInfo()
  15923. if res.Infcode == 0 {
  15924. var result string
  15925. if res.Output.MdtrtCertType == "01" {
  15926. 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)
  15927. } else if res.Output.MdtrtCertType == "02" {
  15928. 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)
  15929. } else if res.Output.MdtrtCertType == "03" {
  15930. 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)
  15931. }
  15932. var dat map[string]interface{}
  15933. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15934. fmt.Println(dat)
  15935. } else {
  15936. fmt.Println(err)
  15937. }
  15938. userJSONBytes, _ := json.Marshal(dat)
  15939. var res2 ResultTwo
  15940. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15941. utils.ErrorLog("解析失败:%v", err)
  15942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15943. return
  15944. }
  15945. if res2.Infcode == 0 {
  15946. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15947. if err == gorm.ErrRecordNotFound {
  15948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15949. return
  15950. } else if err != nil {
  15951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15952. return
  15953. } else {
  15954. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15955. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15956. infoStr := string(Iinfos)
  15957. idetinfoStr := string(Idetinfos)
  15958. var rf []*ResultFive
  15959. json.Unmarshal([]byte(infoStr), &rf)
  15960. var insutypes []*ResultFive
  15961. var insutype string
  15962. var is390 int = 0
  15963. var is310 int = 0
  15964. //var insuplc_admdvs string
  15965. for _, item := range rf {
  15966. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15967. insutypes = append(insutypes, item)
  15968. }
  15969. }
  15970. if len(insutypes) == 1 {
  15971. insutype = insutypes[0].Insutype
  15972. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15973. } else {
  15974. for _, i := range insutypes {
  15975. if i.Insutype == "390" {
  15976. is390 = 1
  15977. }
  15978. if i.Insutype == "310" {
  15979. is310 = 1
  15980. }
  15981. }
  15982. }
  15983. if is390 == 1 {
  15984. insutype = "390"
  15985. }
  15986. if is310 == 1 {
  15987. insutype = "310"
  15988. }
  15989. if len(insutypes) == 0 {
  15990. insutype = "310"
  15991. }
  15992. psn := &models.HisPsn{
  15993. PsnNo: res2.Output.Baseinfo.PsnNo,
  15994. PatientId: patient.ID,
  15995. //Brdy: res2.Output.Baseinfo.Brdy,
  15996. Certno: res2.Output.Baseinfo.Certno,
  15997. Gend: res2.Output.Baseinfo.Gend,
  15998. Naty: res2.Output.Baseinfo.Naty,
  15999. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16000. PsnName: res2.Output.Baseinfo.PsnName,
  16001. Idetinfo: idetinfoStr,
  16002. Insuinfo: infoStr,
  16003. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16004. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16005. VerifyNumber: res.Output.EcToken,
  16006. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16007. }
  16008. service.CreateHisPsn(psn)
  16009. var balc float64
  16010. for _, item := range rf {
  16011. if item.Insutype == insutype {
  16012. balc = item.Balc
  16013. }
  16014. }
  16015. c.ServeSuccessJSON(map[string]interface{}{
  16016. "patient": patient,
  16017. "number": res.Output.CardNo,
  16018. "insutype": insutype,
  16019. "blac": balc,
  16020. "desc": idetinfoStr,
  16021. })
  16022. }
  16023. } else {
  16024. c.ServeSuccessJSON(map[string]interface{}{
  16025. "failed_code": -10,
  16026. "msg": res2.ErrMsg,
  16027. })
  16028. }
  16029. } else {
  16030. c.ServeSuccessJSON(map[string]interface{}{
  16031. "failed_code": -10,
  16032. "msg": res.ErrMsg,
  16033. })
  16034. }
  16035. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16036. var insuplc_admdvs string
  16037. if len(patient.InsuplcAdmdvs) > 0 {
  16038. insuplc_admdvs = patient.InsuplcAdmdvs
  16039. } else {
  16040. if len(insuplc_admdvs_str) > 0 {
  16041. insuplc_admdvs = insuplc_admdvs_str
  16042. } else {
  16043. insuplc_admdvs = miConfig.InsuplcAdmdvs
  16044. }
  16045. }
  16046. //请求内网数据
  16047. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  16048. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16049. "&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 + "&token=" + ""
  16050. resp, requestErr := http.Get(api)
  16051. if requestErr != nil {
  16052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16053. return
  16054. }
  16055. body, ioErr := ioutil.ReadAll(resp.Body)
  16056. if ioErr != nil {
  16057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16059. return
  16060. }
  16061. var respJSON map[string]interface{}
  16062. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16065. return
  16066. }
  16067. status := respJSON["data"].(map[string]interface{})["status"].(string)
  16068. if status == "0" {
  16069. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  16070. c.ServeSuccessJSON(map[string]interface{}{
  16071. "failed_code": -10,
  16072. "msg": err_msg,
  16073. })
  16074. return
  16075. }
  16076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16077. var res ResultTwo
  16078. result, _ := json.Marshal(respJSON)
  16079. fmt.Println("log")
  16080. fmt.Println(string(result))
  16081. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16082. utils.ErrorLog("解析失败:%v", err)
  16083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16084. return
  16085. }
  16086. if res.Infcode == 0 {
  16087. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16088. if err == gorm.ErrRecordNotFound {
  16089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16090. return
  16091. } else if err != nil {
  16092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16093. return
  16094. } else {
  16095. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16096. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16097. infoStr := string(Iinfos)
  16098. idetinfoStr := string(Idetinfos)
  16099. psn := &models.HisPsn{
  16100. PsnNo: res.Output.Baseinfo.PsnNo,
  16101. PatientId: patient.ID,
  16102. Certno: res.Output.Baseinfo.Certno,
  16103. Gend: res.Output.Baseinfo.Gend,
  16104. Naty: res.Output.Baseinfo.Naty,
  16105. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16106. PsnName: res.Output.Baseinfo.PsnName,
  16107. Idetinfo: idetinfoStr,
  16108. Insuinfo: infoStr,
  16109. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16110. }
  16111. service.CreateHisPsn(psn)
  16112. var rf []*ResultFive
  16113. json.Unmarshal([]byte(infoStr), &rf)
  16114. var insutypes []*ResultFive
  16115. var is390 int = 0
  16116. var is310 int = 0
  16117. var insutype string
  16118. for _, item := range rf {
  16119. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16120. insutypes = append(insutypes, item)
  16121. }
  16122. }
  16123. if len(insutypes) == 1 {
  16124. insutype = insutypes[0].Insutype
  16125. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16126. } else {
  16127. for _, i := range insutypes {
  16128. if i.Insutype == "390" {
  16129. is390 = 1
  16130. }
  16131. if i.Insutype == "310" {
  16132. is310 = 1
  16133. }
  16134. }
  16135. }
  16136. if is390 == 1 {
  16137. insutype = "390"
  16138. }
  16139. if is310 == 1 {
  16140. insutype = "310"
  16141. }
  16142. if len(insutypes) == 0 {
  16143. insutype = "390"
  16144. }
  16145. c.ServeSuccessJSON(map[string]interface{}{
  16146. "patient": patient,
  16147. "insutype": insutype,
  16148. "number": res.Output.Baseinfo.Certno,
  16149. "info": res,
  16150. })
  16151. }
  16152. } else {
  16153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16154. return
  16155. }
  16156. } else {
  16157. SFZStr := c.GetSFZBaseInfo()
  16158. id_card_str := strings.Split(SFZStr, "^")
  16159. id_card_number := id_card_str[0]
  16160. card_sn := ""
  16161. 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)
  16162. var dat map[string]interface{}
  16163. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16164. fmt.Println(dat)
  16165. } else {
  16166. fmt.Println(err)
  16167. }
  16168. userJSONBytes, _ := json.Marshal(dat)
  16169. var res ResultTwo
  16170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16171. utils.ErrorLog("解析失败:%v", err)
  16172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16173. return
  16174. }
  16175. if res.Infcode == 0 {
  16176. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  16177. if err == gorm.ErrRecordNotFound {
  16178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16179. return
  16180. } else if err != nil {
  16181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16182. return
  16183. } else {
  16184. c.ServeSuccessJSON(map[string]interface{}{
  16185. "patient": patient,
  16186. "number": id_card_number,
  16187. })
  16188. }
  16189. } else {
  16190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16191. return
  16192. }
  16193. }
  16194. break
  16195. case 3:
  16196. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16197. var api string
  16198. if miConfig.MdtrtareaAdmvs == "320830" {
  16199. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16200. "&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
  16201. fmt.Println(api)
  16202. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16203. 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 +
  16204. "&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
  16205. fmt.Println(api)
  16206. } else {
  16207. 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 +
  16208. "&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)
  16209. }
  16210. resp, requestErr := http.Get(api)
  16211. if requestErr != nil {
  16212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16213. return
  16214. }
  16215. body, ioErr := ioutil.ReadAll(resp.Body)
  16216. if ioErr != nil {
  16217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16219. return
  16220. }
  16221. var respJSON map[string]interface{}
  16222. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16225. return
  16226. }
  16227. var status string
  16228. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16229. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16230. var token string
  16231. var res ResultTwo //1101结果
  16232. var res10265 ResultTwo10265 //1101结果
  16233. var card_info string //卡信息
  16234. var busi_card_info string
  16235. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16236. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16237. if status == "0" { //读卡成功
  16238. if card_type == "1" {
  16239. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16240. result, _ := json.Marshal(respJSON)
  16241. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16242. utils.ErrorLog("解析失败:%v", err)
  16243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16244. return
  16245. }
  16246. res.ErrMsg = res10265.ErrMsg
  16247. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16248. res.Infcode = infocode
  16249. res.Output = res10265.Output
  16250. res.InfRefmsgid = res10265.InfRefmsgid
  16251. } else {
  16252. //var card_info string //卡信息
  16253. //var busi_card_info string
  16254. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16255. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16256. //fmt.Println(card_info)
  16257. //fmt.Println(busi_card_info)
  16258. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16259. result, _ := json.Marshal(respJSON)
  16260. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16261. utils.ErrorLog("解析失败:%v", err)
  16262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16263. return
  16264. }
  16265. res.ErrMsg = res10265.ErrMsg
  16266. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16267. res.Infcode = infocode
  16268. res.Output = res10265.Output
  16269. res.InfRefmsgid = res10265.InfRefmsgid
  16270. }
  16271. if res.Infcode == 0 {
  16272. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16273. if err == gorm.ErrRecordNotFound {
  16274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16275. return
  16276. } else if err != nil {
  16277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16278. return
  16279. } else {
  16280. if card_type == "1" {
  16281. bas := strings.Split(card_info, "|")
  16282. basNumber := bas[2]
  16283. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16284. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16285. infoStr := string(Iinfos)
  16286. idetinfoStr := string(Idetinfos)
  16287. psn := &models.HisPsn{
  16288. PsnNo: res.Output.Baseinfo.PsnNo,
  16289. PatientId: patient.ID,
  16290. Certno: res.Output.Baseinfo.Certno,
  16291. //Brdy: res.Output.Baseinfo.Brdy,
  16292. Gend: res.Output.Baseinfo.Gend,
  16293. Naty: res.Output.Baseinfo.Naty,
  16294. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16295. PsnName: res.Output.Baseinfo.PsnName,
  16296. Idetinfo: idetinfoStr,
  16297. Insuinfo: infoStr,
  16298. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16299. CardInfo: card_info,
  16300. VerifyNumber: busi_card_info,
  16301. }
  16302. service.CreateHisPsn(psn)
  16303. c.ServeSuccessJSON(map[string]interface{}{
  16304. "patient": patient,
  16305. "number": basNumber,
  16306. })
  16307. } else {
  16308. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16309. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16310. infoStr := string(Iinfos)
  16311. idetinfoStr := string(Idetinfos)
  16312. psn := &models.HisPsn{
  16313. PsnNo: res.Output.Baseinfo.PsnNo,
  16314. PatientId: patient.ID,
  16315. Certno: res.Output.Baseinfo.Certno,
  16316. Gend: res.Output.Baseinfo.Gend,
  16317. Naty: res.Output.Baseinfo.Naty,
  16318. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16319. PsnName: res.Output.Baseinfo.PsnName,
  16320. Idetinfo: idetinfoStr,
  16321. Insuinfo: infoStr,
  16322. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16323. CardInfo: card_info,
  16324. VerifyNumber: token,
  16325. }
  16326. service.CreateHisPsn(psn)
  16327. var rf []*ResultFive
  16328. json.Unmarshal([]byte(infoStr), &rf)
  16329. var insutypes []*ResultFive
  16330. var insutype string
  16331. var is390 int = 0
  16332. var is310 int = 0
  16333. for _, item := range rf {
  16334. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16335. insutypes = append(insutypes, item)
  16336. }
  16337. }
  16338. if len(insutypes) == 1 {
  16339. insutype = insutypes[0].Insutype
  16340. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16341. } else {
  16342. for _, i := range insutypes {
  16343. if i.Insutype == "390" {
  16344. is390 = 1
  16345. }
  16346. if i.Insutype == "310" {
  16347. is310 = 1
  16348. }
  16349. }
  16350. }
  16351. if is390 == 1 {
  16352. insutype = "390"
  16353. }
  16354. if is310 == 1 {
  16355. insutype = "310"
  16356. }
  16357. if len(insutypes) == 0 {
  16358. insutype = "310"
  16359. }
  16360. c.ServeSuccessJSON(map[string]interface{}{
  16361. "patient": patient,
  16362. "number": token,
  16363. "insutype": insutype,
  16364. })
  16365. }
  16366. }
  16367. } else {
  16368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16369. return
  16370. }
  16371. } else { //读卡失败
  16372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16373. return
  16374. }
  16375. }
  16376. break
  16377. case 4:
  16378. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16379. var api string
  16380. if miConfig.MdtrtareaAdmvs == "320830" {
  16381. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16382. "&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
  16383. fmt.Println(api)
  16384. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16385. 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 +
  16386. "&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
  16387. fmt.Println(api)
  16388. } else {
  16389. 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 +
  16390. "&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)
  16391. }
  16392. resp, requestErr := http.Get(api)
  16393. if requestErr != nil {
  16394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16395. return
  16396. }
  16397. body, ioErr := ioutil.ReadAll(resp.Body)
  16398. if ioErr != nil {
  16399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16401. return
  16402. }
  16403. var respJSON map[string]interface{}
  16404. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16407. return
  16408. }
  16409. var status string
  16410. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16411. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16412. var token string
  16413. var res ResultTwo //1101结果
  16414. var res10265 ResultTwo10265 //1101结果
  16415. if status == "0" { //读卡成功
  16416. var card_info string //卡信息
  16417. var busi_card_info string
  16418. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16419. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16420. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16421. fmt.Println(card_info)
  16422. fmt.Println(busi_card_info)
  16423. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16424. result, _ := json.Marshal(respJSON)
  16425. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16426. utils.ErrorLog("解析失败:%v", err)
  16427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16428. return
  16429. }
  16430. res.ErrMsg = res10265.ErrMsg
  16431. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16432. res.Infcode = infocode
  16433. res.Output = res10265.Output
  16434. res.InfRefmsgid = res10265.InfRefmsgid
  16435. if res.Infcode == 0 {
  16436. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16437. if err == gorm.ErrRecordNotFound {
  16438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16439. return
  16440. } else if err != nil {
  16441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16442. return
  16443. } else {
  16444. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16445. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16446. infoStr := string(Iinfos)
  16447. idetinfoStr := string(Idetinfos)
  16448. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16449. psn := &models.HisPsn{
  16450. PsnNo: res.Output.Baseinfo.PsnNo,
  16451. PatientId: patient.ID,
  16452. Certno: res.Output.Baseinfo.Certno,
  16453. Brdy: b,
  16454. Age: float64(age),
  16455. //Brdy: res.Output.Baseinfo.Brdy,
  16456. Gend: res.Output.Baseinfo.Gend,
  16457. Naty: res.Output.Baseinfo.Naty,
  16458. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16459. PsnName: res.Output.Baseinfo.PsnName,
  16460. Idetinfo: idetinfoStr,
  16461. Insuinfo: infoStr,
  16462. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16463. CardInfo: card_info,
  16464. VerifyNumber: token,
  16465. }
  16466. var rf []*ResultFive
  16467. json.Unmarshal([]byte(infoStr), &rf)
  16468. var insutypes []*ResultFive
  16469. var insutype string
  16470. var is390 int = 0
  16471. var is310 int = 0
  16472. for _, item := range rf {
  16473. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16474. insutypes = append(insutypes, item)
  16475. }
  16476. }
  16477. if len(insutypes) == 1 {
  16478. insutype = insutypes[0].Insutype
  16479. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16480. } else {
  16481. for _, i := range insutypes {
  16482. if i.Insutype == "390" {
  16483. is390 = 1
  16484. }
  16485. if i.Insutype == "310" {
  16486. is310 = 1
  16487. }
  16488. }
  16489. }
  16490. if is390 == 1 {
  16491. insutype = "390"
  16492. }
  16493. if is310 == 1 {
  16494. insutype = "310"
  16495. }
  16496. if len(insutypes) == 0 {
  16497. insutype = "310"
  16498. }
  16499. service.CreateHisPsn(psn)
  16500. c.ServeSuccessJSON(map[string]interface{}{
  16501. "patient": patient,
  16502. "number": token,
  16503. "insutype": insutype,
  16504. })
  16505. }
  16506. } else {
  16507. c.ServeSuccessJSON(map[string]interface{}{
  16508. "failed_code": -10,
  16509. "msg": res.ErrMsg,
  16510. })
  16511. }
  16512. } else { //读卡失败
  16513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16514. return
  16515. }
  16516. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16517. var api string
  16518. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16519. "&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
  16520. resp, requestErr := http.Get(api)
  16521. if requestErr != nil {
  16522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16523. return
  16524. }
  16525. body, ioErr := ioutil.ReadAll(resp.Body)
  16526. if ioErr != nil {
  16527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16529. return
  16530. }
  16531. var respJSON map[string]interface{}
  16532. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16535. return
  16536. }
  16537. var status string
  16538. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16539. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16540. var token string
  16541. var res ResultTwo //1101结果
  16542. if status == "1" { //读卡成功
  16543. var card_info string //卡信息
  16544. var busi_card_info string
  16545. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16546. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16547. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16548. fmt.Println(card_info)
  16549. fmt.Println(busi_card_info)
  16550. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16551. result, _ := json.Marshal(respJSON)
  16552. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16553. utils.ErrorLog("解析失败:%v", err)
  16554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16555. return
  16556. }
  16557. if res.Infcode == 0 {
  16558. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16559. if err == gorm.ErrRecordNotFound {
  16560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16561. return
  16562. } else if err != nil {
  16563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16564. return
  16565. } else {
  16566. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16567. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16568. infoStr := string(Iinfos)
  16569. idetinfoStr := string(Idetinfos)
  16570. psn := &models.HisPsn{
  16571. PsnNo: res.Output.Baseinfo.PsnNo,
  16572. PatientId: patient.ID,
  16573. Certno: res.Output.Baseinfo.Certno,
  16574. Gend: res.Output.Baseinfo.Gend,
  16575. Naty: res.Output.Baseinfo.Naty,
  16576. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16577. PsnName: res.Output.Baseinfo.PsnName,
  16578. Idetinfo: idetinfoStr,
  16579. Insuinfo: infoStr,
  16580. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16581. CardInfo: card_info,
  16582. VerifyNumber: token,
  16583. }
  16584. var rf []*ResultFive
  16585. json.Unmarshal([]byte(infoStr), &rf)
  16586. var insutypes []*ResultFive
  16587. var insutype string
  16588. var is390 int = 0
  16589. var is310 int = 0
  16590. for _, item := range rf {
  16591. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16592. insutypes = append(insutypes, item)
  16593. }
  16594. }
  16595. if len(insutypes) == 1 {
  16596. insutype = insutypes[0].Insutype
  16597. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16598. } else {
  16599. for _, i := range insutypes {
  16600. if i.Insutype == "390" {
  16601. is390 = 1
  16602. }
  16603. if i.Insutype == "310" {
  16604. is310 = 1
  16605. }
  16606. }
  16607. }
  16608. if is390 == 1 {
  16609. insutype = "390"
  16610. }
  16611. if is310 == 1 {
  16612. insutype = "310"
  16613. }
  16614. if len(insutypes) == 0 {
  16615. insutype = "310"
  16616. }
  16617. service.CreateHisPsn(psn)
  16618. c.ServeSuccessJSON(map[string]interface{}{
  16619. "patient": patient,
  16620. "number": token,
  16621. "insutype": insutype,
  16622. })
  16623. }
  16624. } else {
  16625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16626. return
  16627. }
  16628. } else { //读卡失败
  16629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16630. return
  16631. }
  16632. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16633. var api string
  16634. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16635. "&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
  16636. resp, requestErr := http.Get(api)
  16637. if requestErr != nil {
  16638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16639. return
  16640. }
  16641. body, ioErr := ioutil.ReadAll(resp.Body)
  16642. if ioErr != nil {
  16643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16645. return
  16646. }
  16647. var respJSON map[string]interface{}
  16648. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16651. return
  16652. }
  16653. var status string
  16654. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16655. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16656. var token string
  16657. var res ResultTwo //1101结果
  16658. if status == "1" { //读卡成功
  16659. var card_info string //卡信息
  16660. var busi_card_info string
  16661. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16662. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16663. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16664. fmt.Println(card_info)
  16665. fmt.Println(busi_card_info)
  16666. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16667. result, _ := json.Marshal(respJSON)
  16668. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16669. utils.ErrorLog("解析失败:%v", err)
  16670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16671. return
  16672. }
  16673. if res.Infcode == 0 {
  16674. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16675. if err == gorm.ErrRecordNotFound {
  16676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16677. return
  16678. } else if err != nil {
  16679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16680. return
  16681. } else {
  16682. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16683. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16684. infoStr := string(Iinfos)
  16685. idetinfoStr := string(Idetinfos)
  16686. psn := &models.HisPsn{
  16687. PsnNo: res.Output.Baseinfo.PsnNo,
  16688. PatientId: patient.ID,
  16689. Certno: res.Output.Baseinfo.Certno,
  16690. Gend: res.Output.Baseinfo.Gend,
  16691. Naty: res.Output.Baseinfo.Naty,
  16692. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16693. PsnName: res.Output.Baseinfo.PsnName,
  16694. Idetinfo: idetinfoStr,
  16695. Insuinfo: infoStr,
  16696. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16697. CardInfo: card_info,
  16698. VerifyNumber: token,
  16699. }
  16700. var rf []*ResultFive
  16701. json.Unmarshal([]byte(infoStr), &rf)
  16702. var insutypes []*ResultFive
  16703. var insutype string
  16704. var is390 int = 0
  16705. var is310 int = 0
  16706. for _, item := range rf {
  16707. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16708. insutypes = append(insutypes, item)
  16709. }
  16710. }
  16711. if len(insutypes) == 1 {
  16712. insutype = insutypes[0].Insutype
  16713. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16714. } else {
  16715. for _, i := range insutypes {
  16716. if i.Insutype == "390" {
  16717. is390 = 1
  16718. }
  16719. if i.Insutype == "310" {
  16720. is310 = 1
  16721. }
  16722. }
  16723. }
  16724. if is390 == 1 {
  16725. insutype = "390"
  16726. }
  16727. if is310 == 1 {
  16728. insutype = "310"
  16729. }
  16730. if len(insutypes) == 0 {
  16731. insutype = "390"
  16732. }
  16733. service.CreateHisPsn(psn)
  16734. c.ServeSuccessJSON(map[string]interface{}{
  16735. "patient": patient,
  16736. "number": token,
  16737. "insutype": insutype,
  16738. })
  16739. }
  16740. } else {
  16741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16742. return
  16743. }
  16744. } else { //读卡失败
  16745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16746. return
  16747. }
  16748. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16749. //idNo := c.GetString("idNo")
  16750. //userName := c.GetString("userName")
  16751. //ecToken := c.GetString("ecToken")
  16752. //insuOrg := c.GetString("insuOrg")
  16753. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  16754. utils.ErrorLog("解析失败:%v", json_result)
  16755. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16756. type ELeData struct {
  16757. Data struct {
  16758. IdNo string `json:"idNo"`
  16759. IdType string `json:"idType"`
  16760. UserName string `json:"userName"`
  16761. EcToken string `json:"ecToken"`
  16762. InsuOrg string `json:"insuOrg"`
  16763. Gender string `json:"gender"`
  16764. Birthday string `json:"birthday"`
  16765. Nationality string `json:"nationality"`
  16766. Email string `json:"email"`
  16767. Extra string `json:"extra"`
  16768. } `json:"data"`
  16769. Code int `json:"code"`
  16770. Message string `json:"message"`
  16771. }
  16772. var ele ELeData
  16773. err := json.Unmarshal([]byte(json_result), &ele)
  16774. if err != nil {
  16775. utils.ErrorLog("解析失败:%v", err)
  16776. }
  16777. token := ele.Data.EcToken
  16778. token = Remove0000(token)
  16779. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  16780. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16781. var res ResultTwo
  16782. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16783. utils.ErrorLog("解析失败:%v", err)
  16784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16785. return
  16786. }
  16787. if res.Infcode == 0 {
  16788. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16789. if err == gorm.ErrRecordNotFound {
  16790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16791. return
  16792. } else if err != nil {
  16793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16794. return
  16795. } else {
  16796. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16797. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16798. infoStr := string(Iinfos)
  16799. idetinfoStr := string(Idetinfos)
  16800. psn := &models.HisPsn{
  16801. PsnNo: res.Output.Baseinfo.PsnNo,
  16802. PatientId: patient.ID,
  16803. Certno: res.Output.Baseinfo.Certno,
  16804. Gend: res.Output.Baseinfo.Gend,
  16805. Naty: res.Output.Baseinfo.Naty,
  16806. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16807. PsnName: res.Output.Baseinfo.PsnName,
  16808. Idetinfo: idetinfoStr,
  16809. Insuinfo: infoStr,
  16810. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16811. CardInfo: "",
  16812. Stage: "1",
  16813. VerifyNumber: token,
  16814. InsuplcAdmdvs: ele.Data.InsuOrg,
  16815. }
  16816. service.CreateHisPsn(psn)
  16817. var rf []*ResultFive
  16818. json.Unmarshal([]byte(infoStr), &rf)
  16819. var insutypes []*ResultFive
  16820. var insutype string
  16821. var is390 int = 0
  16822. var is310 int = 0
  16823. for _, item := range rf {
  16824. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16825. insutypes = append(insutypes, item)
  16826. }
  16827. }
  16828. if len(insutypes) == 1 {
  16829. insutype = insutypes[0].Insutype
  16830. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16831. } else {
  16832. for _, i := range insutypes {
  16833. if i.Insutype == "390" {
  16834. is390 = 1
  16835. }
  16836. if i.Insutype == "310" {
  16837. is310 = 1
  16838. }
  16839. }
  16840. }
  16841. if is390 == 1 {
  16842. insutype = "390"
  16843. }
  16844. if is310 == 1 {
  16845. insutype = "310"
  16846. }
  16847. if len(insutypes) == 0 {
  16848. insutype = "310"
  16849. }
  16850. c.ServeSuccessJSON(map[string]interface{}{
  16851. "patient": patient,
  16852. "number": token,
  16853. "insutype": insutype,
  16854. })
  16855. }
  16856. } else {
  16857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16858. return
  16859. }
  16860. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16861. //if initFlag == 0 {
  16862. //c.TestGetJiangXiBasBaseInit()
  16863. //}
  16864. //if initEleFlag == 0 {
  16865. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16866. //}
  16867. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16868. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16869. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16870. type ELeData struct {
  16871. Data struct {
  16872. IdNo string `json:"idNo"`
  16873. IdType string `json:"idType"`
  16874. UserName string `json:"userName"`
  16875. EcToken string `json:"ecToken"`
  16876. InsuOrg string `json:"insuOrg"`
  16877. Gender string `json:"gender"`
  16878. Birthday string `json:"birthday"`
  16879. Nationality string `json:"nationality"`
  16880. Email string `json:"email"`
  16881. Extra string `json:"extra"`
  16882. } `json:"data"`
  16883. Code int `json:"code"`
  16884. Message string `json:"message"`
  16885. }
  16886. var ele ELeData
  16887. err := json.Unmarshal([]byte(result), &ele)
  16888. if err != nil {
  16889. utils.ErrorLog("解析失败:%v", err)
  16890. }
  16891. token := ele.Data.EcToken
  16892. token = Remove0000(token)
  16893. 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)
  16894. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16895. var res ResultTwo
  16896. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16897. utils.ErrorLog("解析失败:%v", err)
  16898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16899. return
  16900. }
  16901. if res.Infcode == 0 {
  16902. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16903. if err == gorm.ErrRecordNotFound {
  16904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16905. return
  16906. } else if err != nil {
  16907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16908. return
  16909. } else {
  16910. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16911. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16912. infoStr := string(Iinfos)
  16913. idetinfoStr := string(Idetinfos)
  16914. psn := &models.HisPsn{
  16915. PsnNo: res.Output.Baseinfo.PsnNo,
  16916. PatientId: patient.ID,
  16917. Certno: res.Output.Baseinfo.Certno,
  16918. Gend: res.Output.Baseinfo.Gend,
  16919. Naty: res.Output.Baseinfo.Naty,
  16920. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16921. PsnName: res.Output.Baseinfo.PsnName,
  16922. Idetinfo: idetinfoStr,
  16923. Insuinfo: infoStr,
  16924. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16925. CardInfo: "",
  16926. VerifyNumber: token,
  16927. InsuplcAdmdvs: ele.Data.InsuOrg,
  16928. }
  16929. service.CreateHisPsn(psn)
  16930. var rf []*ResultFive
  16931. json.Unmarshal([]byte(infoStr), &rf)
  16932. var insutypes []*ResultFive
  16933. var insutype string
  16934. var is390 int = 0
  16935. var is310 int = 0
  16936. for _, item := range rf {
  16937. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16938. insutypes = append(insutypes, item)
  16939. }
  16940. }
  16941. if len(insutypes) == 1 {
  16942. insutype = insutypes[0].Insutype
  16943. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16944. } else {
  16945. for _, i := range insutypes {
  16946. if i.Insutype == "390" {
  16947. is390 = 1
  16948. }
  16949. if i.Insutype == "310" {
  16950. is310 = 1
  16951. }
  16952. }
  16953. }
  16954. if is390 == 1 {
  16955. insutype = "390"
  16956. }
  16957. if is310 == 1 {
  16958. insutype = "310"
  16959. }
  16960. if len(insutypes) == 0 {
  16961. insutype = "310"
  16962. }
  16963. c.ServeSuccessJSON(map[string]interface{}{
  16964. "patient": patient,
  16965. "number": token,
  16966. "insutype": insutype,
  16967. })
  16968. }
  16969. } else {
  16970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16971. return
  16972. }
  16973. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16974. //if initFlag == 0 {
  16975. //c.TestGetJiangXiBasBaseInit()
  16976. //}
  16977. //if initEleFlag == 0 {
  16978. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16979. //}
  16980. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16981. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16982. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16983. type ELeData struct {
  16984. Data struct {
  16985. IdNo string `json:"idNo"`
  16986. IdType string `json:"idType"`
  16987. UserName string `json:"userName"`
  16988. EcToken string `json:"ecToken"`
  16989. InsuOrg string `json:"insuOrg"`
  16990. Gender string `json:"gender"`
  16991. Birthday string `json:"birthday"`
  16992. Nationality string `json:"nationality"`
  16993. Email string `json:"email"`
  16994. Extra string `json:"extra"`
  16995. } `json:"data"`
  16996. Code int `json:"code"`
  16997. Message string `json:"message"`
  16998. }
  16999. var ele ELeData
  17000. err := json.Unmarshal([]byte(result), &ele)
  17001. if err != nil {
  17002. utils.ErrorLog("解析失败:%v", err)
  17003. }
  17004. token := ele.Data.EcToken
  17005. token = Remove0000(token)
  17006. 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)
  17007. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17008. var res ResultTwo
  17009. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17010. utils.ErrorLog("解析失败:%v", err)
  17011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17012. return
  17013. }
  17014. if res.Infcode == 0 {
  17015. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17016. if err == gorm.ErrRecordNotFound {
  17017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17018. return
  17019. } else if err != nil {
  17020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17021. return
  17022. } else {
  17023. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17024. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17025. infoStr := string(Iinfos)
  17026. idetinfoStr := string(Idetinfos)
  17027. psn := &models.HisPsn{
  17028. PsnNo: res.Output.Baseinfo.PsnNo,
  17029. PatientId: patient.ID,
  17030. Certno: res.Output.Baseinfo.Certno,
  17031. Gend: res.Output.Baseinfo.Gend,
  17032. Naty: res.Output.Baseinfo.Naty,
  17033. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17034. PsnName: res.Output.Baseinfo.PsnName,
  17035. Idetinfo: idetinfoStr,
  17036. Insuinfo: infoStr,
  17037. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17038. CardInfo: "",
  17039. VerifyNumber: token,
  17040. InsuplcAdmdvs: ele.Data.InsuOrg,
  17041. }
  17042. service.CreateHisPsn(psn)
  17043. var rf []*ResultFive
  17044. json.Unmarshal([]byte(infoStr), &rf)
  17045. var insutypes []*ResultFive
  17046. var insutype string
  17047. var is390 int = 0
  17048. var is310 int = 0
  17049. for _, item := range rf {
  17050. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17051. insutypes = append(insutypes, item)
  17052. }
  17053. }
  17054. if len(insutypes) == 1 {
  17055. insutype = insutypes[0].Insutype
  17056. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17057. } else {
  17058. for _, i := range insutypes {
  17059. if i.Insutype == "390" {
  17060. is390 = 1
  17061. }
  17062. if i.Insutype == "310" {
  17063. is310 = 1
  17064. }
  17065. }
  17066. }
  17067. if is390 == 1 {
  17068. insutype = "390"
  17069. }
  17070. if is310 == 1 {
  17071. insutype = "310"
  17072. }
  17073. if len(insutypes) == 0 {
  17074. insutype = "310"
  17075. }
  17076. c.ServeSuccessJSON(map[string]interface{}{
  17077. "patient": patient,
  17078. "number": token,
  17079. "insutype": insutype,
  17080. })
  17081. }
  17082. } else {
  17083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17084. return
  17085. }
  17086. } else if miConfig.MdtrtareaAdmvs == "360100" {
  17087. //if initFlag == 0 {
  17088. //c.TestGetJiangXiBasBaseInit()
  17089. //}
  17090. //if initEleFlag == 0 {
  17091. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17092. //}
  17093. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  17094. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  17095. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17096. type ELeData struct {
  17097. Data struct {
  17098. IdNo string `json:"idNo"`
  17099. IdType string `json:"idType"`
  17100. UserName string `json:"userName"`
  17101. EcToken string `json:"ecToken"`
  17102. InsuOrg string `json:"insuOrg"`
  17103. Gender string `json:"gender"`
  17104. Birthday string `json:"birthday"`
  17105. Nationality string `json:"nationality"`
  17106. Email string `json:"email"`
  17107. Extra string `json:"extra"`
  17108. } `json:"data"`
  17109. Code int `json:"code"`
  17110. Message string `json:"message"`
  17111. }
  17112. var ele ELeData
  17113. err := json.Unmarshal([]byte(result), &ele)
  17114. if err != nil {
  17115. utils.ErrorLog("解析失败:%v", err)
  17116. }
  17117. token := ele.Data.EcToken
  17118. token = Remove0000(token)
  17119. 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)
  17120. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17121. var res ResultTwo
  17122. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17123. utils.ErrorLog("解析失败:%v", err)
  17124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17125. return
  17126. }
  17127. if res.Infcode == 0 {
  17128. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17129. if err == gorm.ErrRecordNotFound {
  17130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17131. return
  17132. } else if err != nil {
  17133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17134. return
  17135. } else {
  17136. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17137. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17138. infoStr := string(Iinfos)
  17139. idetinfoStr := string(Idetinfos)
  17140. psn := &models.HisPsn{
  17141. PsnNo: res.Output.Baseinfo.PsnNo,
  17142. PatientId: patient.ID,
  17143. Certno: res.Output.Baseinfo.Certno,
  17144. Gend: res.Output.Baseinfo.Gend,
  17145. Naty: res.Output.Baseinfo.Naty,
  17146. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17147. PsnName: res.Output.Baseinfo.PsnName,
  17148. Idetinfo: idetinfoStr,
  17149. Insuinfo: infoStr,
  17150. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17151. CardInfo: "",
  17152. VerifyNumber: token,
  17153. InsuplcAdmdvs: ele.Data.InsuOrg,
  17154. }
  17155. service.CreateHisPsn(psn)
  17156. var rf []*ResultFive
  17157. json.Unmarshal([]byte(infoStr), &rf)
  17158. var insutypes []*ResultFive
  17159. var insutype string
  17160. var is390 int = 0
  17161. var is310 int = 0
  17162. for _, item := range rf {
  17163. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17164. insutypes = append(insutypes, item)
  17165. }
  17166. }
  17167. if len(insutypes) == 1 {
  17168. insutype = insutypes[0].Insutype
  17169. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17170. } else {
  17171. for _, i := range insutypes {
  17172. if i.Insutype == "390" {
  17173. is390 = 1
  17174. }
  17175. if i.Insutype == "310" {
  17176. is310 = 1
  17177. }
  17178. }
  17179. }
  17180. if is390 == 1 {
  17181. insutype = "390"
  17182. }
  17183. if is310 == 1 {
  17184. insutype = "310"
  17185. }
  17186. if len(insutypes) == 0 {
  17187. insutype = "310"
  17188. }
  17189. c.ServeSuccessJSON(map[string]interface{}{
  17190. "patient": patient,
  17191. "number": token,
  17192. "insutype": insutype,
  17193. })
  17194. }
  17195. } else {
  17196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17197. return
  17198. }
  17199. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17200. //if initFlag == 0 {
  17201. c.TestGetJiangXiBasBaseInit()
  17202. //}
  17203. //if initEleFlag == 0 {
  17204. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17205. //}
  17206. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17207. type ELeData struct {
  17208. Data struct {
  17209. IdNo string `json:"idNo"`
  17210. IdType string `json:"idType"`
  17211. UserName string `json:"userName"`
  17212. EcToken string `json:"ecToken"`
  17213. InsuOrg string `json:"insuOrg"`
  17214. Gender string `json:"gender"`
  17215. Birthday string `json:"birthday"`
  17216. Nationality string `json:"nationality"`
  17217. Email string `json:"email"`
  17218. Extra string `json:"extra"`
  17219. } `json:"data"`
  17220. Code int `json:"code"`
  17221. Message string `json:"message"`
  17222. }
  17223. var ele ELeData
  17224. err := json.Unmarshal([]byte(json_result), &ele)
  17225. if err != nil {
  17226. utils.ErrorLog("解析失败:%v", err)
  17227. }
  17228. token := ele.Data.EcToken
  17229. token = Remove0000(token)
  17230. 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)
  17231. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17232. var res ResultTwo
  17233. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17234. utils.ErrorLog("解析失败:%v", err)
  17235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17236. return
  17237. }
  17238. if res.Infcode == 0 {
  17239. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17240. if err == gorm.ErrRecordNotFound {
  17241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17242. return
  17243. } else if err != nil {
  17244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17245. return
  17246. } else {
  17247. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17248. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17249. infoStr := string(Iinfos)
  17250. idetinfoStr := string(Idetinfos)
  17251. psn := &models.HisPsn{
  17252. PsnNo: res.Output.Baseinfo.PsnNo,
  17253. PatientId: patient.ID,
  17254. Certno: res.Output.Baseinfo.Certno,
  17255. Gend: res.Output.Baseinfo.Gend,
  17256. Naty: res.Output.Baseinfo.Naty,
  17257. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17258. PsnName: res.Output.Baseinfo.PsnName,
  17259. Idetinfo: idetinfoStr,
  17260. Insuinfo: infoStr,
  17261. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17262. CardInfo: "",
  17263. VerifyNumber: token,
  17264. }
  17265. service.CreateHisPsn(psn)
  17266. var rf []*ResultFive
  17267. json.Unmarshal([]byte(infoStr), &rf)
  17268. var insutypes []*ResultFive
  17269. var insutype string
  17270. var is390 int = 0
  17271. var is310 int = 0
  17272. for _, item := range rf {
  17273. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17274. insutypes = append(insutypes, item)
  17275. }
  17276. }
  17277. if len(insutypes) == 1 {
  17278. insutype = insutypes[0].Insutype
  17279. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17280. } else {
  17281. for _, i := range insutypes {
  17282. if i.Insutype == "390" {
  17283. is390 = 1
  17284. }
  17285. if i.Insutype == "310" {
  17286. is310 = 1
  17287. }
  17288. }
  17289. }
  17290. if is390 == 1 {
  17291. insutype = "390"
  17292. }
  17293. if is310 == 1 {
  17294. insutype = "310"
  17295. }
  17296. if len(insutypes) == 0 {
  17297. insutype = "310"
  17298. }
  17299. c.ServeSuccessJSON(map[string]interface{}{
  17300. "patient": patient,
  17301. "number": token,
  17302. "insutype": insutype,
  17303. })
  17304. }
  17305. } else {
  17306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17307. return
  17308. }
  17309. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17310. type ELeData struct {
  17311. Code string `json:"code"`
  17312. Data struct {
  17313. Aac002 string `json:"aac002"`
  17314. Aaz500 string `json:"aaz500"`
  17315. ActCardNo string `json:"actCardNo"`
  17316. Bab520 string `json:"bab520"`
  17317. Bkz543 string `json:"bkz543"`
  17318. BusinessType string `json:"businessType"`
  17319. CertfCodg string `json:"certfCodg"`
  17320. EcIndexNo string `json:"ecIndexNo"`
  17321. EcToken string `json:"ecToken"`
  17322. ID0000 string `json:"id0000"`
  17323. IDNo string `json:"idNo"`
  17324. IDType string `json:"idType"`
  17325. Idcode string `json:"idcode"`
  17326. IdentityToken string `json:"identity_token"`
  17327. InsuOrg string `json:"insuOrg"`
  17328. OfficeID string `json:"officeId"`
  17329. OfficeName string `json:"officeName"`
  17330. OperatorID string `json:"operatorId"`
  17331. OperatorName string `json:"operatorName"`
  17332. OrgID string `json:"orgId"`
  17333. UserName string `json:"userName"`
  17334. } `json:"data"`
  17335. Infno interface{} `json:"infno"`
  17336. Message string `json:"message"`
  17337. OrgID string `json:"orgId"`
  17338. TransType string `json:"transType"`
  17339. }
  17340. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  17341. outPutInfo = Remove0000(outPutInfo)
  17342. if len(outPutInfo) > 0 {
  17343. var ele ELeData
  17344. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17345. if err != nil {
  17346. utils.ErrorLog("解析失败:%v", err)
  17347. }
  17348. token := ele.Data.EcToken
  17349. fmt.Println(inputInfo)
  17350. fmt.Println(outPutInfo)
  17351. 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)
  17352. saveLog(result, requestLog, "1101", "获取人员信息")
  17353. var dat map[string]interface{}
  17354. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17355. fmt.Println(dat)
  17356. } else {
  17357. fmt.Println(err)
  17358. }
  17359. userJSONBytes, _ := json.Marshal(dat)
  17360. var res ResultTwo
  17361. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17362. utils.ErrorLog("解析失败:%v", err)
  17363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17364. return
  17365. }
  17366. res.ErrMsg = errMsgLog
  17367. if res.Infcode == 0 {
  17368. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17369. if err == gorm.ErrRecordNotFound {
  17370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17371. return
  17372. } else if err != nil {
  17373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17374. return
  17375. } else {
  17376. fmt.Println(res)
  17377. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17378. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17379. infoStr := string(Iinfos)
  17380. idetinfoStr := string(Idetinfos)
  17381. psn := &models.HisPsn{
  17382. PsnNo: res.Output.Baseinfo.PsnNo,
  17383. PatientId: patient.ID,
  17384. Certno: res.Output.Baseinfo.Certno,
  17385. Gend: res.Output.Baseinfo.Gend,
  17386. Naty: res.Output.Baseinfo.Naty,
  17387. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17388. PsnName: res.Output.Baseinfo.PsnName,
  17389. Idetinfo: idetinfoStr,
  17390. Insuinfo: infoStr,
  17391. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17392. CardInfo: outPutInfo,
  17393. VerifyNumber: token,
  17394. InsuplcAdmdvs: ele.Data.InsuOrg,
  17395. }
  17396. service.CreateHisPsn(psn)
  17397. var rf []*ResultFive
  17398. json.Unmarshal([]byte(infoStr), &rf)
  17399. var insutypes []*ResultFive
  17400. var insutype string
  17401. var is390 int = 0
  17402. var is310 int = 0
  17403. for _, item := range rf {
  17404. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17405. insutypes = append(insutypes, item)
  17406. }
  17407. }
  17408. if len(insutypes) == 1 {
  17409. insutype = insutypes[0].Insutype
  17410. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17411. } else {
  17412. for _, i := range insutypes {
  17413. if i.Insutype == "390" {
  17414. is390 = 1
  17415. }
  17416. if i.Insutype == "310" {
  17417. is310 = 1
  17418. }
  17419. }
  17420. }
  17421. if is390 == 1 {
  17422. insutype = "390"
  17423. }
  17424. if is310 == 1 {
  17425. insutype = "310"
  17426. }
  17427. if len(insutypes) == 0 {
  17428. insutype = "310"
  17429. }
  17430. c.ServeSuccessJSON(map[string]interface{}{
  17431. "patient": patient,
  17432. "number": token,
  17433. "insutype": insutype,
  17434. })
  17435. }
  17436. } else {
  17437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17438. return
  17439. }
  17440. }
  17441. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17442. var api string
  17443. 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 +
  17444. "&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
  17445. resp, requestErr := http.Get(api)
  17446. if requestErr != nil {
  17447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17448. return
  17449. }
  17450. body, ioErr := ioutil.ReadAll(resp.Body)
  17451. if ioErr != nil {
  17452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17454. return
  17455. }
  17456. var respJSON map[string]interface{}
  17457. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17460. return
  17461. }
  17462. var status string
  17463. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17464. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17465. var token string
  17466. var res ResultTwo //1101结果
  17467. var res10265 ResultTwo10265 //1101结果
  17468. if status == "0" { //读卡成功
  17469. var card_info string //卡信息
  17470. var busi_card_info string
  17471. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17472. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17473. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17474. fmt.Println(card_info)
  17475. fmt.Println(busi_card_info)
  17476. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17477. result, _ := json.Marshal(respJSON)
  17478. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17479. utils.ErrorLog("解析失败:%v", err)
  17480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17481. return
  17482. }
  17483. res.ErrMsg = res10265.ErrMsg
  17484. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17485. res.Infcode = infocode
  17486. res.Output = res10265.Output
  17487. res.InfRefmsgid = res10265.InfRefmsgid
  17488. if res.Infcode == 0 {
  17489. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17490. if err == gorm.ErrRecordNotFound {
  17491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17492. return
  17493. } else if err != nil {
  17494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17495. return
  17496. } else {
  17497. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17498. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17499. infoStr := string(Iinfos)
  17500. idetinfoStr := string(Idetinfos)
  17501. psn := &models.HisPsn{
  17502. PsnNo: res.Output.Baseinfo.PsnNo,
  17503. PatientId: patient.ID,
  17504. Certno: res.Output.Baseinfo.Certno,
  17505. Gend: res.Output.Baseinfo.Gend,
  17506. Naty: res.Output.Baseinfo.Naty,
  17507. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17508. PsnName: res.Output.Baseinfo.PsnName,
  17509. Idetinfo: idetinfoStr,
  17510. Insuinfo: infoStr,
  17511. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17512. CardInfo: card_info,
  17513. VerifyNumber: token,
  17514. }
  17515. var rf []*ResultFive
  17516. json.Unmarshal([]byte(infoStr), &rf)
  17517. var insutypes []*ResultFive
  17518. var insutype string
  17519. var is390 int = 0
  17520. var is310 int = 0
  17521. for _, item := range rf {
  17522. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17523. insutypes = append(insutypes, item)
  17524. }
  17525. }
  17526. if len(insutypes) == 1 {
  17527. insutype = insutypes[0].Insutype
  17528. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17529. } else {
  17530. for _, i := range insutypes {
  17531. if i.Insutype == "390" {
  17532. is390 = 1
  17533. }
  17534. if i.Insutype == "310" {
  17535. is310 = 1
  17536. }
  17537. }
  17538. }
  17539. if is390 == 1 {
  17540. insutype = "390"
  17541. }
  17542. if is310 == 1 {
  17543. insutype = "310"
  17544. }
  17545. if len(insutypes) == 0 {
  17546. insutype = "310"
  17547. }
  17548. service.CreateHisPsn(psn)
  17549. c.ServeSuccessJSON(map[string]interface{}{
  17550. "patient": patient,
  17551. "number": token,
  17552. "insutype": insutype,
  17553. })
  17554. }
  17555. } else {
  17556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17557. return
  17558. }
  17559. } else { //读卡失败
  17560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17561. return
  17562. }
  17563. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17564. res := c.GetoleInfo()
  17565. if res.Infcode == 0 {
  17566. var result string
  17567. if res.Output.MdtrtCertType == "01" {
  17568. 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)
  17569. } else if res.Output.MdtrtCertType == "02" {
  17570. 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)
  17571. } else if res.Output.MdtrtCertType == "03" {
  17572. 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)
  17573. }
  17574. var dat map[string]interface{}
  17575. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17576. fmt.Println(dat)
  17577. } else {
  17578. fmt.Println(err)
  17579. }
  17580. userJSONBytes, _ := json.Marshal(dat)
  17581. var res2 ResultTwo
  17582. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17583. utils.ErrorLog("解析失败:%v", err)
  17584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17585. return
  17586. }
  17587. if res2.Infcode == 0 {
  17588. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  17589. if err == gorm.ErrRecordNotFound {
  17590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17591. return
  17592. } else if err != nil {
  17593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17594. return
  17595. } else {
  17596. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  17597. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  17598. infoStr := string(Iinfos)
  17599. idetinfoStr := string(Idetinfos)
  17600. var rf []*ResultFive
  17601. json.Unmarshal([]byte(infoStr), &rf)
  17602. var insutypes []*ResultFive
  17603. var insutype string
  17604. var is390 int = 0
  17605. var is310 int = 0
  17606. //var insuplc_admdvs string
  17607. for _, item := range rf {
  17608. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17609. insutypes = append(insutypes, item)
  17610. }
  17611. }
  17612. if len(insutypes) == 1 {
  17613. insutype = insutypes[0].Insutype
  17614. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17615. } else {
  17616. for _, i := range insutypes {
  17617. if i.Insutype == "390" {
  17618. is390 = 1
  17619. }
  17620. if i.Insutype == "310" {
  17621. is310 = 1
  17622. }
  17623. }
  17624. }
  17625. if is390 == 1 {
  17626. insutype = "390"
  17627. }
  17628. if is310 == 1 {
  17629. insutype = "310"
  17630. }
  17631. if len(insutypes) == 0 {
  17632. insutype = "310"
  17633. }
  17634. psn := &models.HisPsn{
  17635. PsnNo: res2.Output.Baseinfo.PsnNo,
  17636. PatientId: patient.ID,
  17637. Certno: res2.Output.Baseinfo.Certno,
  17638. Gend: res2.Output.Baseinfo.Gend,
  17639. Naty: res2.Output.Baseinfo.Naty,
  17640. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  17641. PsnName: res2.Output.Baseinfo.PsnName,
  17642. Idetinfo: idetinfoStr,
  17643. Insuinfo: infoStr,
  17644. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17645. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  17646. VerifyNumber: res.Output.EcToken,
  17647. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  17648. }
  17649. if res.Output.MdtrtCertType == "01" {
  17650. psn.VerifyNumber = res.Output.EcToken
  17651. //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)
  17652. } else if res.Output.MdtrtCertType == "02" {
  17653. psn.VerifyNumber = res.Output.CardNo
  17654. //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)
  17655. } else if res.Output.MdtrtCertType == "03" {
  17656. psn.VerifyNumber = res.Output.MdtrtCertNo
  17657. //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)
  17658. }
  17659. service.CreateHisPsn(psn)
  17660. var balc float64
  17661. for _, item := range rf {
  17662. if item.Insutype == insutype {
  17663. balc = item.Balc
  17664. }
  17665. }
  17666. c.ServeSuccessJSON(map[string]interface{}{
  17667. "patient": patient,
  17668. "number": res.Output.CardNo,
  17669. "insutype": insutype,
  17670. "blac": balc,
  17671. "desc": idetinfoStr,
  17672. })
  17673. }
  17674. } else {
  17675. c.ServeSuccessJSON(map[string]interface{}{
  17676. "failed_code": -10,
  17677. "msg": res2.ErrMsg,
  17678. })
  17679. }
  17680. } else {
  17681. c.ServeSuccessJSON(map[string]interface{}{
  17682. "failed_code": -10,
  17683. "msg": res.ErrMsg,
  17684. })
  17685. }
  17686. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17687. var res ResultTwo
  17688. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  17689. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17690. "&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)
  17691. resp, requestErr := http.Get(api)
  17692. if requestErr != nil {
  17693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17694. return
  17695. }
  17696. body, ioErr := ioutil.ReadAll(resp.Body)
  17697. if ioErr != nil {
  17698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17700. return
  17701. }
  17702. var respJSON map[string]interface{}
  17703. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17706. return
  17707. }
  17708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17709. result, _ := json.Marshal(respJSON)
  17710. fmt.Println("log")
  17711. fmt.Println(string(result))
  17712. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17713. utils.ErrorLog("解析失败:%v", err)
  17714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17715. return
  17716. }
  17717. if res.Infcode == 0 {
  17718. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17719. if err == gorm.ErrRecordNotFound {
  17720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17721. return
  17722. } else if err != nil {
  17723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17724. return
  17725. } else {
  17726. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17727. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17728. infoStr := string(Iinfos)
  17729. idetinfoStr := string(Idetinfos)
  17730. var rf []*ResultFive
  17731. json.Unmarshal([]byte(infoStr), &rf)
  17732. var insutypes []*ResultFive
  17733. var insutype string
  17734. var is390 int = 0
  17735. var is310 int = 0
  17736. for _, item := range rf {
  17737. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17738. insutypes = append(insutypes, item)
  17739. }
  17740. }
  17741. if len(insutypes) == 1 {
  17742. insutype = insutypes[0].Insutype
  17743. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17744. } else {
  17745. for _, i := range insutypes {
  17746. if i.Insutype == "390" {
  17747. is390 = 1
  17748. }
  17749. if i.Insutype == "310" {
  17750. is310 = 1
  17751. }
  17752. }
  17753. }
  17754. if is390 == 1 {
  17755. insutype = "390"
  17756. }
  17757. if is310 == 1 {
  17758. insutype = "310"
  17759. }
  17760. if len(insutypes) == 0 {
  17761. insutype = "390"
  17762. }
  17763. var insuplc_admdvs string
  17764. for _, item := range rf {
  17765. if item.Insutype == insutype {
  17766. insuplc_admdvs = item.InsuplcAdmdvs
  17767. }
  17768. }
  17769. psn := &models.HisPsn{
  17770. PsnNo: res.Output.Baseinfo.PsnNo,
  17771. PatientId: patient.ID,
  17772. Certno: res.Output.Baseinfo.Certno,
  17773. Gend: res.Output.Baseinfo.Gend,
  17774. Naty: res.Output.Baseinfo.Naty,
  17775. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17776. PsnName: res.Output.Baseinfo.PsnName,
  17777. Idetinfo: idetinfoStr,
  17778. Insuinfo: infoStr,
  17779. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17780. InsuplcAdmdvs: insuplc_admdvs,
  17781. }
  17782. service.CreateHisPsn(psn)
  17783. c.ServeSuccessJSON(map[string]interface{}{
  17784. "patient": patient,
  17785. "number": res.Output.Baseinfo.Certno,
  17786. })
  17787. }
  17788. } else {
  17789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17790. return
  17791. }
  17792. } else {
  17793. type ELeData struct {
  17794. Code string `json:"code"`
  17795. Data struct {
  17796. Aac002 string `json:"aac002"`
  17797. Aaz500 string `json:"aaz500"`
  17798. ActCardNo string `json:"actCardNo"`
  17799. Bab520 string `json:"bab520"`
  17800. Bkz543 string `json:"bkz543"`
  17801. BusinessType string `json:"businessType"`
  17802. CertfCodg string `json:"certfCodg"`
  17803. EcIndexNo string `json:"ecIndexNo"`
  17804. EcToken string `json:"ecToken"`
  17805. ID0000 string `json:"id0000"`
  17806. IDNo string `json:"idNo"`
  17807. IDType string `json:"idType"`
  17808. Idcode string `json:"idcode"`
  17809. IdentityToken string `json:"identity_token"`
  17810. InsuOrg string `json:"insuOrg"`
  17811. OfficeID string `json:"officeId"`
  17812. OfficeName string `json:"officeName"`
  17813. OperatorID string `json:"operatorId"`
  17814. OperatorName string `json:"operatorName"`
  17815. OrgID string `json:"orgId"`
  17816. UserName string `json:"userName"`
  17817. } `json:"data"`
  17818. Infno interface{} `json:"infno"`
  17819. Message string `json:"message"`
  17820. OrgID string `json:"orgId"`
  17821. TransType string `json:"transType"`
  17822. }
  17823. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17824. fmt.Println(result)
  17825. outPutInfo := Remove0000(result)
  17826. fmt.Println(outPutInfo)
  17827. if len(outPutInfo) > 0 {
  17828. var ele ELeData
  17829. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17830. if err != nil {
  17831. utils.ErrorLog("解析失败:%v", err)
  17832. }
  17833. token := ele.Data.EcToken
  17834. fmt.Println(outPutInfo)
  17835. 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)
  17836. saveLog(result, requestLog, "1101", "获取人员信息")
  17837. var dat map[string]interface{}
  17838. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17839. fmt.Println(dat)
  17840. } else {
  17841. fmt.Println(err)
  17842. }
  17843. userJSONBytes, _ := json.Marshal(dat)
  17844. var res ResultTwo
  17845. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17846. utils.ErrorLog("解析失败:%v", err)
  17847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17848. return
  17849. }
  17850. if res.Infcode == 0 {
  17851. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17852. if err == gorm.ErrRecordNotFound {
  17853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17854. return
  17855. } else if err != nil {
  17856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17857. return
  17858. } else {
  17859. fmt.Println(res)
  17860. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17861. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17862. infoStr := string(Iinfos)
  17863. idetinfoStr := string(Idetinfos)
  17864. psn := &models.HisPsn{
  17865. PsnNo: res.Output.Baseinfo.PsnNo,
  17866. PatientId: patient.ID,
  17867. Certno: res.Output.Baseinfo.Certno,
  17868. Gend: res.Output.Baseinfo.Gend,
  17869. Naty: res.Output.Baseinfo.Naty,
  17870. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17871. PsnName: res.Output.Baseinfo.PsnName,
  17872. Idetinfo: idetinfoStr,
  17873. Insuinfo: infoStr,
  17874. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17875. CardInfo: outPutInfo,
  17876. VerifyNumber: token,
  17877. InsuplcAdmdvs: ele.Data.InsuOrg,
  17878. }
  17879. service.CreateHisPsn(psn)
  17880. var rf []*ResultFive
  17881. json.Unmarshal([]byte(infoStr), &rf)
  17882. var insutypes []*ResultFive
  17883. var insutype string
  17884. var is390 int = 0
  17885. var is310 int = 0
  17886. for _, item := range rf {
  17887. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17888. insutypes = append(insutypes, item)
  17889. }
  17890. }
  17891. if len(insutypes) == 1 {
  17892. insutype = insutypes[0].Insutype
  17893. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17894. } else {
  17895. for _, i := range insutypes {
  17896. if i.Insutype == "390" {
  17897. is390 = 1
  17898. }
  17899. if i.Insutype == "310" {
  17900. is310 = 1
  17901. }
  17902. }
  17903. }
  17904. if is390 == 1 {
  17905. insutype = "390"
  17906. }
  17907. if is310 == 1 {
  17908. insutype = "310"
  17909. }
  17910. if len(insutypes) == 0 {
  17911. insutype = "310"
  17912. }
  17913. c.ServeSuccessJSON(map[string]interface{}{
  17914. "patient": patient,
  17915. "number": token,
  17916. "insutype": insutype,
  17917. })
  17918. }
  17919. } else {
  17920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17921. return
  17922. }
  17923. }
  17924. //fmt.Println(result)
  17925. //
  17926. //if initFlag == 0 {
  17927. // c.TestGetBasBaseInit()
  17928. //}
  17929. //token := c.GetEleBaseInfo()
  17930. //
  17931. //token = Remove0000(token)
  17932. //
  17933. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17934. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17935. ////
  17936. //var res ResultTwo
  17937. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17938. // utils.ErrorLog("解析失败:%v", err)
  17939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17940. // return
  17941. //}
  17942. //
  17943. //if res.Infcode == 0 {
  17944. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17945. // if err == gorm.ErrRecordNotFound {
  17946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17947. // return
  17948. // } else if err != nil {
  17949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17950. // return
  17951. //
  17952. // } else {
  17953. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17954. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17955. // infoStr := string(Iinfos)
  17956. // idetinfoStr := string(Idetinfos)
  17957. //
  17958. //
  17959. //
  17960. //
  17961. // var rf []*ResultFive
  17962. // json.Unmarshal([]byte(infoStr), &rf)
  17963. //
  17964. // var insutypes []*ResultFive
  17965. // var insutype string
  17966. // var is390 int = 0
  17967. // var is310 int = 0
  17968. // var insuplc_admdvs string
  17969. //
  17970. // for _, item := range rf {
  17971. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17972. // insutypes = append(insutypes, item)
  17973. // }
  17974. // }
  17975. //
  17976. // if len(insutypes) == 1 {
  17977. // insutype = insutypes[0].Insutype
  17978. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17979. // } else {
  17980. // for _, i := range insutypes {
  17981. // if i.Insutype == "390" {
  17982. // is390 = 1
  17983. // }
  17984. //
  17985. // if i.Insutype == "310" {
  17986. // is310 = 1
  17987. // }
  17988. // }
  17989. // }
  17990. // if is390 == 1 {
  17991. // insutype = "390"
  17992. // }
  17993. //
  17994. // if is310 == 1 {
  17995. // insutype = "310"
  17996. // }
  17997. // if len(insutypes) == 0 {
  17998. // insutype = "310"
  17999. // }
  18000. // for _, item := range rf {
  18001. // if item.Insutype == insutype {
  18002. // insuplc_admdvs = item.InsuplcAdmdvs
  18003. // }
  18004. // }
  18005. // psn := &models.HisPsn{
  18006. // PsnNo: res.Output.Baseinfo.PsnNo,
  18007. // Age: res.Output.Baseinfo.Age,
  18008. // PatientId: patient.ID,
  18009. // Certno: res.Output.Baseinfo.Certno,
  18010. // Brdy: res.Output.Baseinfo.Brdy,
  18011. // Gend: res.Output.Baseinfo.Gend,
  18012. // Naty: res.Output.Baseinfo.Naty,
  18013. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  18014. // PsnName: res.Output.Baseinfo.PsnName,
  18015. // Idetinfo: idetinfoStr,
  18016. // Insuinfo: infoStr,
  18017. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18018. // CardInfo: "",
  18019. // VerifyNumber: token,
  18020. // InsuplcAdmdvs: insuplc_admdvs,
  18021. // }
  18022. // service.CreateHisPsn(psn)
  18023. //
  18024. // c.ServeSuccessJSON(map[string]interface{}{
  18025. // "patient": patient,
  18026. // "number": token,
  18027. // })
  18028. // }
  18029. //} else {
  18030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18031. // return
  18032. //}
  18033. }
  18034. break
  18035. case 5:
  18036. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  18037. var api string
  18038. if miConfig.MdtrtareaAdmvs == "320830" {
  18039. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  18040. "&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
  18041. fmt.Println(api)
  18042. } else if miConfig.MdtrtareaAdmvs == "320921" {
  18043. 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 +
  18044. "&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
  18045. fmt.Println(api)
  18046. } else {
  18047. 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 +
  18048. "&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)
  18049. }
  18050. resp, requestErr := http.Get(api)
  18051. if requestErr != nil {
  18052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18053. return
  18054. }
  18055. body, ioErr := ioutil.ReadAll(resp.Body)
  18056. if ioErr != nil {
  18057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18059. return
  18060. }
  18061. var respJSON map[string]interface{}
  18062. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18065. return
  18066. }
  18067. var status string
  18068. status = respJSON["data"].(map[string]interface{})["status"].(string)
  18069. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  18070. var token string
  18071. var res ResultTwo //1101结果
  18072. var res10265 ResultTwo10265 //1101结果
  18073. if status == "0" { //读卡成功
  18074. var card_info string //卡信息
  18075. //var busi_card_info string
  18076. var auth_info string
  18077. token = respJSON["data"].(map[string]interface{})["token"].(string)
  18078. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  18079. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  18080. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  18081. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  18082. result, _ := json.Marshal(respJSON)
  18083. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  18084. utils.ErrorLog("解析失败:%v", err)
  18085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18086. return
  18087. }
  18088. res.ErrMsg = res10265.ErrMsg
  18089. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  18090. res.Infcode = infocode
  18091. res.Output = res10265.Output
  18092. res.InfRefmsgid = res10265.InfRefmsgid
  18093. if res.Infcode == 0 {
  18094. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  18095. if err == gorm.ErrRecordNotFound {
  18096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18097. return
  18098. } else if err != nil {
  18099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18100. return
  18101. } else {
  18102. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18103. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18104. infoStr := string(Iinfos)
  18105. idetinfoStr := string(Idetinfos)
  18106. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  18107. psn := &models.HisPsn{
  18108. PsnNo: res.Output.Baseinfo.PsnNo,
  18109. PatientId: patient.ID,
  18110. Certno: res.Output.Baseinfo.Certno,
  18111. Gend: res.Output.Baseinfo.Gend,
  18112. Brdy: b,
  18113. Age: float64(age),
  18114. Naty: res.Output.Baseinfo.Naty,
  18115. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18116. PsnName: res.Output.Baseinfo.PsnName,
  18117. Idetinfo: idetinfoStr,
  18118. Insuinfo: infoStr,
  18119. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18120. CardInfo: card_info,
  18121. VerifyNumber: token,
  18122. AuthInfo: auth_info,
  18123. }
  18124. var rf []*ResultFive
  18125. json.Unmarshal([]byte(infoStr), &rf)
  18126. var insutypes []*ResultFive
  18127. var insutype string
  18128. var is390 int = 0
  18129. var is310 int = 0
  18130. for _, item := range rf {
  18131. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18132. insutypes = append(insutypes, item)
  18133. }
  18134. }
  18135. if len(insutypes) == 1 {
  18136. insutype = insutypes[0].Insutype
  18137. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18138. } else {
  18139. for _, i := range insutypes {
  18140. if i.Insutype == "390" {
  18141. is390 = 1
  18142. }
  18143. if i.Insutype == "310" {
  18144. is310 = 1
  18145. }
  18146. }
  18147. }
  18148. if is390 == 1 {
  18149. insutype = "390"
  18150. }
  18151. if is310 == 1 {
  18152. insutype = "310"
  18153. }
  18154. if len(insutypes) == 0 {
  18155. insutype = "310"
  18156. }
  18157. service.CreateHisPsn(psn)
  18158. c.ServeSuccessJSON(map[string]interface{}{
  18159. "patient": patient,
  18160. "number": token,
  18161. "insutype": insutype,
  18162. })
  18163. }
  18164. } else {
  18165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18166. return
  18167. }
  18168. } else { //读卡失败
  18169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18170. return
  18171. }
  18172. }
  18173. break
  18174. }
  18175. }
  18176. var initFlag int64 = 0
  18177. var initEleFlag int64 = 0
  18178. func (c *HisApiController) TestGetBasBaseInit() {
  18179. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18180. Iinit := DllDef.MustFindProc("Init")
  18181. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18182. url := ""
  18183. if miConfig.InsuplcAdmdvs[:4] == "4403" {
  18184. url = "http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"
  18185. } else if miConfig.InsuplcAdmdvs[:4] == "4401" {
  18186. url = ""
  18187. } else {
  18188. url = "http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"
  18189. }
  18190. fmt.Println("SSCard的报错原因:", url)
  18191. fmt.Println("SSCard的报错原因:", miConfig.InsuplcAdmdvs)
  18192. ret, _, err := Iinit.Call(StrPtr(url), StrPtr(miConfig.InsuplcAdmdvs))
  18193. if ret != 0 {
  18194. fmt.Println("SSCard的报错原因:", err)
  18195. fmt.Println("SSCard的运算结果为:", ret)
  18196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18197. return
  18198. }
  18199. result := int(ret)
  18200. fmt.Println("SSCard的运算结果为1:", result)
  18201. initFlag = 1
  18202. return
  18203. }
  18204. func (c *HisApiController) HandleJiangXiReadCard() {
  18205. fmt.Println("~~~~~~")
  18206. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18207. admin_user_id, _ := c.GetInt64("admin_user_id")
  18208. id_card_type, _ := c.GetInt64("id_card_type")
  18209. //certificates, _ := c.GetInt64("certificates")
  18210. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18211. if initFlag == 0 {
  18212. c.TestGetJiangXiBasBaseInit()
  18213. }
  18214. basStr := c.GetBasBaseInfo()
  18215. if len(basStr) == 0 {
  18216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18217. return
  18218. }
  18219. fmt.Println(basStr)
  18220. bas := strings.Split(basStr, "|")
  18221. basNumber := bas[1]
  18222. fmt.Println(basNumber)
  18223. card_sn := bas[3]
  18224. fmt.Println(card_sn)
  18225. 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, "")
  18226. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  18227. var dat map[string]interface{}
  18228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18229. fmt.Println(dat)
  18230. } else {
  18231. fmt.Println(err)
  18232. }
  18233. userJSONBytes, _ := json.Marshal(dat)
  18234. var res ResultTwo
  18235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18236. utils.ErrorLog("解析失败:%v", err)
  18237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18238. return
  18239. }
  18240. if res.Infcode == 0 {
  18241. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  18242. if err == gorm.ErrRecordNotFound {
  18243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18244. return
  18245. } else if err != nil {
  18246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18247. return
  18248. } else {
  18249. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18250. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18251. infoStr := string(Iinfos)
  18252. idetinfoStr := string(Idetinfos)
  18253. psn := &models.HisPsn{
  18254. PsnNo: res.Output.Baseinfo.PsnNo,
  18255. PatientId: patient.ID,
  18256. Certno: res.Output.Baseinfo.Certno,
  18257. Gend: res.Output.Baseinfo.Gend,
  18258. Naty: res.Output.Baseinfo.Naty,
  18259. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18260. PsnName: res.Output.Baseinfo.PsnName,
  18261. Idetinfo: idetinfoStr,
  18262. Insuinfo: infoStr,
  18263. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18264. CardInfo: basStr,
  18265. VerifyNumber: "",
  18266. }
  18267. service.CreateHisPsn(psn)
  18268. c.ServeSuccessJSON(map[string]interface{}{
  18269. "patient": patient,
  18270. "number": basNumber,
  18271. })
  18272. }
  18273. } else {
  18274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18275. return
  18276. }
  18277. }
  18278. func (c *HisApiController) TestGetHnBasBaseInit() {
  18279. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18280. Iinit := DllDef.MustFindProc("Init")
  18281. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18282. //http://10.77.211.236/CSB/hsa-fsi-1303
  18283. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  18284. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  18285. // 调用 Init 函数
  18286. ret, _, err := Iinit.Call(uintptr(unsafe.Pointer(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"))), uintptr(unsafe.Pointer(StrPtr("430800|scr.hun.hsip.gov.cn"))))
  18287. //if ret != 0 {
  18288. fmt.Println("SSCard的报错原因:", err)
  18289. fmt.Println("SSCard的运算结果为:", ret)
  18290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18291. // return
  18292. //}
  18293. result := int(ret)
  18294. fmt.Println("SSCard的运算结果为1:", result)
  18295. initFlag = 1
  18296. return
  18297. }
  18298. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  18299. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18300. Iinit := DllDef.MustFindProc("Init")
  18301. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18302. //http://10.77.211.236/CSB/hsa-fsi-1303
  18303. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  18304. if ret != 0 {
  18305. fmt.Println("SSCard的报错原因:", err)
  18306. fmt.Println("SSCard的运算结果为:", ret)
  18307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18308. return
  18309. }
  18310. result := int(ret)
  18311. fmt.Println("SSCard的运算结果为1:", result)
  18312. initFlag = 1
  18313. return
  18314. }
  18315. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  18316. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18317. Iinit := DllDef.MustFindProc("Init")
  18318. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18319. //http://10.77.211.236/CSB/hsa-fsi-1303
  18320. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  18321. if ret != 0 {
  18322. fmt.Println("SSCard的报错原因:", err)
  18323. fmt.Println("SSCard的运算结果为:", ret)
  18324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18325. return
  18326. }
  18327. result := int(ret)
  18328. fmt.Println("SSCard的运算结果为1:", result)
  18329. initFlag = 1
  18330. return
  18331. }
  18332. func (c *HisApiController) GetSFZBaseInfo() string {
  18333. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18334. readCard := DllDef.MustFindProc("ReadSFZ")
  18335. if readCard == nil {
  18336. fmt.Println("readcard is nil")
  18337. readCard = DllDef.MustFindProc("ReadSFZ")
  18338. }
  18339. str := make([]byte, 8096)
  18340. str1 := make([]byte, 8096)
  18341. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  18342. fmt.Println(r)
  18343. return Remove0000(string(str))
  18344. }
  18345. func (c *HisApiController) GetEleBaseInfo() string {
  18346. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18347. readCard := DllDef.MustFindProc("GetQRBase")
  18348. fmt.Println(readCard)
  18349. if readCard == nil {
  18350. fmt.Println("readcard is nil")
  18351. readCard = DllDef.MustFindProc("GetQRBase")
  18352. }
  18353. str := make([]byte, 1024)
  18354. str1 := make([]byte, 1024)
  18355. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18356. fmt.Println(ret2)
  18357. fmt.Println(string(str1))
  18358. fmt.Println(string(str))
  18359. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18360. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18361. if ret2 != 0 {
  18362. return ""
  18363. }
  18364. return string(str)
  18365. }
  18366. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18367. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18368. readCard := DllDef.MustFindProc("NationEcTrans")
  18369. fmt.Println(readCard)
  18370. fmt.Println("!!!!!")
  18371. pBusiCardInfo := make([]byte, 2048)
  18372. input := make(map[string]interface{})
  18373. inputData := make(map[string]interface{})
  18374. inputData["orgId"] = code
  18375. inputData["businessType"] = "01101"
  18376. inputData["operatorId"] = "1"
  18377. inputData["operatorName"] = "admin"
  18378. inputData["officeId"] = "001"
  18379. inputData["officeName"] = "血透室"
  18380. inputData["deviceType"] = ""
  18381. input["data"] = inputData
  18382. input["orgId"] = code
  18383. input["transType"] = "ec.query"
  18384. bytesData, _ := json.Marshal(input)
  18385. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18386. fmt.Println(ret2)
  18387. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18388. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18389. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  18390. }
  18391. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18392. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18393. readCard := DllDef.MustFindProc("NationEcTrans")
  18394. fmt.Println(readCard)
  18395. fmt.Println("!!!!!")
  18396. pBusiCardInfo := make([]byte, 2048)
  18397. input := make(map[string]interface{})
  18398. inputData := make(map[string]interface{})
  18399. inputData["orgId"] = code
  18400. inputData["businessType"] = "01101"
  18401. inputData["operatorId"] = "9"
  18402. inputData["operatorName"] = "admin"
  18403. inputData["officeId"] = "001"
  18404. inputData["officeName"] = "血透室"
  18405. inputData["deviceType"] = ""
  18406. input["data"] = inputData
  18407. input["orgId"] = code
  18408. input["transType"] = "ec.query"
  18409. bytesData, _ := json.Marshal(input)
  18410. 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])))
  18411. fmt.Println(ret2)
  18412. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18413. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18414. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18415. }
  18416. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  18417. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18418. readCard := DllDef.MustFindProc("NationEcTrans")
  18419. fmt.Println(readCard)
  18420. fmt.Println("!!!!!")
  18421. pBusiCardInfo := make([]byte, 2048)
  18422. input := make(map[string]interface{})
  18423. inputData := make(map[string]interface{})
  18424. inputData["orgId"] = code
  18425. inputData["businessType"] = "01301"
  18426. inputData["operatorId"] = "9"
  18427. inputData["operatorName"] = "admin"
  18428. inputData["officeId"] = "001"
  18429. inputData["officeName"] = "血透室"
  18430. inputData["deviceType"] = ""
  18431. input["data"] = inputData
  18432. input["orgId"] = code
  18433. input["transType"] = "ec.query"
  18434. bytesData, _ := json.Marshal(input)
  18435. 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])))
  18436. fmt.Println(ret2)
  18437. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18438. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18439. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18440. }
  18441. func GetJxEleBaseInfo(org_id int64) string {
  18442. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18443. readCard := DllDef.MustFindProc("NationEcTrans")
  18444. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18445. if readCard == nil {
  18446. fmt.Println("readcard is nil")
  18447. readCard = DllDef.MustFindProc("NationEcTrans")
  18448. }
  18449. str1 := make([]byte, 1024)
  18450. data := make(map[string]interface{})
  18451. inputData := make(map[string]interface{})
  18452. inputData["orgId"] = miConfig.Code
  18453. inputData["businessType"] = "01101"
  18454. inputData["operatorId"] = "test001"
  18455. inputData["operatorName"] = "cn"
  18456. inputData["officeId"] = "32760"
  18457. inputData["officeName"] = "waike"
  18458. inputData["deviceType"] = ""
  18459. data["data"] = inputData
  18460. data["transType"] = "ec.query"
  18461. data["extra "] = ""
  18462. data["orgId"] = miConfig.Code
  18463. bytesData, _ := json.Marshal(data)
  18464. //bytesData, _ := json.Marshal(data)
  18465. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18466. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18467. fmt.Println(ret2)
  18468. fmt.Println(string(str1))
  18469. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18470. if ret2 != 0 {
  18471. return ""
  18472. }
  18473. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18474. }
  18475. //func GetJxEleBaseInfoTWO(org_id int64) string {
  18476. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  18477. // readCard := DllDef.MustFindProc("NationEcTrans")
  18478. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18479. //
  18480. // if readCard == nil {
  18481. // fmt.Println("readcard is nil")
  18482. // readCard = DllDef.MustFindProc("NationEcTrans")
  18483. // }
  18484. // str1 := make([]byte, 1024)
  18485. //
  18486. // data := make(map[string]interface{})
  18487. //
  18488. // inputData := make(map[string]interface{})
  18489. // inputData["orgId"] = miConfig.Code
  18490. // inputData["businessType"] = "01101"
  18491. // inputData["operatorId"] = "test001"
  18492. // inputData["operatorName"] = "cn"
  18493. // inputData["officeId"] = "32760"
  18494. // inputData["officeName"] = "waike"
  18495. // inputData["deviceType"] = ""
  18496. //
  18497. // data["data"] = inputData
  18498. // data["transType"] = "ec.query"
  18499. // data["extra "] = ""
  18500. // data["orgId"] = miConfig.Code
  18501. // bytesData, _ := json.Marshal(data)
  18502. // //bytesData, _ := json.Marshal(data)
  18503. //
  18504. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18505. //
  18506. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18507. // fmt.Println(ret2)
  18508. // fmt.Println(string(str1))
  18509. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18510. //
  18511. // if ret2 != 0 {
  18512. // return ""
  18513. // }
  18514. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18515. //}
  18516. func GetJxEleBaseInitInfo(org_id int64) string {
  18517. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18518. readCard := DllDef.MustFindProc("NationEcTrans")
  18519. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18520. if readCard == nil {
  18521. fmt.Println("readcard is nil")
  18522. readCard = DllDef.MustFindProc("NationEcTrans")
  18523. }
  18524. str1 := make([]byte, 2048)
  18525. data := make(map[string]interface{})
  18526. inputData := make(map[string]interface{})
  18527. inputData["orgId"] = miConfig.Code
  18528. inputData["businessType"] = "01101"
  18529. inputData["operatorId"] = "1"
  18530. inputData["operatorName"] = "huangchuang"
  18531. inputData["officeId"] = "101"
  18532. inputData["officeName"] = "xuetou"
  18533. inputData["deviceType"] = ""
  18534. data["data"] = inputData
  18535. data["transType"] = "ec.query"
  18536. data["orgId"] = miConfig.Code
  18537. bytesData, _ := json.Marshal(data)
  18538. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18539. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18540. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  18541. fmt.Println(ret2)
  18542. fmt.Println(string(str1))
  18543. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18544. if ret2 != 0 {
  18545. return ""
  18546. }
  18547. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  18548. initEleFlag = 1
  18549. }
  18550. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18551. }
  18552. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  18553. // // 构建命令
  18554. // cmd := exec.Command("python", "b.py")
  18555. //
  18556. // // 执行命令并等待完成
  18557. // output, err := cmd.CombinedOutput()
  18558. // if err != nil {
  18559. // fmt.Println("Error executing Python script:", err)
  18560. // return
  18561. // }
  18562. //
  18563. // // 打印Python脚本的输出
  18564. // fmt.Println(string(output))
  18565. //}
  18566. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  18567. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  18568. readCard := DllDef.MustFindProc("gxyb_call")
  18569. if readCard == nil {
  18570. fmt.Println("readcard is nil")
  18571. readCard = DllDef.MustFindProc("gxyb_call")
  18572. }
  18573. str := make([]byte, 1024)
  18574. str1 := make([]byte, 1024)
  18575. //data := make(map[string]interface{})
  18576. currentTime := time.Now()
  18577. // 格式化时间为 "YYYYMMDDHH24MISS"
  18578. formattedTime := currentTime.Format("20060102150405")
  18579. inputData := make(map[string]interface{})
  18580. inputData2 := make(map[string]interface{})
  18581. inputData["transNo"] = "1401"
  18582. inputData["transType"] = "passwordCheck"
  18583. inputData["timestamp"] = formattedTime
  18584. inputData2["fixmedinsCode"] = code
  18585. inputData2["psnNo"] = ""
  18586. inputData["data"] = inputData2
  18587. jsonBytes, err := json.Marshal(inputData)
  18588. if err != nil {
  18589. fmt.Println("Error encoding map to JSON:", err)
  18590. }
  18591. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18592. fmt.Println(string(str1))
  18593. fmt.Println(string(str))
  18594. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18595. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18596. if ret2 != 0 {
  18597. return ""
  18598. }
  18599. return string(str)
  18600. }
  18601. func (c *HisApiController) GetoleInfo() Response {
  18602. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  18603. defer ole.CoUninitialize()
  18604. // Replace with the ProgID or CLSID of your COM object
  18605. progID := "YinHai.XJ.Actual.Interface.New"
  18606. // Create COM object
  18607. unknown, err := oleutil.CreateObject(progID)
  18608. if err != nil {
  18609. fmt.Println("Unable to create COM object:", err)
  18610. }
  18611. defer unknown.Release()
  18612. // Query for the IDispatch interface
  18613. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  18614. if err != nil {
  18615. fmt.Println("Unable to get IDispatch interface:", err)
  18616. }
  18617. defer dispatch.Release()
  18618. // Prepare parameters
  18619. transNo := "1401"
  18620. transType := "passwordCheck"
  18621. timestamp := time.Now().Unix()
  18622. fixmedinsCode := "H45072101171"
  18623. psnNo := ""
  18624. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  18625. result2 := ""
  18626. // Call COM object's method using the IDispatch interface
  18627. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  18628. fmt.Println(resulr)
  18629. fmt.Println(result2)
  18630. if err != nil {
  18631. fmt.Println("调用COM对象方法失败:", err)
  18632. }
  18633. var response Response
  18634. err2 := json.Unmarshal([]byte(result2), &response)
  18635. if err2 != nil {
  18636. fmt.Println("解析JSON失败:", err)
  18637. }
  18638. return response
  18639. }
  18640. func (c *HisApiController) GetBasBaseInfo() string {
  18641. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18642. readCard := DllDef.MustFindProc("ReadCardBas")
  18643. if readCard == nil {
  18644. fmt.Println("readcard is nil")
  18645. readCard = DllDef.MustFindProc("ReadCardBas")
  18646. }
  18647. str := make([]byte, 1024)
  18648. str1 := make([]byte, 1024)
  18649. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18650. fmt.Println(string(str1))
  18651. fmt.Println(string(str))
  18652. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18653. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18654. if ret2 != 0 {
  18655. return ""
  18656. }
  18657. return string(str)
  18658. }
  18659. type Program struct {
  18660. FunctionID string `xml:"function_id"`
  18661. CardInfo string `xml:"cardinfo"`
  18662. User string `xml:"user"`
  18663. }
  18664. func (c *HisApiController) GetBasBaseInfo1111() string {
  18665. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  18666. readCard := DllDef.MustFindProc("ReadSICardInfo")
  18667. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  18668. if readCard == nil {
  18669. fmt.Println("readcard is nil")
  18670. readCard = DllDef.MustFindProc("ReadSICardInfo")
  18671. }
  18672. if readCard2 == nil {
  18673. fmt.Println("readcard is nil")
  18674. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  18675. }
  18676. str := make([]byte, 1024)
  18677. str1 := make([]byte, 1024)
  18678. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18679. str3 := make([]byte, 1024)
  18680. str4 := make([]byte, 1024)
  18681. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  18682. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18683. //if err != nil {
  18684. // fmt.Println("Error opening file:", err)
  18685. //}
  18686. //defer file.Close()
  18687. //
  18688. //var lastProgram Program
  18689. //scanner := bufio.NewScanner(file)
  18690. //inProgram := false
  18691. //
  18692. //for scanner.Scan() {
  18693. // line := scanner.Text()
  18694. // if strings.Contains(line, "<program>") {
  18695. // inProgram = true
  18696. // programXML := "<program>"
  18697. // for scanner.Scan() {
  18698. // line = scanner.Text()
  18699. // programXML += line
  18700. // if strings.Contains(line, "</program>") {
  18701. // programXML += "</program>"
  18702. // break
  18703. // }
  18704. // }
  18705. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18706. // // 解析成功,更新最后的 Program
  18707. // }
  18708. // inProgram = false
  18709. // }
  18710. //}
  18711. //
  18712. // fmt.Println("Error reading file:", inProgram)
  18713. //
  18714. //if err := scanner.Err(); err != nil {
  18715. // fmt.Println("Error reading file:", err)
  18716. //}
  18717. // 输出最后一次的 Program
  18718. //fmt.Printf("最后一次的 <program>:\n")
  18719. //fmt.Printf("<program>\n")
  18720. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18721. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18722. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18723. //fmt.Printf("</program>\n")
  18724. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18725. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18726. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18727. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18728. return ConvertToString(string(str), "gbk", "utf-8")
  18729. }
  18730. func (c *HisApiController) GetBasBaseInfo22222() string {
  18731. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18732. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18733. if readCard == nil {
  18734. fmt.Println("readcard is nil")
  18735. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18736. }
  18737. str := make([]byte, 1024)
  18738. str1 := make([]byte, 1024)
  18739. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  18740. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18741. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18742. //if err != nil {
  18743. // fmt.Println("Error opening file:", err)
  18744. //}
  18745. //defer file.Close()
  18746. //
  18747. //var lastProgram Program
  18748. //scanner := bufio.NewScanner(file)
  18749. //inProgram := false
  18750. //
  18751. //for scanner.Scan() {
  18752. // line := scanner.Text()
  18753. // if strings.Contains(line, "<program>") {
  18754. // inProgram = true
  18755. // programXML := "<program>"
  18756. // for scanner.Scan() {
  18757. // line = scanner.Text()
  18758. // programXML += line
  18759. // if strings.Contains(line, "</program>") {
  18760. // programXML += "</program>"
  18761. // break
  18762. // }
  18763. // }
  18764. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18765. // // 解析成功,更新最后的 Program
  18766. // }
  18767. // inProgram = false
  18768. // }
  18769. //}
  18770. //
  18771. // fmt.Println("Error reading file:", inProgram)
  18772. //
  18773. //if err := scanner.Err(); err != nil {
  18774. // fmt.Println("Error reading file:", err)
  18775. //}
  18776. // 输出最后一次的 Program
  18777. //fmt.Printf("最后一次的 <program>:\n")
  18778. //fmt.Printf("<program>\n")
  18779. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18780. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18781. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18782. //fmt.Printf("</program>\n")
  18783. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18784. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18785. return ConvertToString(string(str1), "gbk", "utf-8")
  18786. }
  18787. func (c *HisApiController) GetahBasBaseInfo() string {
  18788. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18789. readCard := DllDef.MustFindProc("iReadCardBas")
  18790. if readCard == nil {
  18791. fmt.Println("readcard is nil")
  18792. readCard = DllDef.MustFindProc("iReadCardBas")
  18793. }
  18794. //str := make([]byte, 1024)
  18795. str1 := make([]byte, 1024)
  18796. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18797. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18798. //if err != nil {
  18799. // fmt.Println("Error opening file:", err)
  18800. //}
  18801. //defer file.Close()
  18802. //
  18803. //var lastProgram Program
  18804. //scanner := bufio.NewScanner(file)
  18805. //inProgram := false
  18806. //
  18807. //for scanner.Scan() {
  18808. // line := scanner.Text()
  18809. // if strings.Contains(line, "<program>") {
  18810. // inProgram = true
  18811. // programXML := "<program>"
  18812. // for scanner.Scan() {
  18813. // line = scanner.Text()
  18814. // programXML += line
  18815. // if strings.Contains(line, "</program>") {
  18816. // programXML += "</program>"
  18817. // break
  18818. // }
  18819. // }
  18820. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18821. // // 解析成功,更新最后的 Program
  18822. // }
  18823. // inProgram = false
  18824. // }
  18825. //}
  18826. //
  18827. // fmt.Println("Error reading file:", inProgram)
  18828. //
  18829. //if err := scanner.Err(); err != nil {
  18830. // fmt.Println("Error reading file:", err)
  18831. //}
  18832. // 输出最后一次的 Program
  18833. //fmt.Printf("最后一次的 <program>:\n")
  18834. //fmt.Printf("<program>\n")
  18835. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18836. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18837. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18838. //fmt.Printf("</program>\n")
  18839. fmt.Println(string(str1))
  18840. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18841. if ret2 != 0 {
  18842. return ""
  18843. }
  18844. return string(str1)
  18845. }
  18846. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18847. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18848. readCard := DllDef.MustFindProc("read_cardinfo")
  18849. if readCard == nil {
  18850. fmt.Println("readcard is nil")
  18851. readCard = DllDef.MustFindProc("read_cardinfo")
  18852. }
  18853. str := make([]byte, 1024) //卡号
  18854. str1 := make([]byte, 1024) //卡识别码
  18855. str2 := make([]byte, 1024) //身份证号
  18856. str3 := make([]byte, 1024) //姓名
  18857. str4 := make([]byte, 1024) //错误信息
  18858. 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])))
  18859. fmt.Println(string(str1))
  18860. fmt.Println(string(str))
  18861. fmt.Println(string(str2))
  18862. fmt.Println(string(str3))
  18863. fmt.Println(string(str4))
  18864. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18865. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18866. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18867. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18868. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18869. if ret2 != 0 {
  18870. return "", "", "", "", ""
  18871. }
  18872. return string(str), string(str1), string(str2), string(str3), string(str4)
  18873. }
  18874. type CustomFundPay struct {
  18875. FundPayType string `json:"fund_pay_type"`
  18876. FundPayamt float64 `json:"fund_payamt"`
  18877. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18878. }
  18879. //func (c *HisApiController) GetBatchSettleList() {
  18880. // start_time_str := c.GetString("start_time")
  18881. // //end_time_str := c.GetString("end_time")
  18882. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18883. //
  18884. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18885. //
  18886. // for _, item := range orders {
  18887. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18888. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18889. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18890. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18891. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18892. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18893. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18894. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18895. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18896. //
  18897. // if order.ID == 0 {
  18898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18899. // return
  18900. // }
  18901. //
  18902. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18903. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18904. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18905. // //fmt.Println(count)
  18906. // //var zero string
  18907. // //number := count + 1
  18908. // //if number >= 1000 {
  18909. // // zero = "0000" + strconv.FormatInt(number, 10)
  18910. // //} else if number >= 10000 {
  18911. // // zero = "000" + strconv.FormatInt(number, 10)
  18912. // //} else if number >= 100000 {
  18913. // // zero = "00" + strconv.FormatInt(number, 10)
  18914. // //} else if number >= 1000000 {
  18915. // // zero = "0" + strconv.FormatInt(number, 10)
  18916. // //} else {
  18917. // // zero = strconv.FormatInt(number, 10)
  18918. // //}
  18919. // //fmt.Println(zero)
  18920. //
  18921. // struct4101 := service.Struct4101{
  18922. // PsnNo: order.PsnNo,
  18923. // MdtrtId: order.MdtrtId,
  18924. // SetlId: order.SetlId,
  18925. // PsnName: order.PsnName,
  18926. // Gend: order.Gend,
  18927. // Brdy: his.Brdy,
  18928. // Age: his.Age,
  18929. // Naty: order.Naty,
  18930. // PatnCertType: "01",
  18931. // Certno: order.Certno,
  18932. // Prfs: "90",
  18933. // ConerName: roles[0].UserName,
  18934. // PatnRlts: "99",
  18935. // ConerAddr: miConfig.OrgName,
  18936. // ConerTel: admin.Mobile,
  18937. // HiType: order.Insutype,
  18938. // Insuplc: miConfig.InsuplcAdmdvs,
  18939. // MaindiagFlag: "1",
  18940. // BillCode: order.SetlId,
  18941. // BillNo: order.SetlId,
  18942. // BizSn: order.Number,
  18943. // PsnSelfPay: order.PsnPartAmt,
  18944. // PsnOwnPay: order.PsnPartAmt,
  18945. // AcctPay: order.AcctPay,
  18946. // PsnCashpay: order.PsnCashPay,
  18947. // HiPaymtd: "1",
  18948. // Hsorg: miConfig.InsuplcAdmdvs,
  18949. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18950. // MedinsFillPsn: curRoles.UserName,
  18951. // MedinsFillDept: miConfig.OrgName,
  18952. // IptMedType: "2",
  18953. // }
  18954. // struct4101.SetlBegnDate = order.SetlTime
  18955. // struct4101.SetlEndDate = order.SetlTime
  18956. // time_arr := strings.Split(order.SetlTime, " ")
  18957. // struct4101.AdmTime = time_arr[0]
  18958. // struct4101.AdmEndTime = time_arr[0]
  18959. //
  18960. // var rf []CustomFundPay
  18961. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18962. //
  18963. // var tempFunPays []service.CustomStruct
  18964. // for _, item := range rf {
  18965. // var tempFunPay service.CustomStruct
  18966. // tempFunPay.FundPayamt = item.FundPayamt
  18967. // tempFunPay.FundPayType = item.FundPayType
  18968. // tempFunPays = append(tempFunPays, tempFunPay)
  18969. // }
  18970. // struct4101.CustomStruct = tempFunPays
  18971. //
  18972. // var tempDiaginfos []service.DiaginfoStructTwo
  18973. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18974. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18975. //
  18976. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18977. // var config []*models.HisXtDiagnoseConfig
  18978. // for _, item := range diagnosis_ids {
  18979. // id, _ := strconv.ParseInt(item, 10, 64)
  18980. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18981. // config = append(config, &diagnosisConfig)
  18982. // }
  18983. //
  18984. // for index, item := range config {
  18985. // if index == 0 {
  18986. // var tempDiaginfo service.DiaginfoStructTwo
  18987. // tempDiaginfo.DiagCode = item.CountryCode
  18988. // tempDiaginfo.DiagName = item.CountryContentName
  18989. // tempDiaginfo.DiagType = "1"
  18990. // tempDiaginfo.MaindiagFlag = "1"
  18991. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18992. // } else {
  18993. // var tempDiaginfo service.DiaginfoStructTwo
  18994. // tempDiaginfo.DiagCode = item.CountryCode
  18995. // tempDiaginfo.DiagName = item.CountryContentName
  18996. // tempDiaginfo.DiagType = "1"
  18997. // tempDiaginfo.MaindiagFlag = "0"
  18998. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18999. // }
  19000. // }
  19001. // struct4101.Diseinfo = tempDiaginfos
  19002. //
  19003. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  19004. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19005. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19006. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19007. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19008. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19009. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19010. //
  19011. // var iteminfo service.IteminfoStruct
  19012. //
  19013. // var bedCostTotal float64 = 0 //床位总费
  19014. // var bedCostSelfTotal float64 = 0 //床位自费
  19015. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19016. //
  19017. // var operationCostTotal float64 = 0 //手术费
  19018. // var operationCostSelfTotal float64 = 0 //手术费
  19019. // var operationCostPartSelfTotal float64 = 0 //手术费
  19020. //
  19021. // var otherCostTotal float64 = 0 //其他费用
  19022. // var otherCostSelfTotal float64 = 0 //其他费用
  19023. // var otherCostPartSelfTotal float64 = 0 //其他费用
  19024. //
  19025. // var materialCostTotal float64 = 0 //材料费
  19026. // var materialCostSelfTotal float64 = 0 //材料费
  19027. // var materialCostPartSelfTotal float64 = 0 //材料费
  19028. //
  19029. // var westernMedicineCostTotal float64 = 0 //西药费
  19030. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  19031. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19032. //
  19033. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19034. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19035. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19036. //
  19037. // var checkCostTotal float64 = 0 //检查费
  19038. // var checkCostSelfTotal float64 = 0 //检查费
  19039. // var checkCostPartSelfTotal float64 = 0 //检查费
  19040. //
  19041. // var laboratoryCostTotal float64 = 0 //化验费
  19042. // var laboratoryCostSelfTotal float64 = 0 //化验费
  19043. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19044. //
  19045. // var treatCostTotal float64 = 0 //治疗费用
  19046. // var treatCostSelfTotal float64 = 0 //治疗费用
  19047. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  19048. //
  19049. // decimal.DivisionPrecision = 2
  19050. //
  19051. // var bed_fulamt_ownpay_amt float64 = 0
  19052. // var operation_fulamt_ownpay_amt float64 = 0
  19053. // var other_fulamt_ownpay_amt float64 = 0
  19054. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  19055. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19056. // var check_fulamt_ownpay_amt float64 = 0
  19057. // var material_fulamt_ownpay_amt float64 = 0
  19058. // var laboratory_fulamt_ownpay_amt float64 = 0
  19059. // var treat_fulamt_ownpay_amt float64 = 0
  19060. //
  19061. // var bed_claa_sunmfee float64 = 0
  19062. // var bed_clab_amt float64 = 0
  19063. // var bed_other_amt float64 = 0
  19064. //
  19065. // var operation_claa_sunmfee float64 = 0
  19066. // var operation_clab_amt float64 = 0
  19067. // var operation_other_amt float64 = 0
  19068. //
  19069. // var other_claa_sunmfee float64 = 0
  19070. // var other_clab_amt float64 = 0
  19071. // var other_other_amt float64 = 0
  19072. //
  19073. // var westernMedicine_claa_sunmfee float64 = 0
  19074. // var westernMedicine_clab_amt float64 = 0
  19075. // var westernMedicine_other_amt float64 = 0
  19076. //
  19077. // var chineseTraditional_claa_sunmfee float64 = 0
  19078. // var chineseTraditional_clab_amt float64 = 0
  19079. // var chineseTraditional_other_amt float64 = 0
  19080. //
  19081. // var check_claa_sunmfee float64 = 0
  19082. // var check_clab_amt float64 = 0
  19083. // var check_other_amt float64 = 0
  19084. //
  19085. // var material_claa_sunmfee float64 = 0
  19086. // var material_clab_amt float64 = 0
  19087. // var material_other_amt float64 = 0
  19088. //
  19089. // var laboratory_claa_sunmfee float64 = 0
  19090. // var laboratory_clab_amt float64 = 0
  19091. // var laboratory_other_amt float64 = 0
  19092. //
  19093. // var treat_claa_sunmfee float64 = 0
  19094. // var treat_clab_amt float64 = 0
  19095. // var treat_other_amt float64 = 0
  19096. //
  19097. // for _, item := range order.HisOrderInfo {
  19098. // if item.MedChrgitmType == "01" { //床位费
  19099. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19100. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19101. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19102. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19103. // if item.ChrgitmLv == "1" {
  19104. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19105. // }
  19106. // if item.ChrgitmLv == "2" {
  19107. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19108. //
  19109. // }
  19110. // if item.ChrgitmLv == "3" {
  19111. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19112. // }
  19113. //
  19114. // }
  19115. //
  19116. // if item.MedChrgitmType == "03" { //检查费
  19117. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19118. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19119. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19120. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19121. // if item.ChrgitmLv == "1" {
  19122. //
  19123. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19124. //
  19125. // }
  19126. // if item.ChrgitmLv == "2" {
  19127. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19128. //
  19129. // }
  19130. // if item.ChrgitmLv == "3" {
  19131. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19132. // }
  19133. // }
  19134. //
  19135. // if item.MedChrgitmType == "04" { //化验费
  19136. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19137. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19138. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19139. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19140. // if item.ChrgitmLv == "1" {
  19141. //
  19142. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19143. //
  19144. // }
  19145. // if item.ChrgitmLv == "2" {
  19146. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19147. //
  19148. // }
  19149. // if item.ChrgitmLv == "3" {
  19150. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19151. // }
  19152. // }
  19153. //
  19154. // if item.MedChrgitmType == "05" { //治疗费
  19155. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19156. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19157. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19158. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19159. // if item.ChrgitmLv == "1" {
  19160. //
  19161. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19162. //
  19163. // }
  19164. // if item.ChrgitmLv == "2" {
  19165. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19166. //
  19167. // }
  19168. // if item.ChrgitmLv == "3" {
  19169. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19170. // }
  19171. // }
  19172. //
  19173. // if item.MedChrgitmType == "06" { //手术费
  19174. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19175. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19176. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19177. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19178. //
  19179. // if item.ChrgitmLv == "1" {
  19180. //
  19181. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19182. //
  19183. // }
  19184. // if item.ChrgitmLv == "2" {
  19185. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19186. //
  19187. // }
  19188. // if item.ChrgitmLv == "3" {
  19189. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19190. // }
  19191. // }
  19192. //
  19193. // if item.MedChrgitmType == "08" { //材料费
  19194. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19195. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19196. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19197. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19198. // if item.ChrgitmLv == "1" {
  19199. //
  19200. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19201. //
  19202. // }
  19203. // if item.ChrgitmLv == "2" {
  19204. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19205. //
  19206. // }
  19207. // if item.ChrgitmLv == "3" {
  19208. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19209. // }
  19210. // }
  19211. //
  19212. // if item.MedChrgitmType == "09" { //西药费
  19213. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19214. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19215. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19216. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19217. // if item.ChrgitmLv == "1" {
  19218. //
  19219. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19220. //
  19221. // }
  19222. // if item.ChrgitmLv == "2" {
  19223. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19224. //
  19225. // }
  19226. // if item.ChrgitmLv == "3" {
  19227. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19228. // }
  19229. // }
  19230. //
  19231. // if item.MedChrgitmType == "11" { //中成费
  19232. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19233. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19234. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19235. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19236. // if item.ChrgitmLv == "1" {
  19237. //
  19238. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19239. //
  19240. // }
  19241. // if item.ChrgitmLv == "2" {
  19242. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19243. //
  19244. // }
  19245. // if item.ChrgitmLv == "3" {
  19246. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19247. // }
  19248. // }
  19249. //
  19250. // if item.MedChrgitmType == "14" { //其他费
  19251. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19252. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19253. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19254. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19255. // if item.ChrgitmLv == "1" {
  19256. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19257. //
  19258. // }
  19259. // if item.ChrgitmLv == "2" {
  19260. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19261. //
  19262. // }
  19263. // if item.ChrgitmLv == "3" {
  19264. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19265. // }
  19266. // }
  19267. //
  19268. // }
  19269. //
  19270. // var iteminfoStructs []service.IteminfoStruct
  19271. //
  19272. // if bedCostTotal != 0 {
  19273. // iteminfo.MedChrgitm = "01"
  19274. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19275. // iteminfo.Amt = bedCostTotal
  19276. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19277. // iteminfo.ClabAmt = bed_clab_amt
  19278. // iteminfo.OthAmt = bed_other_amt
  19279. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19280. // }
  19281. //
  19282. // if checkCostTotal != 0 {
  19283. // iteminfo.MedChrgitm = "03"
  19284. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19285. // iteminfo.Amt = checkCostTotal
  19286. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19287. // iteminfo.ClabAmt = check_clab_amt
  19288. // iteminfo.OthAmt = check_other_amt
  19289. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19290. //
  19291. // }
  19292. //
  19293. // if laboratoryCostTotal != 0 {
  19294. // iteminfo.MedChrgitm = "04"
  19295. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19296. // iteminfo.Amt = laboratoryCostTotal
  19297. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19298. // iteminfo.ClabAmt = laboratory_clab_amt
  19299. // iteminfo.OthAmt = laboratory_other_amt
  19300. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19301. //
  19302. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19303. //
  19304. // }
  19305. //
  19306. // if treatCostTotal != 0 {
  19307. // iteminfo.MedChrgitm = "05"
  19308. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19309. // iteminfo.Amt = treatCostTotal
  19310. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19311. // iteminfo.ClabAmt = treat_clab_amt
  19312. // iteminfo.OthAmt = treat_other_amt
  19313. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19314. // //(struct4101.IteminfoStruct, iteminfo)
  19315. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19316. // }
  19317. //
  19318. // if operationCostTotal != 0 {
  19319. // iteminfo.MedChrgitm = "06"
  19320. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19321. // iteminfo.Amt = operationCostTotal
  19322. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19323. // iteminfo.ClabAmt = operation_clab_amt
  19324. // iteminfo.OthAmt = operation_other_amt
  19325. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19326. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19327. // }
  19328. //
  19329. // if materialCostTotal != 0 {
  19330. // iteminfo.MedChrgitm = "08"
  19331. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19332. // iteminfo.Amt = materialCostTotal
  19333. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19334. // iteminfo.ClabAmt = material_clab_amt
  19335. // iteminfo.OthAmt = material_other_amt
  19336. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19337. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19338. // }
  19339. //
  19340. // if westernMedicineCostTotal != 0 {
  19341. // iteminfo.MedChrgitm = "09"
  19342. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19343. // iteminfo.Amt = westernMedicineCostTotal
  19344. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19345. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19346. // iteminfo.OthAmt = westernMedicine_other_amt
  19347. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19348. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19349. //
  19350. // }
  19351. // if chineseTraditionalMedicineCostTotal != 0 {
  19352. // iteminfo.MedChrgitm = "11"
  19353. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19354. // iteminfo.Amt = westernMedicineCostTotal
  19355. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19356. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19357. // iteminfo.OthAmt = westernMedicine_other_amt
  19358. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19359. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19360. //
  19361. // }
  19362. // if otherCostTotal != 0 {
  19363. // iteminfo.MedChrgitm = "14"
  19364. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19365. // iteminfo.Amt = otherCostTotal
  19366. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19367. // iteminfo.ClabAmt = other_clab_amt
  19368. // iteminfo.OthAmt = other_other_amt
  19369. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19370. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19371. //
  19372. // }
  19373. // struct4101.IteminfoStruct = iteminfoStructs
  19374. // struct4101.Ntly = "中国"
  19375. // struct4101.AdmCaty = "A03.06"
  19376. //
  19377. // struct4101.DoctorName = doctor.UserName
  19378. // struct4101.DoctorCode = doctor.DoctorNumber
  19379. //
  19380. // var res ResultSeventeen
  19381. //
  19382. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19383. // struct4101.BillCode = order.Number
  19384. // struct4101.BillNo = order.SetlId
  19385. // var resOther ResultSeventeenOther
  19386. // var pp models.PublicParams
  19387. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19388. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19389. // pp.FixmedinsName = miConfig.OrgName
  19390. // pp.FixmedinsCode = miConfig.Code
  19391. // pp.RequestUrl = miConfig.Url
  19392. // pp.Cainfo = miConfig.Cainfo
  19393. // pp.SecretKey = miConfig.SecretKey
  19394. // pp.AccessKey = miConfig.AccessKey
  19395. // pp.OpterName = curRoles.UserName
  19396. //
  19397. // client := &http.Client{}
  19398. // var req *http.Request
  19399. // data := make(map[string]interface{})
  19400. // data["struct4101"] = struct4101
  19401. // data["pp"] = pp
  19402. // bytesData, _ := json.Marshal(data)
  19403. // if miConfig.MdtrtareaAdmvs == "320921" {
  19404. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19405. // } else {
  19406. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19407. // }
  19408. // resp, _ := client.Do(req)
  19409. // defer resp.Body.Close()
  19410. // body, ioErr := ioutil.ReadAll(resp.Body)
  19411. // if ioErr != nil {
  19412. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19414. // return
  19415. // }
  19416. // var respJSON map[string]interface{}
  19417. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19418. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19420. // return
  19421. // }
  19422. //
  19423. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19424. // userJSONBytes, _ := json.Marshal(respJSON)
  19425. // fmt.Println("log")
  19426. // fmt.Println(string(userJSONBytes))
  19427. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19428. // utils.ErrorLog("解析失败:%v", err)
  19429. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19430. // return
  19431. // }
  19432. // res.InfRefmsgid = resOther.InfRefmsgid
  19433. // res.Output = resOther.Output
  19434. // res.ErrMsg = resOther.ErrMsg
  19435. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19436. // res.Infcode = infocode
  19437. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  19438. //
  19439. // var pp models.PublicParams
  19440. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19441. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19442. // pp.FixmedinsName = miConfig.OrgName
  19443. // pp.FixmedinsCode = miConfig.Code
  19444. // pp.RequestUrl = miConfig.Url
  19445. // pp.Cainfo = miConfig.Cainfo
  19446. // pp.SecretKey = miConfig.SecretKey
  19447. // pp.AccessKey = miConfig.AccessKey
  19448. // pp.OpterName = curRoles.UserName
  19449. // result, _ := service.Jxyb4101(struct4101, pp)
  19450. // var dat map[string]interface{}
  19451. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19452. // fmt.Println(dat)
  19453. // } else {
  19454. // fmt.Println(err)
  19455. // }
  19456. // userJSONBytes, _ := json.Marshal(dat)
  19457. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19458. // utils.ErrorLog("解析失败:%v", err)
  19459. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19460. // return
  19461. // }
  19462. //
  19463. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  19464. // var pp models.PublicParams
  19465. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19466. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19467. // pp.FixmedinsName = miConfig.OrgName
  19468. // pp.FixmedinsCode = miConfig.Code
  19469. // pp.RequestUrl = miConfig.Url
  19470. // pp.Cainfo = miConfig.Cainfo
  19471. // pp.SecretKey = miConfig.SecretKey
  19472. // pp.AccessKey = miConfig.AccessKey
  19473. // pp.OpterName = curRoles.UserName
  19474. // result, _ := service.Hnyb4101(struct4101, pp)
  19475. // var dat map[string]interface{}
  19476. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19477. // fmt.Println(dat)
  19478. // } else {
  19479. // fmt.Println(err)
  19480. // }
  19481. // userJSONBytes, _ := json.Marshal(dat)
  19482. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19483. // utils.ErrorLog("解析失败:%v", err)
  19484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19485. // return
  19486. // }
  19487. //
  19488. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  19489. // var resOther ResultSeventeenOther
  19490. //
  19491. // var pp models.PublicParams
  19492. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19493. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19494. // pp.FixmedinsName = miConfig.OrgName
  19495. // pp.FixmedinsCode = miConfig.Code
  19496. // pp.RequestUrl = miConfig.Url
  19497. // pp.Cainfo = miConfig.Cainfo
  19498. // pp.SecretKey = miConfig.SecretKey
  19499. // pp.AccessKey = miConfig.AccessKey
  19500. // pp.OpterName = curRoles.UserName
  19501. // client := &http.Client{}
  19502. // var req *http.Request
  19503. // data := make(map[string]interface{})
  19504. // data["struct4101"] = struct4101
  19505. // data["pp"] = pp
  19506. // bytesData, _ := json.Marshal(data)
  19507. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19508. // resp, _ := client.Do(req)
  19509. // defer resp.Body.Close()
  19510. // body, ioErr := ioutil.ReadAll(resp.Body)
  19511. // if ioErr != nil {
  19512. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19514. // return
  19515. // }
  19516. // var respJSON map[string]interface{}
  19517. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19518. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19520. // return
  19521. // }
  19522. //
  19523. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19524. // userJSONBytes, _ := json.Marshal(respJSON)
  19525. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19526. // utils.ErrorLog("解析失败:%v", err)
  19527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19528. // return
  19529. // }
  19530. // res.InfRefmsgid = resOther.InfRefmsgid
  19531. // res.Output = resOther.Output
  19532. // res.ErrMsg = resOther.ErrMsg
  19533. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19534. // res.Infcode = infocode
  19535. //
  19536. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  19537. // var pp models.PublicParams
  19538. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19539. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19540. // pp.FixmedinsName = miConfig.OrgName
  19541. // pp.FixmedinsCode = miConfig.Code
  19542. // pp.RequestUrl = miConfig.Url
  19543. // pp.Cainfo = miConfig.Cainfo
  19544. // pp.SecretKey = miConfig.SecretKey
  19545. // pp.AccessKey = miConfig.AccessKey
  19546. // pp.OpterName = curRoles.UserName
  19547. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19548. // fmt.Println(requestLog)
  19549. // fmt.Println(errMsgLog)
  19550. //
  19551. // saveLog(result, requestLog, "4101a", "上传清单")
  19552. //
  19553. // var dat map[string]interface{}
  19554. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19555. // fmt.Println(dat)
  19556. // } else {
  19557. // fmt.Println(err)
  19558. // }
  19559. // userJSONBytes, _ := json.Marshal(dat)
  19560. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19561. // utils.ErrorLog("解析失败:%v", err)
  19562. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19563. // return
  19564. // }
  19565. //
  19566. // } else {
  19567. //
  19568. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  19569. // var dat map[string]interface{}
  19570. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19571. // fmt.Println(dat)
  19572. // } else {
  19573. // fmt.Println(err)
  19574. // }
  19575. // userJSONBytes, _ := json.Marshal(dat)
  19576. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19577. // utils.ErrorLog("解析失败:%v", err)
  19578. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19579. // return
  19580. // }
  19581. // }
  19582. //
  19583. // if res.Infcode != 0 {
  19584. // adminUser := c.GetAdminUserInfo()
  19585. // errlog := &models.HisOrderError{
  19586. // UserOrgId: adminUser.CurrentOrgId,
  19587. // Ctime: time.Now().Unix(),
  19588. // Mtime: time.Now().Unix(),
  19589. // ErrMsg: res.ErrMsg,
  19590. // Status: 1,
  19591. // PatientId: order.ID,
  19592. // Stage: 10265,
  19593. // }
  19594. // service.CreateErrMsgLog(errlog)
  19595. // continue
  19596. // } else {
  19597. // //order.FaPiaoNumber = zero
  19598. // //order.FaPiaoCode = last_order.FaPiaoCode
  19599. // //service.UpdateOrder(order)
  19600. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19601. // Number: res.Output.SetlListId,
  19602. // Status: 1,
  19603. // Ctime: time.Now().Unix(),
  19604. // Mtime: time.Now().Unix(),
  19605. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19606. // IsUpload: 1,
  19607. // OrderId: order.ID,
  19608. // }
  19609. // service.CreateUploadRecord(hisFundSettleListResult)
  19610. // c.ServeSuccessJSON(map[string]interface{}{
  19611. // "msg": "上传成功",
  19612. // "result": hisFundSettleListResult,
  19613. // })
  19614. // continue
  19615. // }
  19616. // }
  19617. //}
  19618. func (c *HisApiController) GetbatchSettleList() {
  19619. //order_id, _ := c.GetInt64("order_id")
  19620. admin_user_id, _ := c.GetInt64("admin_user_id")
  19621. start_date := c.GetString("start_date")
  19622. end_date := c.GetString("end_date")
  19623. orders, _ := service.GetAllHisOrderTwo10485(start_date,end_date)
  19624. for _, item := range orders {
  19625. order, _ := service.GetHisOrderByIDTwo(item.ID)
  19626. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19627. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19628. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19629. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19630. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19631. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19632. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19633. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19634. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19635. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19636. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19637. //fmt.Println(count)
  19638. //var zero string
  19639. //number := count + 1
  19640. //if number >= 1000 {
  19641. // zero = "0000" + strconv.FormatInt(number, 10)
  19642. //} else if number >= 10000 {
  19643. // zero = "000" + strconv.FormatInt(number, 10)
  19644. //} else if number >= 100000 {
  19645. // zero = "00" + strconv.FormatInt(number, 10)
  19646. //} else if number >= 1000000 {
  19647. // zero = "0" + strconv.FormatInt(number, 10)
  19648. //} else {
  19649. // zero = strconv.FormatInt(number, 10)
  19650. //}
  19651. //fmt.Println(zero)
  19652. struct4101 := service.Struct4101{
  19653. PsnNo: order.PsnNo,
  19654. MdtrtId: order.MdtrtId,
  19655. SetlId: order.SetlId,
  19656. PsnName: order.PsnName,
  19657. Gend: order.Gend,
  19658. Brdy: his.Brdy,
  19659. Age: his.Age,
  19660. Naty: order.Naty,
  19661. PatnCertType: "01",
  19662. Certno: order.Certno,
  19663. Prfs: "90",
  19664. ConerName: roles[0].UserName,
  19665. PatnRlts: "99",
  19666. ConerAddr: miConfig.OrgName,
  19667. ConerTel: admin.Mobile,
  19668. HiType: order.Insutype,
  19669. Insuplc: miConfig.InsuplcAdmdvs,
  19670. MaindiagFlag: "1",
  19671. BillCode: order.SetlId,
  19672. BillNo: order.SetlId,
  19673. BizSn: order.Number,
  19674. PsnSelfPay: order.PsnPartAmt,
  19675. PsnOwnPay: order.PsnPartAmt,
  19676. AcctPay: order.AcctPay,
  19677. PsnCashpay: order.PsnCashPay,
  19678. HiPaymtd: "1",
  19679. Hsorg: miConfig.InsuplcAdmdvs,
  19680. HsorgOpter: miConfig.InsuplcAdmdvs,
  19681. MedinsFillPsn: curRoles.UserName,
  19682. MedinsFillDept: miConfig.OrgName,
  19683. IptMedType: "2",
  19684. }
  19685. struct4101.SetlBegnDate = order.SetlTime
  19686. struct4101.SetlEndDate = order.SetlTime
  19687. time_arr := strings.Split(order.SetlTime, " ")
  19688. struct4101.AdmTime = time_arr[0]
  19689. struct4101.AdmEndTime = time_arr[0]
  19690. //var rf []CustomFundPay
  19691. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19692. //
  19693. //var tempFunPays []service.CustomStruct
  19694. //for _, item := range rf {
  19695. // var tempFunPay service.CustomStruct
  19696. // tempFunPay.FundPayamt = item.FundPayamt
  19697. // tempFunPay.FundPayType = item.FundPayType
  19698. // tempFunPays = append(tempFunPays, tempFunPay)
  19699. //}
  19700. //struct4101.CustomStruct = tempFunPays
  19701. var tempDiaginfos []service.DiaginfoStructTwo
  19702. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19703. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19704. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19705. var config []*models.HisXtDiagnoseConfig
  19706. for _, item := range diagnosis_ids {
  19707. id, _ := strconv.ParseInt(item, 10, 64)
  19708. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19709. config = append(config, &diagnosisConfig)
  19710. }
  19711. for index, item := range config {
  19712. if index == 0 {
  19713. var tempDiaginfo service.DiaginfoStructTwo
  19714. tempDiaginfo.DiagCode = item.CountryCode
  19715. tempDiaginfo.DiagName = item.CountryContentName
  19716. tempDiaginfo.DiagType = "1"
  19717. tempDiaginfo.MaindiagFlag = "1"
  19718. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19719. } else {
  19720. var tempDiaginfo service.DiaginfoStructTwo
  19721. tempDiaginfo.DiagCode = item.CountryCode
  19722. tempDiaginfo.DiagName = item.CountryContentName
  19723. tempDiaginfo.DiagType = "1"
  19724. tempDiaginfo.MaindiagFlag = "0"
  19725. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19726. }
  19727. }
  19728. struct4101.Diseinfo = tempDiaginfos
  19729. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19730. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19731. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19732. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19733. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19734. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19735. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19736. var iteminfo service.IteminfoStruct
  19737. var bedCostTotal float64 = 0 //床位总费
  19738. var bedCostSelfTotal float64 = 0 //床位自费
  19739. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19740. var operationCostTotal float64 = 0 //手术费
  19741. var operationCostSelfTotal float64 = 0 //手术费
  19742. var operationCostPartSelfTotal float64 = 0 //手术费
  19743. var otherCostTotal float64 = 0 //其他费用
  19744. var otherCostSelfTotal float64 = 0 //其他费用
  19745. var otherCostPartSelfTotal float64 = 0 //其他费用
  19746. var materialCostTotal float64 = 0 //材料费
  19747. var materialCostSelfTotal float64 = 0 //材料费
  19748. var materialCostPartSelfTotal float64 = 0 //材料费
  19749. var westernMedicineCostTotal float64 = 0 //西药费
  19750. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19751. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19752. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19753. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19754. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19755. var checkCostTotal float64 = 0 //检查费
  19756. var checkCostSelfTotal float64 = 0 //检查费
  19757. var checkCostPartSelfTotal float64 = 0 //检查费
  19758. var laboratoryCostTotal float64 = 0 //化验费
  19759. var laboratoryCostSelfTotal float64 = 0 //化验费
  19760. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19761. var treatCostTotal float64 = 0 //治疗费用
  19762. var treatCostSelfTotal float64 = 0 //治疗费用
  19763. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19764. decimal.DivisionPrecision = 2
  19765. var bed_fulamt_ownpay_amt float64 = 0
  19766. var operation_fulamt_ownpay_amt float64 = 0
  19767. var other_fulamt_ownpay_amt float64 = 0
  19768. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19769. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19770. var check_fulamt_ownpay_amt float64 = 0
  19771. var material_fulamt_ownpay_amt float64 = 0
  19772. var laboratory_fulamt_ownpay_amt float64 = 0
  19773. var treat_fulamt_ownpay_amt float64 = 0
  19774. var bed_claa_sunmfee float64 = 0
  19775. var bed_clab_amt float64 = 0
  19776. var bed_other_amt float64 = 0
  19777. var operation_claa_sunmfee float64 = 0
  19778. var operation_clab_amt float64 = 0
  19779. var operation_other_amt float64 = 0
  19780. var other_claa_sunmfee float64 = 0
  19781. var other_clab_amt float64 = 0
  19782. var other_other_amt float64 = 0
  19783. var westernMedicine_claa_sunmfee float64 = 0
  19784. var westernMedicine_clab_amt float64 = 0
  19785. var westernMedicine_other_amt float64 = 0
  19786. var chineseTraditional_claa_sunmfee float64 = 0
  19787. var chineseTraditional_clab_amt float64 = 0
  19788. var chineseTraditional_other_amt float64 = 0
  19789. var check_claa_sunmfee float64 = 0
  19790. var check_clab_amt float64 = 0
  19791. var check_other_amt float64 = 0
  19792. var material_claa_sunmfee float64 = 0
  19793. var material_clab_amt float64 = 0
  19794. var material_other_amt float64 = 0
  19795. var laboratory_claa_sunmfee float64 = 0
  19796. var laboratory_clab_amt float64 = 0
  19797. var laboratory_other_amt float64 = 0
  19798. var treat_claa_sunmfee float64 = 0
  19799. var treat_clab_amt float64 = 0
  19800. var treat_other_amt float64 = 0
  19801. for _, item := range order.HisOrderInfo {
  19802. if item.MedChrgitmType == "01" { //床位费
  19803. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19804. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19805. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19806. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19807. if item.ChrgitmLv == "1" {
  19808. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19809. }
  19810. if item.ChrgitmLv == "2" {
  19811. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19812. }
  19813. if item.ChrgitmLv == "3" {
  19814. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19815. }
  19816. }
  19817. if item.MedChrgitmType == "03" { //检查费
  19818. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19819. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19820. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19821. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19822. if item.ChrgitmLv == "1" {
  19823. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19824. }
  19825. if item.ChrgitmLv == "2" {
  19826. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19827. }
  19828. if item.ChrgitmLv == "3" {
  19829. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19830. }
  19831. }
  19832. if item.MedChrgitmType == "04" { //化验费
  19833. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19834. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19835. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19836. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19837. if item.ChrgitmLv == "1" {
  19838. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19839. }
  19840. if item.ChrgitmLv == "2" {
  19841. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19842. }
  19843. if item.ChrgitmLv == "3" {
  19844. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19845. }
  19846. }
  19847. if item.MedChrgitmType == "05" { //治疗费
  19848. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19849. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19850. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19851. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19852. if item.ChrgitmLv == "1" {
  19853. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19854. }
  19855. if item.ChrgitmLv == "2" {
  19856. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19857. }
  19858. if item.ChrgitmLv == "3" {
  19859. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19860. }
  19861. }
  19862. if item.MedChrgitmType == "06" { //手术费
  19863. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19864. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19865. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19866. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19867. if item.ChrgitmLv == "1" {
  19868. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19869. }
  19870. if item.ChrgitmLv == "2" {
  19871. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19872. }
  19873. if item.ChrgitmLv == "3" {
  19874. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19875. }
  19876. }
  19877. if item.MedChrgitmType == "08" { //材料费
  19878. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19879. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19880. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19881. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19882. if item.ChrgitmLv == "1" {
  19883. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19884. }
  19885. if item.ChrgitmLv == "2" {
  19886. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19887. }
  19888. if item.ChrgitmLv == "3" {
  19889. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19890. }
  19891. }
  19892. if item.MedChrgitmType == "09" { //西药费
  19893. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19894. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19895. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19896. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19897. if item.ChrgitmLv == "1" {
  19898. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19899. }
  19900. if item.ChrgitmLv == "2" {
  19901. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19902. }
  19903. if item.ChrgitmLv == "3" {
  19904. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19905. }
  19906. }
  19907. if item.MedChrgitmType == "11" { //中成费
  19908. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19909. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19910. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19911. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19912. if item.ChrgitmLv == "1" {
  19913. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19914. }
  19915. if item.ChrgitmLv == "2" {
  19916. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19917. }
  19918. if item.ChrgitmLv == "3" {
  19919. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19920. }
  19921. }
  19922. if item.MedChrgitmType == "14" { //其他费
  19923. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19924. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19925. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19926. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19927. if item.ChrgitmLv == "1" {
  19928. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19929. }
  19930. if item.ChrgitmLv == "2" {
  19931. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19932. }
  19933. if item.ChrgitmLv == "3" {
  19934. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19935. }
  19936. }
  19937. }
  19938. var iteminfoStructs []service.IteminfoStruct
  19939. if bedCostTotal != 0 {
  19940. iteminfo.MedChrgitm = "01"
  19941. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19942. iteminfo.Amt = bedCostTotal
  19943. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19944. iteminfo.ClabAmt = bed_clab_amt
  19945. iteminfo.OthAmt = bed_other_amt
  19946. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19947. }
  19948. if checkCostTotal != 0 {
  19949. iteminfo.MedChrgitm = "03"
  19950. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19951. iteminfo.Amt = checkCostTotal
  19952. iteminfo.ClaaSumfee = check_claa_sunmfee
  19953. iteminfo.ClabAmt = check_clab_amt
  19954. iteminfo.OthAmt = check_other_amt
  19955. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19956. }
  19957. if laboratoryCostTotal != 0 {
  19958. iteminfo.MedChrgitm = "04"
  19959. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19960. iteminfo.Amt = laboratoryCostTotal
  19961. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19962. iteminfo.ClabAmt = laboratory_clab_amt
  19963. iteminfo.OthAmt = laboratory_other_amt
  19964. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19965. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19966. }
  19967. if treatCostTotal != 0 {
  19968. iteminfo.MedChrgitm = "05"
  19969. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19970. iteminfo.Amt = treatCostTotal
  19971. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19972. iteminfo.ClabAmt = treat_clab_amt
  19973. iteminfo.OthAmt = treat_other_amt
  19974. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19975. //(struct4101.IteminfoStruct, iteminfo)
  19976. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19977. }
  19978. if operationCostTotal != 0 {
  19979. iteminfo.MedChrgitm = "06"
  19980. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19981. iteminfo.Amt = operationCostTotal
  19982. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19983. iteminfo.ClabAmt = operation_clab_amt
  19984. iteminfo.OthAmt = operation_other_amt
  19985. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19986. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19987. }
  19988. if materialCostTotal != 0 {
  19989. iteminfo.MedChrgitm = "08"
  19990. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19991. iteminfo.Amt = materialCostTotal
  19992. iteminfo.ClaaSumfee = material_claa_sunmfee
  19993. iteminfo.ClabAmt = material_clab_amt
  19994. iteminfo.OthAmt = material_other_amt
  19995. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19996. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19997. }
  19998. if westernMedicineCostTotal != 0 {
  19999. iteminfo.MedChrgitm = "09"
  20000. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20001. iteminfo.Amt = westernMedicineCostTotal
  20002. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20003. iteminfo.ClabAmt = westernMedicine_clab_amt
  20004. iteminfo.OthAmt = westernMedicine_other_amt
  20005. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20006. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20007. }
  20008. if chineseTraditionalMedicineCostTotal != 0 {
  20009. iteminfo.MedChrgitm = "11"
  20010. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20011. iteminfo.Amt = westernMedicineCostTotal
  20012. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20013. iteminfo.ClabAmt = westernMedicine_clab_amt
  20014. iteminfo.OthAmt = westernMedicine_other_amt
  20015. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20016. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20017. }
  20018. if otherCostTotal != 0 {
  20019. iteminfo.MedChrgitm = "14"
  20020. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20021. iteminfo.Amt = otherCostTotal
  20022. iteminfo.ClaaSumfee = other_claa_sunmfee
  20023. iteminfo.ClabAmt = other_clab_amt
  20024. iteminfo.OthAmt = other_other_amt
  20025. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20026. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20027. }
  20028. struct4101.IteminfoStruct = iteminfoStructs
  20029. struct4101.Ntly = "中国"
  20030. struct4101.AdmCaty = "A03.06"
  20031. struct4101.DoctorName = doctor.UserName
  20032. struct4101.DoctorCode = doctor.DoctorNumber
  20033. var res ResultSeventeen
  20034. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20035. struct4101.BillCode = order.Number
  20036. struct4101.BillNo = order.SetlId
  20037. var resOther ResultSeventeenOther
  20038. var pp models.PublicParams
  20039. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20040. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20041. pp.FixmedinsName = miConfig.OrgName
  20042. pp.FixmedinsCode = miConfig.Code
  20043. pp.RequestUrl = miConfig.Url
  20044. pp.Cainfo = miConfig.Cainfo
  20045. pp.SecretKey = miConfig.SecretKey
  20046. pp.AccessKey = miConfig.AccessKey
  20047. pp.OpterName = curRoles.UserName
  20048. client := &http.Client{}
  20049. var req *http.Request
  20050. data := make(map[string]interface{})
  20051. data["struct4101"] = struct4101
  20052. data["pp"] = pp
  20053. bytesData, _ := json.Marshal(data)
  20054. if miConfig.MdtrtareaAdmvs == "320830" {
  20055. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20056. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20057. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20058. } else {
  20059. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20060. }
  20061. resp, _ := client.Do(req)
  20062. defer resp.Body.Close()
  20063. body, ioErr := ioutil.ReadAll(resp.Body)
  20064. if ioErr != nil {
  20065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20067. return
  20068. }
  20069. var respJSON map[string]interface{}
  20070. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20073. return
  20074. }
  20075. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20076. userJSONBytes, _ := json.Marshal(respJSON)
  20077. fmt.Println("log")
  20078. fmt.Println(string(userJSONBytes))
  20079. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20080. utils.ErrorLog("解析失败:%v", err)
  20081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20082. return
  20083. }
  20084. res.InfRefmsgid = resOther.InfRefmsgid
  20085. res.Output = resOther.Output
  20086. res.ErrMsg = resOther.ErrMsg
  20087. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20088. res.Infcode = infocode
  20089. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20090. var pp models.PublicParams
  20091. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20092. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20093. pp.FixmedinsName = miConfig.OrgName
  20094. pp.FixmedinsCode = miConfig.Code
  20095. pp.RequestUrl = miConfig.Url
  20096. pp.Cainfo = miConfig.Cainfo
  20097. pp.SecretKey = miConfig.SecretKey
  20098. pp.AccessKey = miConfig.AccessKey
  20099. pp.OpterName = curRoles.UserName
  20100. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20101. result, _ := service.Jxyb4101(struct4101, pp)
  20102. var dat map[string]interface{}
  20103. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20104. fmt.Println(dat)
  20105. } else {
  20106. fmt.Println(err)
  20107. }
  20108. userJSONBytes, _ := json.Marshal(dat)
  20109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20110. utils.ErrorLog("解析失败:%v", err)
  20111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20112. return
  20113. }
  20114. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20115. var pp models.PublicParams
  20116. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20117. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20118. pp.FixmedinsName = miConfig.OrgName
  20119. pp.FixmedinsCode = miConfig.Code
  20120. pp.RequestUrl = miConfig.Url
  20121. pp.Cainfo = miConfig.Cainfo
  20122. pp.SecretKey = miConfig.SecretKey
  20123. pp.AccessKey = miConfig.AccessKey
  20124. pp.OpterName = curRoles.UserName
  20125. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20126. result, _ := service.Jxyb4101(struct4101, pp)
  20127. var dat map[string]interface{}
  20128. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20129. fmt.Println(dat)
  20130. } else {
  20131. fmt.Println(err)
  20132. }
  20133. userJSONBytes, _ := json.Marshal(dat)
  20134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20135. utils.ErrorLog("解析失败:%v", err)
  20136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20137. return
  20138. }
  20139. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20140. var pp models.PublicParams
  20141. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20142. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20143. pp.FixmedinsName = miConfig.OrgName
  20144. pp.FixmedinsCode = miConfig.Code
  20145. pp.RequestUrl = miConfig.Url
  20146. pp.Cainfo = miConfig.Cainfo
  20147. pp.SecretKey = miConfig.SecretKey
  20148. pp.AccessKey = miConfig.AccessKey
  20149. pp.OpterName = curRoles.UserName
  20150. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20151. result, _ := service.Jxyb4101(struct4101, pp)
  20152. var dat map[string]interface{}
  20153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20154. fmt.Println(dat)
  20155. } else {
  20156. fmt.Println(err)
  20157. }
  20158. userJSONBytes, _ := json.Marshal(dat)
  20159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20160. utils.ErrorLog("解析失败:%v", err)
  20161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20162. return
  20163. }
  20164. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20165. var pp models.PublicParams
  20166. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20167. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20168. pp.FixmedinsName = miConfig.OrgName
  20169. pp.FixmedinsCode = miConfig.Code
  20170. pp.RequestUrl = miConfig.Url
  20171. pp.Cainfo = miConfig.Cainfo
  20172. pp.SecretKey = miConfig.SecretKey
  20173. pp.AccessKey = miConfig.AccessKey
  20174. pp.OpterName = curRoles.UserName
  20175. result, _ := service.Hnyb4101(struct4101, pp)
  20176. var dat map[string]interface{}
  20177. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20178. fmt.Println(dat)
  20179. } else {
  20180. fmt.Println(err)
  20181. }
  20182. userJSONBytes, _ := json.Marshal(dat)
  20183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20184. utils.ErrorLog("解析失败:%v", err)
  20185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20186. return
  20187. }
  20188. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20189. var resOther ResultSeventeenOther
  20190. var pp models.PublicParams
  20191. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20192. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20193. pp.FixmedinsName = miConfig.OrgName
  20194. pp.FixmedinsCode = miConfig.Code
  20195. pp.RequestUrl = miConfig.Url
  20196. pp.Cainfo = miConfig.Cainfo
  20197. pp.SecretKey = miConfig.SecretKey
  20198. pp.AccessKey = miConfig.AccessKey
  20199. pp.OpterName = curRoles.UserName
  20200. client := &http.Client{}
  20201. var req *http.Request
  20202. data := make(map[string]interface{})
  20203. data["struct4101"] = struct4101
  20204. data["pp"] = pp
  20205. bytesData, _ := json.Marshal(data)
  20206. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20207. resp, _ := client.Do(req)
  20208. defer resp.Body.Close()
  20209. body, ioErr := ioutil.ReadAll(resp.Body)
  20210. if ioErr != nil {
  20211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20213. return
  20214. }
  20215. var respJSON map[string]interface{}
  20216. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20219. return
  20220. }
  20221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20222. userJSONBytes, _ := json.Marshal(respJSON)
  20223. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20224. utils.ErrorLog("解析失败:%v", err)
  20225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20226. return
  20227. }
  20228. res.InfRefmsgid = resOther.InfRefmsgid
  20229. res.Output = resOther.Output
  20230. res.ErrMsg = resOther.ErrMsg
  20231. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20232. res.Infcode = infocode
  20233. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20234. var pp models.PublicParams
  20235. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20236. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20237. pp.FixmedinsName = miConfig.OrgName
  20238. pp.FixmedinsCode = miConfig.Code
  20239. pp.RequestUrl = miConfig.Url
  20240. pp.Cainfo = miConfig.Cainfo
  20241. pp.SecretKey = miConfig.SecretKey
  20242. pp.AccessKey = miConfig.AccessKey
  20243. pp.OpterName = curRoles.UserName
  20244. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20245. fmt.Println(requestLog)
  20246. fmt.Println(errMsgLog)
  20247. saveLog(result, requestLog, "4101a", "上传清单")
  20248. var dat map[string]interface{}
  20249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20250. fmt.Println(dat)
  20251. } else {
  20252. fmt.Println(err)
  20253. }
  20254. userJSONBytes, _ := json.Marshal(dat)
  20255. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20256. utils.ErrorLog("解析失败:%v", err)
  20257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20258. return
  20259. }
  20260. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20261. var pp models.PublicParams
  20262. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20263. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20264. pp.FixmedinsName = miConfig.OrgName
  20265. pp.FixmedinsCode = miConfig.Code
  20266. pp.RequestUrl = miConfig.Url
  20267. pp.Cainfo = miConfig.Cainfo
  20268. pp.SecretKey = miConfig.SecretKey
  20269. pp.AccessKey = miConfig.AccessKey
  20270. pp.OpterName = curRoles.UserName
  20271. client := &http.Client{}
  20272. var req *http.Request
  20273. data := make(map[string]interface{})
  20274. data["struct4101"] = struct4101
  20275. data["pp"] = pp
  20276. bytesData, _ := json.Marshal(data)
  20277. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20278. resp, _ := client.Do(req)
  20279. defer resp.Body.Close()
  20280. body, ioErr := ioutil.ReadAll(resp.Body)
  20281. if ioErr != nil {
  20282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20284. return
  20285. }
  20286. var respJSON map[string]interface{}
  20287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20290. return
  20291. }
  20292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20293. userJSONBytes, _ := json.Marshal(respJSON)
  20294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20295. utils.ErrorLog("解析失败:%v", err)
  20296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20297. return
  20298. }
  20299. } else {
  20300. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20301. var dat map[string]interface{}
  20302. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20303. fmt.Println(dat)
  20304. } else {
  20305. fmt.Println(err)
  20306. }
  20307. userJSONBytes, _ := json.Marshal(dat)
  20308. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20309. utils.ErrorLog("解析失败:%v", err)
  20310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20311. return
  20312. }
  20313. }
  20314. if res.Infcode != 0 {
  20315. errlog := &models.HisOrderError{
  20316. UserOrgId: order.UserOrgId,
  20317. Ctime: time.Now().Unix(),
  20318. Mtime: time.Now().Unix(),
  20319. ErrMsg: res.ErrMsg + "解析失败",
  20320. Status: 1,
  20321. PatientId: order.ID,
  20322. Stage: 10485,
  20323. }
  20324. service.CreateErrMsgLog(errlog)
  20325. continue
  20326. //c.ServeSuccessJSON(map[string]interface{}{
  20327. // "failed_code": -10,
  20328. // "msg": res.ErrMsg,
  20329. //})
  20330. } else {
  20331. //order.FaPiaoNumber = zero
  20332. //order.FaPiaoCode = last_order.FaPiaoCode
  20333. //service.UpdateOrder(order)
  20334. hisFundSettleListResult := &models.HisFundSettleListResult{
  20335. Number: res.Output.SetlListId,
  20336. Status: 1,
  20337. Ctime: time.Now().Unix(),
  20338. Mtime: time.Now().Unix(),
  20339. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20340. IsUpload: 1,
  20341. OrderId: order.ID,
  20342. }
  20343. service.CreateUploadRecord(hisFundSettleListResult)
  20344. continue
  20345. }
  20346. }
  20347. }
  20348. func (c *HisApiController) GetSettleList() {
  20349. order_id, _ := c.GetInt64("order_id")
  20350. admin_user_id, _ := c.GetInt64("admin_user_id")
  20351. order, _ := service.GetHisOrderByIDTwo(order_id)
  20352. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20353. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20354. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20355. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20356. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20357. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20358. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20359. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20360. if order.ID == 0 {
  20361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20362. return
  20363. }
  20364. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20365. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20366. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20367. //fmt.Println(count)
  20368. //var zero string
  20369. //number := count + 1
  20370. //if number >= 1000 {
  20371. // zero = "0000" + strconv.FormatInt(number, 10)
  20372. //} else if number >= 10000 {
  20373. // zero = "000" + strconv.FormatInt(number, 10)
  20374. //} else if number >= 100000 {
  20375. // zero = "00" + strconv.FormatInt(number, 10)
  20376. //} else if number >= 1000000 {
  20377. // zero = "0" + strconv.FormatInt(number, 10)
  20378. //} else {
  20379. // zero = strconv.FormatInt(number, 10)
  20380. //}
  20381. //fmt.Println(zero)
  20382. struct4101 := service.Struct4101{
  20383. PsnNo: order.PsnNo,
  20384. MdtrtId: order.MdtrtId,
  20385. SetlId: order.SetlId,
  20386. PsnName: order.PsnName,
  20387. Gend: order.Gend,
  20388. Brdy: his.Brdy,
  20389. Age: his.Age,
  20390. Naty: order.Naty,
  20391. PatnCertType: "01",
  20392. Certno: order.Certno,
  20393. Prfs: "90",
  20394. ConerName: roles[0].UserName,
  20395. PatnRlts: "99",
  20396. ConerAddr: miConfig.OrgName,
  20397. ConerTel: admin.Mobile,
  20398. HiType: order.Insutype,
  20399. Insuplc: miConfig.InsuplcAdmdvs,
  20400. MaindiagFlag: "1",
  20401. BillCode: order.SetlId,
  20402. BillNo: order.SetlId,
  20403. BizSn: order.Number,
  20404. PsnSelfPay: order.PsnPartAmt,
  20405. PsnOwnPay: order.PsnPartAmt,
  20406. AcctPay: order.AcctPay,
  20407. PsnCashpay: order.PsnCashPay,
  20408. HiPaymtd: "1",
  20409. Hsorg: miConfig.InsuplcAdmdvs,
  20410. HsorgOpter: miConfig.InsuplcAdmdvs,
  20411. MedinsFillPsn: curRoles.UserName,
  20412. MedinsFillDept: miConfig.OrgName,
  20413. IptMedType: "2",
  20414. }
  20415. struct4101.SetlBegnDate = order.SetlTime
  20416. struct4101.SetlEndDate = order.SetlTime
  20417. time_arr := strings.Split(order.SetlTime, " ")
  20418. struct4101.AdmTime = time_arr[0]
  20419. struct4101.AdmEndTime = time_arr[0]
  20420. //
  20421. //var rf []CustomFundPay
  20422. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20423. //
  20424. //var tempFunPays []service.CustomStruct
  20425. //for _, item := range rf {
  20426. // var tempFunPay service.CustomStruct
  20427. // tempFunPay.FundPayamt = item.FundPayamt
  20428. // tempFunPay.FundPayType = item.FundPayType
  20429. // tempFunPays = append(tempFunPays, tempFunPay)
  20430. //}
  20431. //struct4101.CustomStruct = tempFunPays
  20432. var tempDiaginfos []service.DiaginfoStructTwo
  20433. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20434. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20435. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  20436. var config []*models.HisXtDiagnoseConfig
  20437. for _, item := range diagnosis_ids {
  20438. id, _ := strconv.ParseInt(item, 10, 64)
  20439. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20440. config = append(config, &diagnosisConfig)
  20441. }
  20442. if miConfig.Code == "H15049901371" {
  20443. //for _, item := range config {
  20444. // if item.ID == 138 {
  20445. diagnosisConfig, _ := service.FindDiagnoseById(138)
  20446. var tempDiaginfo service.DiaginfoStructTwo
  20447. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  20448. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  20449. tempDiaginfo.DiagType = "1"
  20450. tempDiaginfo.MaindiagFlag = "1"
  20451. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20452. //}
  20453. //}
  20454. for _, item := range config {
  20455. if item.ID != 138 {
  20456. var tempDiaginfo service.DiaginfoStructTwo
  20457. tempDiaginfo.DiagCode = item.CountryCode
  20458. tempDiaginfo.DiagName = item.CountryContentName
  20459. tempDiaginfo.DiagType = "1"
  20460. tempDiaginfo.MaindiagFlag = "0"
  20461. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20462. }
  20463. }
  20464. } else {
  20465. for index, item := range config {
  20466. if index == 0 {
  20467. var tempDiaginfo service.DiaginfoStructTwo
  20468. tempDiaginfo.DiagCode = item.CountryCode
  20469. tempDiaginfo.DiagName = item.CountryContentName
  20470. tempDiaginfo.DiagType = "1"
  20471. tempDiaginfo.MaindiagFlag = "1"
  20472. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20473. } else {
  20474. var tempDiaginfo service.DiaginfoStructTwo
  20475. tempDiaginfo.DiagCode = item.CountryCode
  20476. tempDiaginfo.DiagName = item.CountryContentName
  20477. tempDiaginfo.DiagType = "1"
  20478. tempDiaginfo.MaindiagFlag = "0"
  20479. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20480. }
  20481. }
  20482. }
  20483. struct4101.Diseinfo = tempDiaginfos
  20484. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20485. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20486. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20487. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  20488. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  20489. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20490. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20491. var iteminfo service.IteminfoStruct
  20492. var bedCostTotal float64 = 0 //床位总费
  20493. var bedCostSelfTotal float64 = 0 //床位自费
  20494. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20495. var operationCostTotal float64 = 0 //手术费
  20496. var operationCostSelfTotal float64 = 0 //手术费
  20497. var operationCostPartSelfTotal float64 = 0 //手术费
  20498. var otherCostTotal float64 = 0 //其他费用
  20499. var otherCostSelfTotal float64 = 0 //其他费用
  20500. var otherCostPartSelfTotal float64 = 0 //其他费用
  20501. var materialCostTotal float64 = 0 //材料费
  20502. var materialCostSelfTotal float64 = 0 //材料费
  20503. var materialCostPartSelfTotal float64 = 0 //材料费
  20504. var westernMedicineCostTotal float64 = 0 //西药费
  20505. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20506. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20507. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20508. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20509. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20510. var checkCostTotal float64 = 0 //检查费
  20511. var checkCostSelfTotal float64 = 0 //检查费
  20512. var checkCostPartSelfTotal float64 = 0 //检查费
  20513. var laboratoryCostTotal float64 = 0 //化验费
  20514. var laboratoryCostSelfTotal float64 = 0 //化验费
  20515. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20516. var treatCostTotal float64 = 0 //治疗费用
  20517. var treatCostSelfTotal float64 = 0 //治疗费用
  20518. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20519. decimal.DivisionPrecision = 2
  20520. var bed_fulamt_ownpay_amt float64 = 0
  20521. var operation_fulamt_ownpay_amt float64 = 0
  20522. var other_fulamt_ownpay_amt float64 = 0
  20523. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20524. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20525. var check_fulamt_ownpay_amt float64 = 0
  20526. var material_fulamt_ownpay_amt float64 = 0
  20527. var laboratory_fulamt_ownpay_amt float64 = 0
  20528. var treat_fulamt_ownpay_amt float64 = 0
  20529. var bed_claa_sunmfee float64 = 0
  20530. var bed_clab_amt float64 = 0
  20531. var bed_other_amt float64 = 0
  20532. var operation_claa_sunmfee float64 = 0
  20533. var operation_clab_amt float64 = 0
  20534. var operation_other_amt float64 = 0
  20535. var other_claa_sunmfee float64 = 0
  20536. var other_clab_amt float64 = 0
  20537. var other_other_amt float64 = 0
  20538. var westernMedicine_claa_sunmfee float64 = 0
  20539. var westernMedicine_clab_amt float64 = 0
  20540. var westernMedicine_other_amt float64 = 0
  20541. var chineseTraditional_claa_sunmfee float64 = 0
  20542. var chineseTraditional_clab_amt float64 = 0
  20543. var chineseTraditional_other_amt float64 = 0
  20544. var check_claa_sunmfee float64 = 0
  20545. var check_clab_amt float64 = 0
  20546. var check_other_amt float64 = 0
  20547. var material_claa_sunmfee float64 = 0
  20548. var material_clab_amt float64 = 0
  20549. var material_other_amt float64 = 0
  20550. var laboratory_claa_sunmfee float64 = 0
  20551. var laboratory_clab_amt float64 = 0
  20552. var laboratory_other_amt float64 = 0
  20553. var treat_claa_sunmfee float64 = 0
  20554. var treat_clab_amt float64 = 0
  20555. var treat_other_amt float64 = 0
  20556. for _, item := range order.HisOrderInfo {
  20557. if item.MedChrgitmType == "01" { //床位费
  20558. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20559. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20560. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20561. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20562. if item.ChrgitmLv == "1" {
  20563. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20564. }
  20565. if item.ChrgitmLv == "2" {
  20566. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20567. }
  20568. if item.ChrgitmLv == "3" {
  20569. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20570. }
  20571. }
  20572. if item.MedChrgitmType == "03" { //检查费
  20573. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20574. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20575. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20576. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20577. if item.ChrgitmLv == "1" {
  20578. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20579. }
  20580. if item.ChrgitmLv == "2" {
  20581. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20582. }
  20583. if item.ChrgitmLv == "3" {
  20584. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20585. }
  20586. }
  20587. if item.MedChrgitmType == "04" { //化验费
  20588. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20589. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20590. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20591. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20592. if item.ChrgitmLv == "1" {
  20593. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20594. }
  20595. if item.ChrgitmLv == "2" {
  20596. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20597. }
  20598. if item.ChrgitmLv == "3" {
  20599. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20600. }
  20601. }
  20602. if item.MedChrgitmType == "05" { //治疗费
  20603. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20604. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20605. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20606. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20607. if item.ChrgitmLv == "1" {
  20608. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20609. }
  20610. if item.ChrgitmLv == "2" {
  20611. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20612. }
  20613. if item.ChrgitmLv == "3" {
  20614. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20615. }
  20616. }
  20617. if item.MedChrgitmType == "06" { //手术费
  20618. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20619. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20620. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20621. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20622. if item.ChrgitmLv == "1" {
  20623. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20624. }
  20625. if item.ChrgitmLv == "2" {
  20626. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20627. }
  20628. if item.ChrgitmLv == "3" {
  20629. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20630. }
  20631. }
  20632. if item.MedChrgitmType == "08" { //材料费
  20633. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20634. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20635. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20636. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20637. if item.ChrgitmLv == "1" {
  20638. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20639. }
  20640. if item.ChrgitmLv == "2" {
  20641. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20642. }
  20643. if item.ChrgitmLv == "3" {
  20644. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20645. }
  20646. }
  20647. if item.MedChrgitmType == "09" { //西药费
  20648. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20649. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20650. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20651. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20652. if item.ChrgitmLv == "1" {
  20653. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20654. }
  20655. if item.ChrgitmLv == "2" {
  20656. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20657. }
  20658. if item.ChrgitmLv == "3" {
  20659. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20660. }
  20661. }
  20662. if item.MedChrgitmType == "11" { //中成费
  20663. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20664. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20665. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20666. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20667. if item.ChrgitmLv == "1" {
  20668. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20669. }
  20670. if item.ChrgitmLv == "2" {
  20671. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20672. }
  20673. if item.ChrgitmLv == "3" {
  20674. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20675. }
  20676. }
  20677. if item.MedChrgitmType == "14" { //其他费
  20678. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20679. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20680. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20681. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20682. if item.ChrgitmLv == "1" {
  20683. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20684. }
  20685. if item.ChrgitmLv == "2" {
  20686. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20687. }
  20688. if item.ChrgitmLv == "3" {
  20689. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20690. }
  20691. }
  20692. }
  20693. var iteminfoStructs []service.IteminfoStruct
  20694. if bedCostTotal != 0 {
  20695. iteminfo.MedChrgitm = "01"
  20696. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20697. iteminfo.Amt = bedCostTotal
  20698. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20699. iteminfo.ClabAmt = bed_clab_amt
  20700. iteminfo.OthAmt = bed_other_amt
  20701. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20702. }
  20703. if checkCostTotal != 0 {
  20704. iteminfo.MedChrgitm = "03"
  20705. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20706. iteminfo.Amt = checkCostTotal
  20707. iteminfo.ClaaSumfee = check_claa_sunmfee
  20708. iteminfo.ClabAmt = check_clab_amt
  20709. iteminfo.OthAmt = check_other_amt
  20710. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20711. }
  20712. if laboratoryCostTotal != 0 {
  20713. iteminfo.MedChrgitm = "04"
  20714. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20715. iteminfo.Amt = laboratoryCostTotal
  20716. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20717. iteminfo.ClabAmt = laboratory_clab_amt
  20718. iteminfo.OthAmt = laboratory_other_amt
  20719. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20720. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20721. }
  20722. if treatCostTotal != 0 {
  20723. iteminfo.MedChrgitm = "05"
  20724. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20725. iteminfo.Amt = treatCostTotal
  20726. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20727. iteminfo.ClabAmt = treat_clab_amt
  20728. iteminfo.OthAmt = treat_other_amt
  20729. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20730. //(struct4101.IteminfoStruct, iteminfo)
  20731. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20732. }
  20733. if operationCostTotal != 0 {
  20734. iteminfo.MedChrgitm = "06"
  20735. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20736. iteminfo.Amt = operationCostTotal
  20737. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20738. iteminfo.ClabAmt = operation_clab_amt
  20739. iteminfo.OthAmt = operation_other_amt
  20740. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20741. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20742. }
  20743. if materialCostTotal != 0 {
  20744. iteminfo.MedChrgitm = "08"
  20745. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20746. iteminfo.Amt = materialCostTotal
  20747. iteminfo.ClaaSumfee = material_claa_sunmfee
  20748. iteminfo.ClabAmt = material_clab_amt
  20749. iteminfo.OthAmt = material_other_amt
  20750. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20751. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20752. }
  20753. if westernMedicineCostTotal != 0 {
  20754. iteminfo.MedChrgitm = "09"
  20755. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20756. iteminfo.Amt = westernMedicineCostTotal
  20757. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20758. iteminfo.ClabAmt = westernMedicine_clab_amt
  20759. iteminfo.OthAmt = westernMedicine_other_amt
  20760. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20761. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20762. }
  20763. if chineseTraditionalMedicineCostTotal != 0 {
  20764. iteminfo.MedChrgitm = "11"
  20765. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20766. iteminfo.Amt = westernMedicineCostTotal
  20767. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20768. iteminfo.ClabAmt = westernMedicine_clab_amt
  20769. iteminfo.OthAmt = westernMedicine_other_amt
  20770. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20771. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20772. }
  20773. if otherCostTotal != 0 {
  20774. iteminfo.MedChrgitm = "14"
  20775. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20776. iteminfo.Amt = otherCostTotal
  20777. iteminfo.ClaaSumfee = other_claa_sunmfee
  20778. iteminfo.ClabAmt = other_clab_amt
  20779. iteminfo.OthAmt = other_other_amt
  20780. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20781. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20782. }
  20783. struct4101.IteminfoStruct = iteminfoStructs
  20784. struct4101.Ntly = "中国"
  20785. struct4101.AdmCaty = "A03.06"
  20786. struct4101.DoctorName = doctor.UserName
  20787. struct4101.DoctorCode = doctor.DoctorNumber
  20788. var res ResultSeventeen
  20789. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20790. struct4101.BillCode = order.Number
  20791. struct4101.BillNo = order.SetlId
  20792. var resOther ResultSeventeenOther
  20793. var pp models.PublicParams
  20794. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20795. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20796. pp.FixmedinsName = miConfig.OrgName
  20797. pp.FixmedinsCode = miConfig.Code
  20798. pp.RequestUrl = miConfig.Url
  20799. pp.Cainfo = miConfig.Cainfo
  20800. pp.SecretKey = miConfig.SecretKey
  20801. pp.AccessKey = miConfig.AccessKey
  20802. pp.OpterName = curRoles.UserName
  20803. client := &http.Client{}
  20804. var req *http.Request
  20805. data := make(map[string]interface{})
  20806. data["struct4101"] = struct4101
  20807. data["pp"] = pp
  20808. bytesData, _ := json.Marshal(data)
  20809. if miConfig.MdtrtareaAdmvs == "320830" {
  20810. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20811. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20812. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20813. } else {
  20814. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20815. }
  20816. resp, _ := client.Do(req)
  20817. defer resp.Body.Close()
  20818. body, ioErr := ioutil.ReadAll(resp.Body)
  20819. if ioErr != nil {
  20820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20822. return
  20823. }
  20824. var respJSON map[string]interface{}
  20825. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20828. return
  20829. }
  20830. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20831. userJSONBytes, _ := json.Marshal(respJSON)
  20832. fmt.Println("log")
  20833. fmt.Println(string(userJSONBytes))
  20834. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20835. utils.ErrorLog("解析失败:%v", err)
  20836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20837. return
  20838. }
  20839. res.InfRefmsgid = resOther.InfRefmsgid
  20840. res.Output = resOther.Output
  20841. res.ErrMsg = resOther.ErrMsg
  20842. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20843. res.Infcode = infocode
  20844. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20845. var pp models.PublicParams
  20846. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20847. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20848. pp.FixmedinsName = miConfig.OrgName
  20849. pp.FixmedinsCode = miConfig.Code
  20850. pp.RequestUrl = miConfig.Url
  20851. pp.Cainfo = miConfig.Cainfo
  20852. pp.SecretKey = miConfig.SecretKey
  20853. pp.AccessKey = miConfig.AccessKey
  20854. pp.OpterName = curRoles.UserName
  20855. result, _ := service.Jxyb4101(struct4101, pp)
  20856. var dat map[string]interface{}
  20857. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20858. fmt.Println(dat)
  20859. } else {
  20860. fmt.Println(err)
  20861. }
  20862. userJSONBytes, _ := json.Marshal(dat)
  20863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20864. utils.ErrorLog("解析失败:%v", err)
  20865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20866. return
  20867. }
  20868. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20869. var pp models.PublicParams
  20870. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20871. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20872. pp.FixmedinsName = miConfig.OrgName
  20873. pp.FixmedinsCode = miConfig.Code
  20874. pp.RequestUrl = miConfig.Url
  20875. pp.Cainfo = miConfig.Cainfo
  20876. pp.SecretKey = miConfig.SecretKey
  20877. pp.AccessKey = miConfig.AccessKey
  20878. pp.OpterName = curRoles.UserName
  20879. result, _ := service.Jxyb4101(struct4101, pp)
  20880. var dat map[string]interface{}
  20881. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20882. fmt.Println(dat)
  20883. } else {
  20884. fmt.Println(err)
  20885. }
  20886. userJSONBytes, _ := json.Marshal(dat)
  20887. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20888. utils.ErrorLog("解析失败:%v", err)
  20889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20890. return
  20891. }
  20892. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20893. var pp models.PublicParams
  20894. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20895. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20896. pp.FixmedinsName = miConfig.OrgName
  20897. pp.FixmedinsCode = miConfig.Code
  20898. pp.RequestUrl = miConfig.Url
  20899. pp.Cainfo = miConfig.Cainfo
  20900. pp.SecretKey = miConfig.SecretKey
  20901. pp.AccessKey = miConfig.AccessKey
  20902. pp.OpterName = curRoles.UserName
  20903. result, _ := service.Jxyb4101(struct4101, pp)
  20904. var dat map[string]interface{}
  20905. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20906. fmt.Println(dat)
  20907. } else {
  20908. fmt.Println(err)
  20909. }
  20910. userJSONBytes, _ := json.Marshal(dat)
  20911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20912. utils.ErrorLog("解析失败:%v", err)
  20913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20914. return
  20915. }
  20916. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20917. var pp models.PublicParams
  20918. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20919. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20920. pp.FixmedinsName = miConfig.OrgName
  20921. pp.FixmedinsCode = miConfig.Code
  20922. pp.RequestUrl = miConfig.Url
  20923. pp.Cainfo = miConfig.Cainfo
  20924. pp.SecretKey = miConfig.SecretKey
  20925. pp.AccessKey = miConfig.AccessKey
  20926. pp.OpterName = curRoles.UserName
  20927. result, _ := service.Hnyb4101(struct4101, pp)
  20928. var dat map[string]interface{}
  20929. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20930. fmt.Println(dat)
  20931. } else {
  20932. fmt.Println(err)
  20933. }
  20934. userJSONBytes, _ := json.Marshal(dat)
  20935. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20936. utils.ErrorLog("解析失败:%v", err)
  20937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20938. return
  20939. }
  20940. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20941. var resOther ResultSeventeenOther
  20942. var pp models.PublicParams
  20943. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20944. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20945. pp.FixmedinsName = miConfig.OrgName
  20946. pp.FixmedinsCode = miConfig.Code
  20947. pp.RequestUrl = miConfig.Url
  20948. pp.Cainfo = miConfig.Cainfo
  20949. pp.SecretKey = miConfig.SecretKey
  20950. pp.AccessKey = miConfig.AccessKey
  20951. pp.OpterName = curRoles.UserName
  20952. client := &http.Client{}
  20953. var req *http.Request
  20954. data := make(map[string]interface{})
  20955. data["struct4101"] = struct4101
  20956. data["pp"] = pp
  20957. bytesData, _ := json.Marshal(data)
  20958. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20959. resp, _ := client.Do(req)
  20960. defer resp.Body.Close()
  20961. body, ioErr := ioutil.ReadAll(resp.Body)
  20962. if ioErr != nil {
  20963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20965. return
  20966. }
  20967. var respJSON map[string]interface{}
  20968. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20971. return
  20972. }
  20973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20974. userJSONBytes, _ := json.Marshal(respJSON)
  20975. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20976. utils.ErrorLog("解析失败:%v", err)
  20977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20978. return
  20979. }
  20980. res.InfRefmsgid = resOther.InfRefmsgid
  20981. res.Output = resOther.Output
  20982. res.ErrMsg = resOther.ErrMsg
  20983. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20984. res.Infcode = infocode
  20985. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20986. var pp models.PublicParams
  20987. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20988. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20989. pp.FixmedinsName = miConfig.OrgName
  20990. pp.FixmedinsCode = miConfig.Code
  20991. pp.RequestUrl = miConfig.Url
  20992. pp.Cainfo = miConfig.Cainfo
  20993. pp.SecretKey = miConfig.SecretKey
  20994. pp.AccessKey = miConfig.AccessKey
  20995. pp.OpterName = curRoles.UserName
  20996. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20997. fmt.Println(requestLog)
  20998. fmt.Println(errMsgLog)
  20999. saveLog(result, requestLog, "4101a", "上传清单")
  21000. var dat map[string]interface{}
  21001. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21002. fmt.Println(dat)
  21003. } else {
  21004. fmt.Println(err)
  21005. }
  21006. userJSONBytes, _ := json.Marshal(dat)
  21007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21008. utils.ErrorLog("解析失败:%v", err)
  21009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21010. return
  21011. }
  21012. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21013. var pp models.PublicParams
  21014. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21015. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21016. pp.FixmedinsName = miConfig.OrgName
  21017. pp.FixmedinsCode = miConfig.Code
  21018. pp.RequestUrl = miConfig.Url
  21019. pp.Cainfo = miConfig.Cainfo
  21020. pp.SecretKey = miConfig.SecretKey
  21021. pp.AccessKey = miConfig.AccessKey
  21022. pp.OpterName = curRoles.UserName
  21023. client := &http.Client{}
  21024. var req *http.Request
  21025. data := make(map[string]interface{})
  21026. data["struct4101"] = struct4101
  21027. data["pp"] = pp
  21028. bytesData, _ := json.Marshal(data)
  21029. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  21030. resp, _ := client.Do(req)
  21031. defer resp.Body.Close()
  21032. body, ioErr := ioutil.ReadAll(resp.Body)
  21033. if ioErr != nil {
  21034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21036. return
  21037. }
  21038. var respJSON map[string]interface{}
  21039. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21042. return
  21043. }
  21044. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21045. userJSONBytes, _ := json.Marshal(respJSON)
  21046. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21047. utils.ErrorLog("解析失败:%v", err)
  21048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21049. return
  21050. }
  21051. } else {
  21052. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21053. var dat map[string]interface{}
  21054. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21055. fmt.Println(dat)
  21056. } else {
  21057. fmt.Println(err)
  21058. }
  21059. userJSONBytes, _ := json.Marshal(dat)
  21060. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21061. utils.ErrorLog("解析失败:%v", err)
  21062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21063. return
  21064. }
  21065. }
  21066. if res.Infcode != 0 {
  21067. c.ServeSuccessJSON(map[string]interface{}{
  21068. "failed_code": -10,
  21069. "msg": res.ErrMsg,
  21070. })
  21071. return
  21072. } else {
  21073. //order.FaPiaoNumber = zero
  21074. //order.FaPiaoCode = last_order.FaPiaoCode
  21075. //service.UpdateOrder(order)
  21076. hisFundSettleListResult := &models.HisFundSettleListResult{
  21077. Number: res.Output.SetlListId,
  21078. Status: 1,
  21079. Ctime: time.Now().Unix(),
  21080. Mtime: time.Now().Unix(),
  21081. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21082. IsUpload: 1,
  21083. OrderId: order_id,
  21084. }
  21085. service.CreateUploadRecord(hisFundSettleListResult)
  21086. c.ServeSuccessJSON(map[string]interface{}{
  21087. "msg": "上传成功",
  21088. "result": hisFundSettleListResult,
  21089. })
  21090. return
  21091. }
  21092. }
  21093. func (c *HisApiController) GetSettleListHospital() {
  21094. order_id, _ := c.GetInt64("order_id")
  21095. admin_user_id, _ := c.GetInt64("admin_user_id")
  21096. order, _ := service.GetHisOrderByIDTwo(order_id)
  21097. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21098. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  21099. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21100. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  21101. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21102. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21103. if order.ID == 0 {
  21104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21105. return
  21106. }
  21107. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  21108. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  21109. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  21110. fmt.Println(count)
  21111. var zero string
  21112. number := count + 1
  21113. if number >= 1000 {
  21114. zero = "0000" + strconv.FormatInt(number, 10)
  21115. } else if number >= 10000 {
  21116. zero = "000" + strconv.FormatInt(number, 10)
  21117. } else if number >= 100000 {
  21118. zero = "00" + strconv.FormatInt(number, 10)
  21119. } else if number >= 1000000 {
  21120. zero = "0" + strconv.FormatInt(number, 10)
  21121. } else {
  21122. zero = strconv.FormatInt(number, 10)
  21123. }
  21124. fmt.Println(zero)
  21125. struct4101 := service.Struct4101{
  21126. PsnNo: order.PsnNo,
  21127. MdtrtId: order.MdtrtId,
  21128. SetlId: order.SetlId,
  21129. PsnName: order.PsnName,
  21130. Gend: order.Gend,
  21131. Brdy: his.Brdy,
  21132. Age: int64(order.Age),
  21133. Naty: order.Naty,
  21134. PatnCertType: "01",
  21135. Certno: order.Certno,
  21136. Prfs: "90",
  21137. ConerName: roles[0].UserName,
  21138. PatnRlts: "99",
  21139. ConerAddr: miConfig.OrgName,
  21140. ConerTel: admin.Mobile,
  21141. HiType: order.Insutype,
  21142. Insuplc: miConfig.InsuplcAdmdvs,
  21143. MaindiagFlag: "1",
  21144. BillCode: order.SetlId,
  21145. BillNo: order.SetlId,
  21146. BizSn: order.Number,
  21147. PsnSelfPay: order.PsnPartAmt,
  21148. PsnOwnPay: order.PsnPartAmt,
  21149. AcctPay: order.AcctPay,
  21150. PsnCashpay: order.PsnCashPay,
  21151. HiPaymtd: "1",
  21152. Hsorg: miConfig.InsuplcAdmdvs,
  21153. HsorgOpter: miConfig.InsuplcAdmdvs,
  21154. MedinsFillPsn: curRoles.UserName,
  21155. MedinsFillDept: depart.Name,
  21156. IptMedType: "2",
  21157. AdmTime: his.InHosptialTime,
  21158. AdmEndTime: his.OutHosptialTime,
  21159. }
  21160. struct4101.SetlBegnDate = order.SetlTime
  21161. struct4101.SetlEndDate = order.SetlTime
  21162. //var rf []CustomFundPay
  21163. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  21164. //
  21165. //var tempFunPays []service.CustomStruct
  21166. //for _, item := range rf {
  21167. // var tempFunPay service.CustomStruct
  21168. // tempFunPay.FundPayamt = item.FundPayamt
  21169. // tempFunPay.FundPayType = item.FundPayType
  21170. // tempFunPays = append(tempFunPays, tempFunPay)
  21171. //}
  21172. //struct4101.CustomStruct = tempFunPays
  21173. var tempDiaginfos []service.DiaginfoStructTwo
  21174. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21175. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21176. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  21177. //for _, item := range infos {
  21178. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  21179. //}
  21180. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  21181. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  21182. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21183. fmt.Println(diagnosis_ids_arr)
  21184. if order.UserOrgId == 10210 {
  21185. var diagnosis_ids_arr_two []int64
  21186. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  21187. var config []*models.HisXtDiagnoseConfig
  21188. for _, id := range diagnosis_ids_arr_two {
  21189. //id, _ := strconv.ParseInt(item, 10, 64)
  21190. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21191. if diagnosisConfig.ID > 0 {
  21192. config = append(config, &diagnosisConfig)
  21193. }
  21194. }
  21195. for index, item := range config {
  21196. if item.ID > 0 {
  21197. if index == 0 {
  21198. var tempDiaginfo service.DiaginfoStructTwo
  21199. tempDiaginfo.DiagCode = item.CountryCode
  21200. tempDiaginfo.DiagName = item.CountryContentName
  21201. tempDiaginfo.DiagType = "1"
  21202. tempDiaginfo.MaindiagFlag = "1"
  21203. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21204. } else {
  21205. var tempDiaginfo service.DiaginfoStructTwo
  21206. tempDiaginfo.DiagCode = item.CountryCode
  21207. tempDiaginfo.DiagName = item.CountryContentName
  21208. tempDiaginfo.DiagType = "1"
  21209. tempDiaginfo.MaindiagFlag = "0"
  21210. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21211. }
  21212. }
  21213. }
  21214. struct4101.Diseinfo = tempDiaginfos
  21215. } else {
  21216. var config []*models.HisXtDiagnoseConfig
  21217. for _, item := range diagnosis_ids_arr {
  21218. id, _ := strconv.ParseInt(item, 10, 64)
  21219. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21220. if diagnosisConfig.ID > 0 {
  21221. config = append(config, &diagnosisConfig)
  21222. }
  21223. }
  21224. for index, item := range config {
  21225. if item.ID > 0 {
  21226. if index == 0 {
  21227. var tempDiaginfo service.DiaginfoStructTwo
  21228. tempDiaginfo.DiagCode = item.CountryCode
  21229. tempDiaginfo.DiagName = item.CountryContentName
  21230. tempDiaginfo.DiagType = "1"
  21231. tempDiaginfo.MaindiagFlag = "1"
  21232. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21233. } else {
  21234. var tempDiaginfo service.DiaginfoStructTwo
  21235. tempDiaginfo.DiagCode = item.CountryCode
  21236. tempDiaginfo.DiagName = item.CountryContentName
  21237. tempDiaginfo.DiagType = "1"
  21238. tempDiaginfo.MaindiagFlag = "0"
  21239. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21240. }
  21241. }
  21242. }
  21243. struct4101.Diseinfo = tempDiaginfos
  21244. }
  21245. sickConfigTwo, _ := service.FindSickById(his.SickType)
  21246. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21247. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21248. tempOpspdiseinfo2.OprnOprtCode = ""
  21249. tempOpspdiseinfo2.OprnOprtName = ""
  21250. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21251. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21252. var iteminfo service.IteminfoStruct
  21253. var bedCostTotal float64 = 0 //床位总费
  21254. var bedCostSelfTotal float64 = 0 //床位自费
  21255. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21256. var operationCostTotal float64 = 0 //手术费
  21257. var operationCostSelfTotal float64 = 0 //手术费
  21258. var operationCostPartSelfTotal float64 = 0 //手术费
  21259. var otherCostTotal float64 = 0 //其他费用
  21260. var otherCostSelfTotal float64 = 0 //其他费用
  21261. var otherCostPartSelfTotal float64 = 0 //其他费用
  21262. var materialCostTotal float64 = 0 //材料费
  21263. var materialCostSelfTotal float64 = 0 //材料费
  21264. var materialCostPartSelfTotal float64 = 0 //材料费
  21265. var westernMedicineCostTotal float64 = 0 //西药费
  21266. var westernMedicineCostSelfTotal float64 = 0 //西药费
  21267. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21268. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21269. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21270. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21271. var checkCostTotal float64 = 0 //检查费
  21272. var checkCostSelfTotal float64 = 0 //检查费
  21273. var checkCostPartSelfTotal float64 = 0 //检查费
  21274. var laboratoryCostTotal float64 = 0 //化验费
  21275. var laboratoryCostSelfTotal float64 = 0 //化验费
  21276. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21277. var treatCostTotal float64 = 0 //治疗费用
  21278. var treatCostSelfTotal float64 = 0 //治疗费用
  21279. var treatCostPartSelfTotal float64 = 0 //治疗费用
  21280. decimal.DivisionPrecision = 2
  21281. var bed_fulamt_ownpay_amt float64 = 0
  21282. var operation_fulamt_ownpay_amt float64 = 0
  21283. var other_fulamt_ownpay_amt float64 = 0
  21284. var westernMedicine_fulamt_ownpay_amt float64 = 0
  21285. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21286. var check_fulamt_ownpay_amt float64 = 0
  21287. var material_fulamt_ownpay_amt float64 = 0
  21288. var laboratory_fulamt_ownpay_amt float64 = 0
  21289. var treat_fulamt_ownpay_amt float64 = 0
  21290. var bed_claa_sunmfee float64 = 0
  21291. var bed_clab_amt float64 = 0
  21292. var bed_other_amt float64 = 0
  21293. var operation_claa_sunmfee float64 = 0
  21294. var operation_clab_amt float64 = 0
  21295. var operation_other_amt float64 = 0
  21296. var other_claa_sunmfee float64 = 0
  21297. var other_clab_amt float64 = 0
  21298. var other_other_amt float64 = 0
  21299. var westernMedicine_claa_sunmfee float64 = 0
  21300. var westernMedicine_clab_amt float64 = 0
  21301. var westernMedicine_other_amt float64 = 0
  21302. var chineseTraditional_claa_sunmfee float64 = 0
  21303. var chineseTraditional_clab_amt float64 = 0
  21304. var chineseTraditional_other_amt float64 = 0
  21305. var check_claa_sunmfee float64 = 0
  21306. var check_clab_amt float64 = 0
  21307. var check_other_amt float64 = 0
  21308. var material_claa_sunmfee float64 = 0
  21309. var material_clab_amt float64 = 0
  21310. var material_other_amt float64 = 0
  21311. var laboratory_claa_sunmfee float64 = 0
  21312. var laboratory_clab_amt float64 = 0
  21313. var laboratory_other_amt float64 = 0
  21314. var treat_claa_sunmfee float64 = 0
  21315. var treat_clab_amt float64 = 0
  21316. var treat_other_amt float64 = 0
  21317. for _, item := range order.HisOrderInfo {
  21318. if item.MedChrgitmType == "01" { //床位费
  21319. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21320. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21321. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21322. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21323. if item.ChrgitmLv == "1" {
  21324. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21325. }
  21326. if item.ChrgitmLv == "2" {
  21327. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21328. }
  21329. if item.ChrgitmLv == "3" {
  21330. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21331. }
  21332. }
  21333. if item.MedChrgitmType == "03" { //检查费
  21334. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21335. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21336. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21337. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21338. if item.ChrgitmLv == "1" {
  21339. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21340. }
  21341. if item.ChrgitmLv == "2" {
  21342. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21343. }
  21344. if item.ChrgitmLv == "3" {
  21345. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21346. }
  21347. }
  21348. if item.MedChrgitmType == "04" { //化验费
  21349. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21350. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21351. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21352. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21353. if item.ChrgitmLv == "1" {
  21354. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21355. }
  21356. if item.ChrgitmLv == "2" {
  21357. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21358. }
  21359. if item.ChrgitmLv == "3" {
  21360. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21361. }
  21362. }
  21363. if item.MedChrgitmType == "05" { //治疗费
  21364. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21365. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21366. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21367. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21368. if item.ChrgitmLv == "1" {
  21369. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21370. }
  21371. if item.ChrgitmLv == "2" {
  21372. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21373. }
  21374. if item.ChrgitmLv == "3" {
  21375. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21376. }
  21377. }
  21378. if item.MedChrgitmType == "06" { //手术费
  21379. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21380. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21381. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21382. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21383. if item.ChrgitmLv == "1" {
  21384. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21385. }
  21386. if item.ChrgitmLv == "2" {
  21387. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21388. }
  21389. if item.ChrgitmLv == "3" {
  21390. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21391. }
  21392. }
  21393. if item.MedChrgitmType == "08" { //材料费
  21394. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21395. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21396. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21397. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21398. if item.ChrgitmLv == "1" {
  21399. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21400. }
  21401. if item.ChrgitmLv == "2" {
  21402. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21403. }
  21404. if item.ChrgitmLv == "3" {
  21405. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21406. }
  21407. }
  21408. if item.MedChrgitmType == "09" { //西药费
  21409. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21410. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21411. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21412. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21413. if item.ChrgitmLv == "1" {
  21414. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21415. }
  21416. if item.ChrgitmLv == "2" {
  21417. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21418. }
  21419. if item.ChrgitmLv == "3" {
  21420. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21421. }
  21422. }
  21423. if item.MedChrgitmType == "11" { //中成费
  21424. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21425. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21426. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21427. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21428. if item.ChrgitmLv == "1" {
  21429. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21430. }
  21431. if item.ChrgitmLv == "2" {
  21432. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21433. }
  21434. if item.ChrgitmLv == "3" {
  21435. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21436. }
  21437. }
  21438. if item.MedChrgitmType == "14" { //其他费
  21439. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21440. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21441. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21442. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21443. if item.ChrgitmLv == "1" {
  21444. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21445. }
  21446. if item.ChrgitmLv == "2" {
  21447. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21448. }
  21449. if item.ChrgitmLv == "3" {
  21450. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21451. }
  21452. }
  21453. }
  21454. var iteminfoStructs []service.IteminfoStruct
  21455. if bedCostTotal != 0 {
  21456. iteminfo.MedChrgitm = "01"
  21457. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21458. iteminfo.Amt = bedCostTotal
  21459. iteminfo.ClaaSumfee = bed_claa_sunmfee
  21460. iteminfo.ClabAmt = bed_clab_amt
  21461. iteminfo.OthAmt = bed_other_amt
  21462. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21463. }
  21464. if checkCostTotal != 0 {
  21465. iteminfo.MedChrgitm = "03"
  21466. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21467. iteminfo.Amt = checkCostTotal
  21468. iteminfo.ClaaSumfee = check_claa_sunmfee
  21469. iteminfo.ClabAmt = check_clab_amt
  21470. iteminfo.OthAmt = check_other_amt
  21471. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21472. }
  21473. if laboratoryCostTotal != 0 {
  21474. iteminfo.MedChrgitm = "04"
  21475. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21476. iteminfo.Amt = laboratoryCostTotal
  21477. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21478. iteminfo.ClabAmt = laboratory_clab_amt
  21479. iteminfo.OthAmt = laboratory_other_amt
  21480. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21481. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21482. }
  21483. if treatCostTotal != 0 {
  21484. iteminfo.MedChrgitm = "05"
  21485. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21486. iteminfo.Amt = treatCostTotal
  21487. iteminfo.ClaaSumfee = treat_claa_sunmfee
  21488. iteminfo.ClabAmt = treat_clab_amt
  21489. iteminfo.OthAmt = treat_other_amt
  21490. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21491. //(struct4101.IteminfoStruct, iteminfo)
  21492. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21493. }
  21494. if operationCostTotal != 0 {
  21495. iteminfo.MedChrgitm = "06"
  21496. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21497. iteminfo.Amt = operationCostTotal
  21498. iteminfo.ClaaSumfee = operation_claa_sunmfee
  21499. iteminfo.ClabAmt = operation_clab_amt
  21500. iteminfo.OthAmt = operation_other_amt
  21501. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21502. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21503. }
  21504. if materialCostTotal != 0 {
  21505. iteminfo.MedChrgitm = "08"
  21506. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21507. iteminfo.Amt = materialCostTotal
  21508. iteminfo.ClaaSumfee = material_claa_sunmfee
  21509. iteminfo.ClabAmt = material_clab_amt
  21510. iteminfo.OthAmt = material_other_amt
  21511. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21512. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21513. }
  21514. if westernMedicineCostTotal != 0 {
  21515. iteminfo.MedChrgitm = "09"
  21516. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21517. iteminfo.Amt = westernMedicineCostTotal
  21518. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21519. iteminfo.ClabAmt = westernMedicine_clab_amt
  21520. iteminfo.OthAmt = westernMedicine_other_amt
  21521. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21522. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21523. }
  21524. if chineseTraditionalMedicineCostTotal != 0 {
  21525. iteminfo.MedChrgitm = "11"
  21526. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21527. iteminfo.Amt = westernMedicineCostTotal
  21528. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21529. iteminfo.ClabAmt = westernMedicine_clab_amt
  21530. iteminfo.OthAmt = westernMedicine_other_amt
  21531. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21532. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21533. }
  21534. if otherCostTotal != 0 {
  21535. iteminfo.MedChrgitm = "14"
  21536. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21537. iteminfo.Amt = otherCostTotal
  21538. iteminfo.ClaaSumfee = other_claa_sunmfee
  21539. iteminfo.ClabAmt = other_clab_amt
  21540. iteminfo.OthAmt = other_other_amt
  21541. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21542. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21543. }
  21544. struct4101.IteminfoStruct = iteminfoStructs
  21545. struct4101.Ntly = "中国"
  21546. struct4101.AdmCaty = "A03.06"
  21547. var resOther ResultSeventeenOther
  21548. var res ResultSeventeen
  21549. if miConfig.MdtrtareaAdmvs == "150499" {
  21550. var pp models.PublicParams
  21551. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21552. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21553. pp.FixmedinsName = miConfig.OrgName
  21554. pp.FixmedinsCode = miConfig.Code
  21555. pp.RequestUrl = miConfig.Url
  21556. pp.Cainfo = miConfig.Cainfo
  21557. pp.SecretKey = miConfig.SecretKey
  21558. pp.AccessKey = miConfig.AccessKey
  21559. pp.OpterName = curRoles.UserName
  21560. client := &http.Client{}
  21561. var req *http.Request
  21562. data := make(map[string]interface{})
  21563. data["struct4101"] = struct4101
  21564. data["pp"] = pp
  21565. bytesData, _ := json.Marshal(data)
  21566. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  21567. resp, _ := client.Do(req)
  21568. defer resp.Body.Close()
  21569. body, ioErr := ioutil.ReadAll(resp.Body)
  21570. if ioErr != nil {
  21571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21573. return
  21574. }
  21575. var respJSON map[string]interface{}
  21576. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21579. return
  21580. }
  21581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21582. userJSONBytes, _ := json.Marshal(respJSON)
  21583. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  21584. utils.ErrorLog("解析失败:%v", err)
  21585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21586. return
  21587. }
  21588. res.InfRefmsgid = resOther.InfRefmsgid
  21589. res.Output = resOther.Output
  21590. res.ErrMsg = resOther.ErrMsg
  21591. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  21592. res.Infcode = infocode
  21593. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21594. var pp models.PublicParams
  21595. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21596. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21597. pp.FixmedinsName = miConfig.OrgName
  21598. pp.FixmedinsCode = miConfig.Code
  21599. pp.RequestUrl = miConfig.Url
  21600. pp.Cainfo = miConfig.Cainfo
  21601. pp.SecretKey = miConfig.SecretKey
  21602. pp.AccessKey = miConfig.AccessKey
  21603. pp.OpterName = curRoles.UserName
  21604. result, _ := service.Jxyb4101(struct4101, pp)
  21605. var dat map[string]interface{}
  21606. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21607. fmt.Println(dat)
  21608. } else {
  21609. fmt.Println(err)
  21610. }
  21611. userJSONBytes, _ := json.Marshal(dat)
  21612. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21613. utils.ErrorLog("解析失败:%v", err)
  21614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21615. return
  21616. }
  21617. } else if miConfig.MdtrtareaAdmvs == "361025" {
  21618. var pp models.PublicParams
  21619. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21620. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21621. pp.FixmedinsName = miConfig.OrgName
  21622. pp.FixmedinsCode = miConfig.Code
  21623. pp.RequestUrl = miConfig.Url
  21624. pp.Cainfo = miConfig.Cainfo
  21625. pp.SecretKey = miConfig.SecretKey
  21626. pp.AccessKey = miConfig.AccessKey
  21627. pp.OpterName = curRoles.UserName
  21628. result, _ := service.Jxyb4101(struct4101, pp)
  21629. var dat map[string]interface{}
  21630. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21631. fmt.Println(dat)
  21632. } else {
  21633. fmt.Println(err)
  21634. }
  21635. userJSONBytes, _ := json.Marshal(dat)
  21636. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21637. utils.ErrorLog("解析失败:%v", err)
  21638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21639. return
  21640. }
  21641. } else if miConfig.MdtrtareaAdmvs == "360100" {
  21642. var pp models.PublicParams
  21643. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21644. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21645. pp.FixmedinsName = miConfig.OrgName
  21646. pp.FixmedinsCode = miConfig.Code
  21647. pp.RequestUrl = miConfig.Url
  21648. pp.Cainfo = miConfig.Cainfo
  21649. pp.SecretKey = miConfig.SecretKey
  21650. pp.AccessKey = miConfig.AccessKey
  21651. pp.OpterName = curRoles.UserName
  21652. result, _ := service.Jxyb4101(struct4101, pp)
  21653. var dat map[string]interface{}
  21654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21655. fmt.Println(dat)
  21656. } else {
  21657. fmt.Println(err)
  21658. }
  21659. userJSONBytes, _ := json.Marshal(dat)
  21660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21661. utils.ErrorLog("解析失败:%v", err)
  21662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21663. return
  21664. }
  21665. } else {
  21666. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21667. var dat map[string]interface{}
  21668. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21669. fmt.Println(dat)
  21670. } else {
  21671. fmt.Println(err)
  21672. }
  21673. userJSONBytes, _ := json.Marshal(dat)
  21674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21675. utils.ErrorLog("解析失败:%v", err)
  21676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21677. return
  21678. }
  21679. }
  21680. if res.Infcode != 0 {
  21681. c.ServeSuccessJSON(map[string]interface{}{
  21682. "failed_code": -10,
  21683. "msg": res.ErrMsg,
  21684. })
  21685. return
  21686. } else {
  21687. if miConfig.MdtrtareaAdmvs != "150499" {
  21688. order.FaPiaoNumber = zero
  21689. order.FaPiaoCode = last_order.FaPiaoCode
  21690. service.UpdateOrder(order)
  21691. }
  21692. hisFundSettleListResult := &models.HisFundSettleListResult{
  21693. Number: res.Output.SetlListId,
  21694. Status: 1,
  21695. Ctime: time.Now().Unix(),
  21696. Mtime: time.Now().Unix(),
  21697. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21698. IsUpload: 1,
  21699. OrderId: order_id,
  21700. }
  21701. service.CreateUploadRecord(hisFundSettleListResult)
  21702. c.ServeSuccessJSON(map[string]interface{}{
  21703. "msg": "上传成功",
  21704. "result": hisFundSettleListResult,
  21705. })
  21706. return
  21707. }
  21708. }
  21709. //func (c *HisApiController) GetBatchSettleList() {
  21710. // orders, _ := service.GetAllHisOrder(10106)
  21711. // for _, item := range orders {
  21712. // order_id := item.ID
  21713. // order, _ := service.GetHisOrderByIDTwo(order_id)
  21714. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21715. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  21716. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21717. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  21718. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21719. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21720. //
  21721. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  21722. //
  21723. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  21724. //
  21725. // if order.ID == 0 {
  21726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21727. // return
  21728. // }
  21729. // if his.BalanceAccountsType == 2 {
  21730. // continue
  21731. // }
  21732. // struct4101 := service.Struct4101{
  21733. // PsnNo: order.PsnNo,
  21734. // MdtrtId: order.MdtrtId,
  21735. // SetlId: order.SetlId,
  21736. // PsnName: order.PsnName,
  21737. // Gend: order.Gend,
  21738. // Brdy: his.Brdy,
  21739. // Age: his.Age,
  21740. // Naty: order.Naty,
  21741. // PatnCertType: "01",
  21742. // Certno: order.Certno,
  21743. // Prfs: "90",
  21744. // ConerName: roles[0].UserName,
  21745. // PatnRlts: "99",
  21746. // ConerAddr: miConfig.OrgName,
  21747. // ConerTel: admin.Mobile,
  21748. // HiType: order.Insutype,
  21749. // Insuplc: his.InsuplcAdmdvs,
  21750. // MaindiagFlag: "1",
  21751. // BillCode: order.SetlId,
  21752. // BillNo: order.SetlId,
  21753. // BizSn: order.Number,
  21754. // PsnSelfPay: order.PsnPartAmt,
  21755. // PsnOwnPay: order.PsnPartAmt,
  21756. // AcctPay: order.AcctPay,
  21757. // PsnCashpay: order.PsnCashPay,
  21758. // HiPaymtd: "1",
  21759. // Hsorg: his.InsuplcAdmdvs,
  21760. // HsorgOpter: his.InsuplcAdmdvs,
  21761. // MedinsFillPsn: curRoles.UserName,
  21762. // MedinsFillDept: depart.Name,
  21763. // IptMedType: "2",
  21764. // }
  21765. // struct4101.SetlBegnDate = order.SetlTime
  21766. // struct4101.SetlEndDate = order.SetlTime
  21767. // //if order.SettleType == 1 {
  21768. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  21769. // // dateStr := t.Format("2006-01-02")
  21770. // // struct4101.SetlBegnDate = dateStr
  21771. // // struct4101.SetlEndDate = dateStr
  21772. // //} else {
  21773. // // t := time.Unix(int64(order.SettleStartTime), 0)
  21774. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  21775. // // dateStartStr := t.Format("2006-01-02")
  21776. // // dateEndStr := t2.Format("2006-01-02")
  21777. // // struct4101.SetlBegnDate = dateStartStr
  21778. // // struct4101.SetlEndDate = dateEndStr
  21779. // //}
  21780. //
  21781. // var rf []CustomFundPay
  21782. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  21783. //
  21784. // var tempFunPays []service.CustomStruct
  21785. // var tempFunPay610100 service.CustomStruct
  21786. //
  21787. // for _, item := range rf {
  21788. // if item.FundPayType == "610100" {
  21789. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  21790. // tempFunPay610100.FundPayType = item.FundPayType
  21791. // } else {
  21792. // var tempFunPay service.CustomStruct
  21793. // tempFunPay.FundPayamt = item.FundPayamt
  21794. // tempFunPay.FundPayType = item.FundPayType
  21795. // tempFunPays = append(tempFunPays, tempFunPay)
  21796. // }
  21797. // }
  21798. // tempFunPays = append(tempFunPays, tempFunPay610100)
  21799. // struct4101.CustomStruct = tempFunPays
  21800. //
  21801. // var tempDiaginfos []service.DiaginfoStructTwo
  21802. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21803. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21804. //
  21805. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21806. // var config []*models.HisXtDiagnoseConfig
  21807. // for _, item := range diagnosis_ids {
  21808. // id, _ := strconv.ParseInt(item, 10, 64)
  21809. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  21810. // config = append(config, &diagnosisConfig)
  21811. // }
  21812. //
  21813. // for index, item := range config {
  21814. // if index == 0 {
  21815. // var tempDiaginfo service.DiaginfoStructTwo
  21816. // tempDiaginfo.DiagCode = item.CountryCode
  21817. // tempDiaginfo.DiagName = item.CountryContentName
  21818. // tempDiaginfo.DiagType = "1"
  21819. // tempDiaginfo.MaindiagFlag = "1"
  21820. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21821. // } else {
  21822. //
  21823. // var tempDiaginfo service.DiaginfoStructTwo
  21824. // tempDiaginfo.DiagCode = item.CountryCode
  21825. // tempDiaginfo.DiagName = item.CountryContentName
  21826. // tempDiaginfo.DiagType = "2"
  21827. // tempDiaginfo.MaindiagFlag = "0"
  21828. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21829. // }
  21830. // }
  21831. // struct4101.Diseinfo = tempDiaginfos
  21832. //
  21833. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  21834. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21835. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21836. // tempOpspdiseinfo2.OprnOprtCode = ""
  21837. // tempOpspdiseinfo2.OprnOprtName = ""
  21838. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21839. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21840. //
  21841. // var iteminfo service.IteminfoStruct
  21842. //
  21843. // var bedCostTotal float64 = 0 //床位总费
  21844. // var bedCostSelfTotal float64 = 0 //床位自费
  21845. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21846. //
  21847. // var examineCostTotal float64 = 0 //诊查总费
  21848. // var examineCostSelfTotal float64 = 0 //诊查自费
  21849. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21850. //
  21851. // var nursingCostTotal float64 = 0 //护理总费
  21852. // var nursingCostSelfTotal float64 = 0 //护理自费
  21853. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21854. //
  21855. // var chineseMedicineCostTotal float64 = 0 //中成药
  21856. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21857. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21858. //
  21859. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21860. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21861. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21862. //
  21863. // var registerCostTotal float64 = 0 //一般诊疗费
  21864. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21865. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21866. //
  21867. // var operationCostTotal float64 = 0 //手术费
  21868. // var operationCostSelfTotal float64 = 0 //手术费
  21869. // var operationCostPartSelfTotal float64 = 0 //手术费
  21870. //
  21871. // var otherCostTotal float64 = 0 //其他费用
  21872. // var otherCostSelfTotal float64 = 0 //其他费用
  21873. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21874. //
  21875. // var materialCostTotal float64 = 0 //材料费
  21876. // var materialCostSelfTotal float64 = 0 //材料费
  21877. // var materialCostPartSelfTotal float64 = 0 //材料费
  21878. //
  21879. // var westernMedicineCostTotal float64 = 0 //西药费
  21880. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21881. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21882. //
  21883. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21884. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21885. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21886. //
  21887. // var checkCostTotal float64 = 0 //检查费
  21888. // var checkCostSelfTotal float64 = 0 //检查费
  21889. // var checkCostPartSelfTotal float64 = 0 //检查费
  21890. //
  21891. // var laboratoryCostTotal float64 = 0 //化验费
  21892. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21893. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21894. //
  21895. // var treatCostTotal float64 = 0 //治疗费用
  21896. // var treatCostSelfTotal float64 = 0 //治疗费用
  21897. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21898. //
  21899. // decimal.DivisionPrecision = 2
  21900. //
  21901. // var bed_fulamt_ownpay_amt float64 = 0
  21902. //
  21903. // var examine_fulamt_ownpay_amt float64 = 0
  21904. //
  21905. // var nursing_fulamt_ownpay_amt float64 = 0
  21906. //
  21907. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21908. //
  21909. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21910. //
  21911. // var register_fulamt_ownpay_amt float64 = 0
  21912. //
  21913. // var operation_fulamt_ownpay_amt float64 = 0
  21914. // var other_fulamt_ownpay_amt float64 = 0
  21915. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21916. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21917. // var check_fulamt_ownpay_amt float64 = 0
  21918. // var material_fulamt_ownpay_amt float64 = 0
  21919. // var laboratory_fulamt_ownpay_amt float64 = 0
  21920. // var treat_fulamt_ownpay_amt float64 = 0
  21921. //
  21922. // var bed_claa_sunmfee float64 = 0
  21923. // var bed_clab_amt float64 = 0
  21924. // var bed_other_amt float64 = 0
  21925. //
  21926. // var examine_claa_sunmfee float64 = 0
  21927. // var examine_clab_amt float64 = 0
  21928. // var examine_other_amt float64 = 0
  21929. //
  21930. // var nursing_claa_sunmfee float64 = 0
  21931. // var nursing_clab_amt float64 = 0
  21932. // var nursing_other_amt float64 = 0
  21933. //
  21934. // var chinese_medicine_claa_sunmfee float64 = 0
  21935. // var chinese_medicine_clab_amt float64 = 0
  21936. // var chinese_medicine_other_amt float64 = 0
  21937. //
  21938. // var commonly_treatment_claa_sunmfee float64 = 0
  21939. // var commonly_treatment_clab_amt float64 = 0
  21940. // var commonly_treatment_other_amt float64 = 0
  21941. //
  21942. // var operation_claa_sunmfee float64 = 0
  21943. // var operation_clab_amt float64 = 0
  21944. // var operation_other_amt float64 = 0
  21945. //
  21946. // var other_claa_sunmfee float64 = 0
  21947. // var other_clab_amt float64 = 0
  21948. // var other_other_amt float64 = 0
  21949. //
  21950. // var westernMedicine_claa_sunmfee float64 = 0
  21951. // var westernMedicine_clab_amt float64 = 0
  21952. // var westernMedicine_other_amt float64 = 0
  21953. //
  21954. // var chineseTraditional_claa_sunmfee float64 = 0
  21955. // var chineseTraditional_clab_amt float64 = 0
  21956. // var chineseTraditional_other_amt float64 = 0
  21957. //
  21958. // var check_claa_sunmfee float64 = 0
  21959. // var check_clab_amt float64 = 0
  21960. // var check_other_amt float64 = 0
  21961. //
  21962. // var material_claa_sunmfee float64 = 0
  21963. // var material_clab_amt float64 = 0
  21964. // var material_other_amt float64 = 0
  21965. //
  21966. // var laboratory_claa_sunmfee float64 = 0
  21967. // var laboratory_clab_amt float64 = 0
  21968. // var laboratory_other_amt float64 = 0
  21969. //
  21970. // var treat_claa_sunmfee float64 = 0
  21971. // var treat_clab_amt float64 = 0
  21972. // var treat_other_amt float64 = 0
  21973. //
  21974. // var register_claa_sunmfee float64 = 0
  21975. // var register_clab_amt float64 = 0
  21976. // var register_other_amt float64 = 0
  21977. //
  21978. // for _, item := range order.HisOrderInfo {
  21979. // if item.MedChrgitmType == "01" { //床位费
  21980. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21981. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21982. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21983. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21984. // if item.ChrgitmLv == "1" {
  21985. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21986. // }
  21987. // if item.ChrgitmLv == "2" {
  21988. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21989. //
  21990. // }
  21991. // if item.ChrgitmLv == "3" {
  21992. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21993. // }
  21994. //
  21995. // }
  21996. //
  21997. // if item.MedChrgitmType == "02" { //诊查
  21998. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21999. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22000. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22001. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22002. // if item.ChrgitmLv == "1" {
  22003. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22004. // }
  22005. // if item.ChrgitmLv == "2" {
  22006. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22007. //
  22008. // }
  22009. // if item.ChrgitmLv == "3" {
  22010. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22011. // }
  22012. //
  22013. // }
  22014. //
  22015. // if item.MedChrgitmType == "03" { //检查费
  22016. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22017. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22018. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22019. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22020. // if item.ChrgitmLv == "1" {
  22021. //
  22022. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22023. //
  22024. // }
  22025. // if item.ChrgitmLv == "2" {
  22026. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22027. //
  22028. // }
  22029. // if item.ChrgitmLv == "3" {
  22030. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22031. // }
  22032. // }
  22033. //
  22034. // if item.MedChrgitmType == "04" { //化验费
  22035. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22036. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22037. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22038. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22039. // if item.ChrgitmLv == "1" {
  22040. //
  22041. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22042. //
  22043. // }
  22044. // if item.ChrgitmLv == "2" {
  22045. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22046. //
  22047. // }
  22048. // if item.ChrgitmLv == "3" {
  22049. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22050. // }
  22051. // }
  22052. //
  22053. // if item.MedChrgitmType == "05" { //治疗费
  22054. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22055. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22056. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22057. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22058. // if item.ChrgitmLv == "1" {
  22059. //
  22060. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22061. //
  22062. // }
  22063. // if item.ChrgitmLv == "2" {
  22064. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22065. //
  22066. // }
  22067. // if item.ChrgitmLv == "3" {
  22068. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22069. // }
  22070. // }
  22071. //
  22072. // if item.MedChrgitmType == "06" { //手术费
  22073. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22074. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22075. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22076. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22077. //
  22078. // if item.ChrgitmLv == "1" {
  22079. //
  22080. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22081. //
  22082. // }
  22083. // if item.ChrgitmLv == "2" {
  22084. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22085. //
  22086. // }
  22087. // if item.ChrgitmLv == "3" {
  22088. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22089. // }
  22090. // }
  22091. //
  22092. // if item.MedChrgitmType == "07" { //手术费
  22093. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22094. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22095. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22096. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22097. //
  22098. // if item.ChrgitmLv == "1" {
  22099. //
  22100. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22101. //
  22102. // }
  22103. // if item.ChrgitmLv == "2" {
  22104. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22105. //
  22106. // }
  22107. // if item.ChrgitmLv == "3" {
  22108. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22109. // }
  22110. // }
  22111. //
  22112. // if item.MedChrgitmType == "08" { //材料费
  22113. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22114. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22115. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22116. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22117. // if item.ChrgitmLv == "1" {
  22118. //
  22119. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22120. //
  22121. // }
  22122. // if item.ChrgitmLv == "2" {
  22123. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22124. //
  22125. // }
  22126. // if item.ChrgitmLv == "3" {
  22127. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22128. // }
  22129. // }
  22130. // if item.MedChrgitmType == "09" { //西药费
  22131. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22132. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22133. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22134. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22135. // if item.ChrgitmLv == "1" {
  22136. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22137. // }
  22138. // if item.ChrgitmLv == "2" {
  22139. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22140. // }
  22141. // if item.ChrgitmLv == "3" {
  22142. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22143. // }
  22144. // }
  22145. // if item.MedChrgitmType == "10" { //中药饮片
  22146. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22147. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22148. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22149. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22150. // if item.ChrgitmLv == "1" {
  22151. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22152. // }
  22153. // if item.ChrgitmLv == "2" {
  22154. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22155. // }
  22156. // if item.ChrgitmLv == "3" {
  22157. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22158. // }
  22159. // }
  22160. //
  22161. // if item.MedChrgitmType == "11" { //中成费
  22162. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22163. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22164. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22165. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22166. // if item.ChrgitmLv == "1" {
  22167. //
  22168. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22169. //
  22170. // }
  22171. // if item.ChrgitmLv == "2" {
  22172. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22173. //
  22174. // }
  22175. // if item.ChrgitmLv == "3" {
  22176. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22177. // }
  22178. // }
  22179. //
  22180. // if item.MedChrgitmType == "12" { //中成费
  22181. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22182. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22183. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22184. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22185. // if item.ChrgitmLv == "1" {
  22186. //
  22187. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22188. //
  22189. // }
  22190. // if item.ChrgitmLv == "2" {
  22191. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22192. //
  22193. // }
  22194. // if item.ChrgitmLv == "3" {
  22195. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22196. // }
  22197. // }
  22198. //
  22199. // if item.MedChrgitmType == "13" { //中成费
  22200. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22201. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22202. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22203. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22204. // if item.ChrgitmLv == "1" {
  22205. //
  22206. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22207. //
  22208. // }
  22209. // if item.ChrgitmLv == "2" {
  22210. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22211. //
  22212. // }
  22213. // if item.ChrgitmLv == "3" {
  22214. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22215. // }
  22216. // }
  22217. //
  22218. // if item.MedChrgitmType == "14" { //其他费
  22219. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22220. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22221. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22222. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22223. // if item.ChrgitmLv == "1" {
  22224. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22225. //
  22226. // }
  22227. // if item.ChrgitmLv == "2" {
  22228. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22229. //
  22230. // }
  22231. // if item.ChrgitmLv == "3" {
  22232. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22233. // }
  22234. // }
  22235. //
  22236. // }
  22237. //
  22238. // var iteminfoStructs []service.IteminfoStruct
  22239. //
  22240. // if bedCostTotal != 0 {
  22241. // iteminfo.MedChrgitm = "01"
  22242. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22243. // iteminfo.Amt = bedCostTotal
  22244. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  22245. // iteminfo.ClabAmt = bed_clab_amt
  22246. // iteminfo.OthAmt = bed_other_amt
  22247. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22248. // }
  22249. //
  22250. // if examineCostTotal != 0 {
  22251. // iteminfo.MedChrgitm = "02"
  22252. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  22253. // iteminfo.Amt = examineCostTotal
  22254. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  22255. // iteminfo.ClabAmt = examine_clab_amt
  22256. // iteminfo.OthAmt = examine_other_amt
  22257. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22258. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22259. // }
  22260. //
  22261. // if checkCostTotal != 0 {
  22262. // iteminfo.MedChrgitm = "03"
  22263. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  22264. // iteminfo.Amt = checkCostTotal
  22265. // iteminfo.ClaaSumfee = check_claa_sunmfee
  22266. // iteminfo.ClabAmt = check_clab_amt
  22267. // iteminfo.OthAmt = check_other_amt
  22268. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22269. //
  22270. // }
  22271. //
  22272. // if laboratoryCostTotal != 0 {
  22273. // iteminfo.MedChrgitm = "04"
  22274. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  22275. // iteminfo.Amt = laboratoryCostTotal
  22276. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  22277. // iteminfo.ClabAmt = laboratory_clab_amt
  22278. // iteminfo.OthAmt = laboratory_other_amt
  22279. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22280. //
  22281. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22282. //
  22283. // }
  22284. //
  22285. // if treatCostTotal != 0 {
  22286. // iteminfo.MedChrgitm = "05"
  22287. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  22288. // iteminfo.Amt = treatCostTotal
  22289. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  22290. // iteminfo.ClabAmt = treat_clab_amt
  22291. // iteminfo.OthAmt = treat_other_amt
  22292. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22293. // //(struct4101.IteminfoStruct, iteminfo)
  22294. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22295. // }
  22296. //
  22297. // if operationCostTotal != 0 {
  22298. // iteminfo.MedChrgitm = "06"
  22299. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22300. // iteminfo.Amt = operationCostTotal
  22301. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  22302. // iteminfo.ClabAmt = operation_clab_amt
  22303. // iteminfo.OthAmt = operation_other_amt
  22304. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22305. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22306. // }
  22307. //
  22308. // if nursingCostTotal != 0 {
  22309. // iteminfo.MedChrgitm = "07"
  22310. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  22311. // iteminfo.Amt = nursingCostTotal
  22312. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  22313. // iteminfo.ClabAmt = nursing_clab_amt
  22314. // iteminfo.OthAmt = nursing_other_amt
  22315. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22316. // }
  22317. //
  22318. // if materialCostTotal != 0 {
  22319. // iteminfo.MedChrgitm = "08"
  22320. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  22321. // iteminfo.Amt = materialCostTotal
  22322. // iteminfo.ClaaSumfee = material_claa_sunmfee
  22323. // iteminfo.ClabAmt = material_clab_amt
  22324. // iteminfo.OthAmt = material_other_amt
  22325. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22326. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22327. // }
  22328. //
  22329. // if westernMedicineCostTotal != 0 {
  22330. // iteminfo.MedChrgitm = "09"
  22331. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22332. // iteminfo.Amt = westernMedicineCostTotal
  22333. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22334. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22335. // iteminfo.OthAmt = westernMedicine_other_amt
  22336. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22337. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22338. //
  22339. // }
  22340. //
  22341. // if chineseMedicineCostTotal != 0 {
  22342. // iteminfo.MedChrgitm = "10"
  22343. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  22344. // iteminfo.Amt = chineseMedicineCostTotal
  22345. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  22346. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  22347. // iteminfo.OthAmt = chinese_medicine_other_amt
  22348. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22349. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22350. //
  22351. // }
  22352. //
  22353. // if chineseTraditionalMedicineCostTotal != 0 {
  22354. // iteminfo.MedChrgitm = "11"
  22355. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22356. // iteminfo.Amt = westernMedicineCostTotal
  22357. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22358. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22359. // iteminfo.OthAmt = westernMedicine_other_amt
  22360. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22361. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22362. //
  22363. // }
  22364. //
  22365. // if commonlyTreatmentCostTotal != 0 {
  22366. // iteminfo.MedChrgitm = "12"
  22367. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  22368. // iteminfo.Amt = commonlyTreatmentCostTotal
  22369. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  22370. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  22371. // iteminfo.OthAmt = commonly_treatment_other_amt
  22372. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22373. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22374. //
  22375. // }
  22376. //
  22377. // if registerCostTotal != 0 {
  22378. // iteminfo.MedChrgitm = "13"
  22379. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  22380. // iteminfo.Amt = registerCostTotal
  22381. // iteminfo.ClaaSumfee = register_claa_sunmfee
  22382. // iteminfo.ClabAmt = register_clab_amt
  22383. // iteminfo.OthAmt = register_other_amt
  22384. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22385. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22386. //
  22387. // }
  22388. //
  22389. // if otherCostTotal != 0 {
  22390. // iteminfo.MedChrgitm = "14"
  22391. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  22392. // iteminfo.Amt = otherCostTotal
  22393. // iteminfo.ClaaSumfee = other_claa_sunmfee
  22394. // iteminfo.ClabAmt = other_clab_amt
  22395. // iteminfo.OthAmt = other_other_amt
  22396. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22397. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22398. //
  22399. // }
  22400. // struct4101.IteminfoStruct = iteminfoStructs
  22401. // time_arr := strings.Split(order.SetlTime, " ")
  22402. // struct4101.AdmTime = time_arr[0]
  22403. // struct4101.AdmEndTime = time_arr[0]
  22404. //
  22405. // struct4101.DoctorName = doctor.UserName
  22406. // struct4101.DoctorCode = doctor.DoctorNumber
  22407. //
  22408. // struct4101.Ntly = "中国"
  22409. // struct4101.AdmCaty = "A03.06"
  22410. // var res ResultSeventeen
  22411. // if miConfig.MdtrtareaAdmvs == "421300" {
  22412. // data := make(map[string]interface{})
  22413. // data["struct4101"] = struct4101
  22414. // data["secret_key"] = miConfig.SecretKey
  22415. // data["org_name"] = miConfig.OrgName
  22416. // data["opera"] = curRoles.UserName
  22417. // data["code"] = miConfig.Code
  22418. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22419. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22420. //
  22421. // client := &http.Client{}
  22422. // bytesData, _ := json.Marshal(data)
  22423. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22424. // resp, _ := client.Do(req)
  22425. // defer resp.Body.Close()
  22426. // body, ioErr := ioutil.ReadAll(resp.Body)
  22427. // if ioErr != nil {
  22428. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22429. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22430. // return
  22431. // }
  22432. // var respJSON map[string]interface{}
  22433. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22434. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22435. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22436. // return
  22437. // }
  22438. //
  22439. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22440. // userJSONBytes, _ := json.Marshal(respJSON)
  22441. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22442. // utils.ErrorLog("解析失败:%v", err)
  22443. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22444. // adminUser := c.GetAdminUserInfo()
  22445. // errlog := &models.HisOrderError{
  22446. // UserOrgId: adminUser.CurrentOrgId,
  22447. // Ctime: time.Now().Unix(),
  22448. // Mtime: time.Now().Unix(),
  22449. // ErrMsg: res.ErrMsg + "解析失败",
  22450. // Status: 1,
  22451. // PatientId: order_id,
  22452. // Stage: 10088,
  22453. // }
  22454. // service.CreateErrMsgLog(errlog)
  22455. // continue
  22456. // }
  22457. //
  22458. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  22459. // data := make(map[string]interface{})
  22460. // data["struct4101"] = struct4101
  22461. // data["secret_key"] = miConfig.SecretKey
  22462. // data["org_name"] = miConfig.OrgName
  22463. // data["opera"] = curRoles.UserName
  22464. // data["code"] = miConfig.Code
  22465. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22466. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22467. //
  22468. // client := &http.Client{}
  22469. // bytesData, _ := json.Marshal(data)
  22470. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22471. // resp, _ := client.Do(req)
  22472. // defer resp.Body.Close()
  22473. // body, ioErr := ioutil.ReadAll(resp.Body)
  22474. // if ioErr != nil {
  22475. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22477. // return
  22478. // }
  22479. // var respJSON map[string]interface{}
  22480. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22481. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22483. // return
  22484. // }
  22485. //
  22486. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22487. // userJSONBytes, _ := json.Marshal(respJSON)
  22488. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22489. // utils.ErrorLog("解析失败:%v", err)
  22490. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22491. // adminUser := c.GetAdminUserInfo()
  22492. // errlog := &models.HisOrderError{
  22493. // UserOrgId: adminUser.CurrentOrgId,
  22494. // Ctime: time.Now().Unix(),
  22495. // Mtime: time.Now().Unix(),
  22496. // ErrMsg: res.ErrMsg + "解析失败",
  22497. // Status: 1,
  22498. // PatientId: order_id,
  22499. // Stage: 10088,
  22500. // }
  22501. // service.CreateErrMsgLog(errlog)
  22502. // continue
  22503. // }
  22504. //
  22505. // } else {
  22506. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  22507. // fmt.Println(result)
  22508. //
  22509. // var dat map[string]interface{}
  22510. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22511. // fmt.Println(dat)
  22512. // } else {
  22513. // fmt.Println(err)
  22514. // }
  22515. // userJSONBytes, _ := json.Marshal(dat)
  22516. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22517. // utils.ErrorLog("解析失败:%v", err)
  22518. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22519. // adminUser := c.GetAdminUserInfo()
  22520. // errlog := &models.HisOrderError{
  22521. // UserOrgId: adminUser.CurrentOrgId,
  22522. // Ctime: time.Now().Unix(),
  22523. // Mtime: time.Now().Unix(),
  22524. // ErrMsg: res.ErrMsg + "解析失败",
  22525. // Status: 1,
  22526. // PatientId: order_id,
  22527. // Stage: 10106,
  22528. // }
  22529. // service.CreateErrMsgLog(errlog)
  22530. // continue
  22531. // }
  22532. // }
  22533. //
  22534. // if res.Infcode != 0 {
  22535. // adminUser := c.GetAdminUserInfo()
  22536. // errlog := &models.HisOrderError{
  22537. // UserOrgId: adminUser.CurrentOrgId,
  22538. // Ctime: time.Now().Unix(),
  22539. // Mtime: time.Now().Unix(),
  22540. // ErrMsg: res.ErrMsg,
  22541. // Status: 1,
  22542. // PatientId: order_id,
  22543. // Stage: 10106,
  22544. // }
  22545. // service.CreateErrMsgLog(errlog)
  22546. // continue
  22547. // } else {
  22548. // hisFundSettleListResult := &models.HisFundSettleListResult{
  22549. // Number: res.Output.SetlListId,
  22550. // Status: 1,
  22551. // Ctime: time.Now().Unix(),
  22552. // Mtime: time.Now().Unix(),
  22553. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  22554. // IsUpload: 1,
  22555. // OrderId: order_id,
  22556. // }
  22557. // service.CreateUploadRecord(hisFundSettleListResult)
  22558. // continue
  22559. // }
  22560. // }
  22561. //}
  22562. func (c *HisApiController) GetOrgInfo() {
  22563. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  22564. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  22565. }
  22566. func (c *HisApiController) GetHisPatientInfo() {
  22567. medical_insurance_card := c.GetString("medical_insurance_card")
  22568. id_card_type, _ := c.GetInt64("id_card_type")
  22569. id_card := c.GetString("id_card")
  22570. adminInfo := c.GetAdminUserInfo()
  22571. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22572. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22573. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  22574. IdCardNo := ""
  22575. if id_card_type == 1 {
  22576. IdCardNo = medical_insurance_card
  22577. } else if id_card_type == 2 {
  22578. IdCardNo = id_card
  22579. }
  22580. if config.IsOpen == 1 {
  22581. 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
  22582. resp, requestErr := http.Get(api)
  22583. if requestErr != nil {
  22584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22585. return
  22586. }
  22587. defer resp.Body.Close()
  22588. body, ioErr := ioutil.ReadAll(resp.Body)
  22589. if ioErr != nil {
  22590. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22592. return
  22593. }
  22594. var respJSON map[string]interface{}
  22595. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22598. return
  22599. }
  22600. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22601. userJSONBytes, _ := json.Marshal(userJSON)
  22602. var res ResultTwo
  22603. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22604. utils.ErrorLog("解析失败:%v", err)
  22605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22606. return
  22607. }
  22608. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22609. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22610. infoStr := string(Iinfos)
  22611. idetinfoStr := string(Idetinfos)
  22612. if res.Infcode == 0 {
  22613. his := models.VMHisPatient{
  22614. Status: 1,
  22615. Ctime: time.Now().Unix(),
  22616. Mtime: time.Now().Unix(),
  22617. PsnNo: res.Output.Baseinfo.PsnNo,
  22618. PsnCertType: res.Output.Baseinfo.PsnCertType,
  22619. Certno: res.Output.Baseinfo.Certno,
  22620. PsnName: res.Output.Baseinfo.PsnName,
  22621. Gend: res.Output.Baseinfo.Gend,
  22622. Naty: res.Output.Baseinfo.Naty,
  22623. Iinfo: infoStr,
  22624. Idetinfo: idetinfoStr,
  22625. UserOrgId: adminInfo.CurrentOrgId,
  22626. IsReturn: 1,
  22627. IdCardType: id_card_type,
  22628. }
  22629. c.ServeSuccessJSON(map[string]interface{}{
  22630. "info": his,
  22631. })
  22632. } else {
  22633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  22634. return
  22635. }
  22636. }
  22637. }
  22638. //func GetBasBaseInfo() (jsonStr string, err error) {
  22639. //
  22640. // handle := syscall.NewLazyDLL("SSCard.dll")
  22641. // add := handle.NewProc("ReadCardBas")
  22642. // str := make([]byte, 1024)
  22643. // str1 := make([]byte, 1024)
  22644. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22645. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  22646. //
  22647. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  22648. //
  22649. // fmt.Println("> Add(4,5)的结果为:", ret)
  22650. // handle.Release()
  22651. //
  22652. // return "", nil
  22653. //
  22654. //}
  22655. //func GetQRBaseInfo() (jsonStr string, err error) {
  22656. // handle := syscall.LoadDLL("SSCard.dll")
  22657. // ReadCardBas := handle.FindProc("GetQRBase")
  22658. //
  22659. // str := make([]byte, 256)
  22660. // str1 := make([]byte, 256)
  22661. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22662. //
  22663. // fmt.Println(string(str))
  22664. // fmt.Println(r)
  22665. // return string(str), nil
  22666. //}
  22667. //func CardInit() int {
  22668. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  22669. // add := DllTestDef.MustFindProc("Init")
  22670. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22671. // if err != nil {
  22672. // fmt.Println("SSCard的运算结果为:", ret)
  22673. // }
  22674. // result := int(ret)
  22675. // return result
  22676. //}
  22677. //func CardInit() int {
  22678. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22679. // if err != nil {
  22680. // fmt.Println("SSCard的运算结果为:", ret)
  22681. // }
  22682. // fmt.Println(err)
  22683. // result := int(ret)
  22684. // return result
  22685. //}
  22686. func IntPtr(n int) uintptr {
  22687. return uintptr(n)
  22688. }
  22689. func StrPtr(s string) uintptr {
  22690. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  22691. }
  22692. type Result2001 struct {
  22693. Cainfo interface{} `json:"cainfo"`
  22694. ErrMsg string `json:"err_msg"`
  22695. InfRefmsgid string `json:"inf_refmsgid"`
  22696. Infcode int64 `json:"infcode"`
  22697. Output struct {
  22698. Trtinfo struct {
  22699. PsnNo string `json:"psn_no"`
  22700. TrtChkType string `json:"trt_chk_type"`
  22701. FundPayType string `json:"fund_pay_type"`
  22702. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22703. Begndate string `json:"begndate"`
  22704. Enddate string `json:"enddate"`
  22705. TrtChkRslt string `json:"trt_chk_rslt"`
  22706. } `json:"trtinfo"`
  22707. } `json:"output"`
  22708. RefmsgTime string `json:"refmsg_time"`
  22709. RespondTime string `json:"respond_time"`
  22710. Signtype interface{} `json:"signtype"`
  22711. WarnMsg interface{} `json:"warn_msg"`
  22712. }
  22713. type Result2001Org10265 struct {
  22714. Cainfo interface{} `json:"cainfo"`
  22715. ErrMsg string `json:"err_msg"`
  22716. InfRefmsgid string `json:"inf_refmsgid"`
  22717. Infcode string `json:"infcode"`
  22718. Output struct {
  22719. Trtinfo struct {
  22720. PsnNo string `json:"psn_no"`
  22721. TrtChkType string `json:"trt_chk_type"`
  22722. FundPayType string `json:"fund_pay_type"`
  22723. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22724. Begndate string `json:"begndate"`
  22725. Enddate string `json:"enddate"`
  22726. TrtChkRslt string `json:"trt_chk_rslt"`
  22727. } `json:"trtinfo"`
  22728. } `json:"output"`
  22729. RefmsgTime string `json:"refmsg_time"`
  22730. RespondTime string `json:"respond_time"`
  22731. Signtype interface{} `json:"signtype"`
  22732. WarnMsg interface{} `json:"warn_msg"`
  22733. }
  22734. type ResultTwo struct {
  22735. ErrMsg string `json:"err_msg"`
  22736. InfRefmsgid string `json:"inf_refmsgid"`
  22737. Infcode int64 `json:"infcode"`
  22738. Output struct {
  22739. Baseinfo struct {
  22740. //Brdy string `json:"brdy"`
  22741. Certno string `json:"certno"`
  22742. Gend string `json:"gend"`
  22743. Naty string `json:"naty"`
  22744. PsnCertType string `json:"psn_cert_type"`
  22745. PsnName string `json:"psn_name"`
  22746. PsnNo string `json:"psn_no"`
  22747. } `json:"baseinfo"`
  22748. Idetinfo []interface{} `json:"idetinfo"`
  22749. Iinfo []struct {
  22750. Balc float64 `json:"balc"`
  22751. CvlservFlag string `json:"cvlserv_flag"`
  22752. EmpName string `json:"emp_name"`
  22753. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22754. Insutype string `json:"insutype"`
  22755. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22756. //PausInsuDate string `json:"paus_insu_date"`
  22757. //PsnInsuDate string `json:"psn_insu_date"`
  22758. PsnInsuStas string `json:"psn_insu_stas"`
  22759. PsnType string `json:"psn_type"`
  22760. } `json:"insuinfo"`
  22761. } `json:"output"`
  22762. RefmsgTime string `json:"refmsg_time"`
  22763. RespondTime string `json:"respond_time"`
  22764. Signtype interface{} `json:"signtype"`
  22765. WarnInfo interface{} `json:"warn_info"`
  22766. }
  22767. type ResultTwo10265 struct {
  22768. ErrMsg string `json:"err_msg"`
  22769. InfRefmsgid string `json:"inf_refmsgid"`
  22770. Infcode string `json:"infcode"`
  22771. Output struct {
  22772. Baseinfo struct {
  22773. //Brdy string `json:"brdy"`
  22774. Certno string `json:"certno"`
  22775. Gend string `json:"gend"`
  22776. Naty string `json:"naty"`
  22777. PsnCertType string `json:"psn_cert_type"`
  22778. PsnName string `json:"psn_name"`
  22779. PsnNo string `json:"psn_no"`
  22780. } `json:"baseinfo"`
  22781. Idetinfo []interface{} `json:"idetinfo"`
  22782. Iinfo []struct {
  22783. Balc float64 `json:"balc"`
  22784. CvlservFlag string `json:"cvlserv_flag"`
  22785. EmpName string `json:"emp_name"`
  22786. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22787. Insutype string `json:"insutype"`
  22788. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22789. PsnInsuStas string `json:"psn_insu_stas"`
  22790. PsnType string `json:"psn_type"`
  22791. } `json:"insuinfo"`
  22792. } `json:"output"`
  22793. RefmsgTime string `json:"refmsg_time"`
  22794. RespondTime string `json:"respond_time"`
  22795. Signtype interface{} `json:"signtype"`
  22796. WarnInfo interface{} `json:"warn_info"`
  22797. }
  22798. type ResultThree struct {
  22799. Cainfo interface{} `json:"cainfo"`
  22800. ErrMsg string `json:"err_msg"`
  22801. InfRefmsgid string `json:"inf_refmsgid"`
  22802. Infcode int64 `json:"infcode"`
  22803. Output struct {
  22804. Data struct {
  22805. IptOtpNo string `json:"ipt_otp_no"`
  22806. MdtrtID string `json:"mdtrt_id"`
  22807. PsnNo string `json:"psn_no"`
  22808. } `json:"data"`
  22809. } `json:"output"`
  22810. RefmsgTime string `json:"refmsg_time"`
  22811. RespondTime string `json:"respond_time"`
  22812. Signtype interface{} `json:"signtype"`
  22813. WarnMsg interface{} `json:"warn_msg"`
  22814. }
  22815. type ResultThree10265 struct {
  22816. Cainfo interface{} `json:"cainfo"`
  22817. ErrMsg string `json:"err_msg"`
  22818. InfRefmsgid string `json:"inf_refmsgid"`
  22819. Infcode string `json:"infcode"`
  22820. Output struct {
  22821. Data struct {
  22822. IptOtpNo string `json:"ipt_otp_no"`
  22823. MdtrtID string `json:"mdtrt_id"`
  22824. PsnNo string `json:"psn_no"`
  22825. } `json:"data"`
  22826. } `json:"output"`
  22827. RefmsgTime string `json:"refmsg_time"`
  22828. RespondTime string `json:"respond_time"`
  22829. Signtype interface{} `json:"signtype"`
  22830. WarnMsg interface{} `json:"warn_msg"`
  22831. }
  22832. type ResultFour struct {
  22833. Cainfo string `json:"cainfo"`
  22834. ErrMsg string `json:"err_msg"`
  22835. InfRefmsgid string `json:"inf_refmsgid"`
  22836. Infcode int64 `json:"infcode"`
  22837. Output struct {
  22838. Result []struct {
  22839. BasMednFlag string `json:"bas_medn_flag"`
  22840. ChldMedcFlag string `json:"chld_medc_flag"`
  22841. ChrgitmLv string `json:"chrgitm_lv"`
  22842. Cnt float64 `json:"cnt"`
  22843. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22844. DrtReimFlag string `json:"drt_reim_flag"`
  22845. FeedetlSn string `json:"feedetl_sn"`
  22846. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22847. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22848. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22849. ListSpItemFlag string `json:"list_sp_item_flag"`
  22850. LmtUsedFlag string `json:"lmt_used_flag"`
  22851. MedChrgitmType string `json:"med_chrgitm_type"`
  22852. Memo string `json:"memo"`
  22853. OverlmtAmt float64 `json:"overlmt_amt"`
  22854. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22855. Pric float64 `json:"pric"`
  22856. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22857. SelfpayProp float64 `json:"selfpay_prop"`
  22858. } `json:"result"`
  22859. } `json:"output"`
  22860. RefmsgTime string `json:"refmsg_time"`
  22861. RespondTime string `json:"respond_time"`
  22862. Signtype string `json:"signtype"`
  22863. WarnMsg string `json:"warn_msg"`
  22864. }
  22865. type ResultFour10265 struct {
  22866. Cainfo string `json:"cainfo"`
  22867. ErrMsg string `json:"err_msg"`
  22868. InfRefmsgid string `json:"inf_refmsgid"`
  22869. Infcode string `json:"infcode"`
  22870. Output struct {
  22871. Result []struct {
  22872. BasMednFlag string `json:"bas_medn_flag"`
  22873. ChldMedcFlag string `json:"chld_medc_flag"`
  22874. ChrgitmLv string `json:"chrgitm_lv"`
  22875. Cnt float64 `json:"cnt"`
  22876. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22877. DrtReimFlag string `json:"drt_reim_flag"`
  22878. FeedetlSn string `json:"feedetl_sn"`
  22879. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22880. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22881. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22882. ListSpItemFlag string `json:"list_sp_item_flag"`
  22883. LmtUsedFlag string `json:"lmt_used_flag"`
  22884. MedChrgitmType string `json:"med_chrgitm_type"`
  22885. Memo string `json:"memo"`
  22886. OverlmtAmt float64 `json:"overlmt_amt"`
  22887. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22888. Pric float64 `json:"pric"`
  22889. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22890. SelfpayProp float64 `json:"selfpay_prop"`
  22891. } `json:"result"`
  22892. } `json:"output"`
  22893. RefmsgTime string `json:"refmsg_time"`
  22894. RespondTime string `json:"respond_time"`
  22895. Signtype string `json:"signtype"`
  22896. WarnMsg string `json:"warn_msg"`
  22897. }
  22898. type ResultMemo struct {
  22899. InsuAdmdvs string `json:"insuAdmdvs"`
  22900. }
  22901. // [{"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}]
  22902. type ResultIDInfo struct {
  22903. Begntime string `json:"begntime"`
  22904. Endtime string `json:"endtime"`
  22905. Memo string `json:"memo"`
  22906. }
  22907. type ResultFive struct {
  22908. Balc float64 `json:"balc"`
  22909. CvlservFlag string `json:"cvlserv_flag"`
  22910. EmpName string `json:"emp_name"`
  22911. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22912. Insutype string `json:"insutype"`
  22913. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22914. PausInsuDate string `json:"paus_insu_date"`
  22915. PsnInsuDate string `json:"psn_insu_date"`
  22916. PsnInsuStas string `json:"psn_insu_stas"`
  22917. PsnType string `json:"psn_type"`
  22918. }
  22919. type ResultSix struct {
  22920. Cainfo interface{} `json:"cainfo"`
  22921. ErrMsg string `json:"err_msg"`
  22922. InfRefmsgid string `json:"inf_refmsgid"`
  22923. Infcode int64 `json:"infcode"`
  22924. Output struct {
  22925. } `json:"output"`
  22926. RefmsgTime string `json:"refmsg_time"`
  22927. RespondTime string `json:"respond_time"`
  22928. Signtype interface{} `json:"signtype"`
  22929. WarnMsg interface{} `json:"warn_msg"`
  22930. }
  22931. type ResultSix3103 struct {
  22932. Cainfo interface{} `json:"cainfo"`
  22933. ErrMsg string `json:"err_msg"`
  22934. InfRefmsgid string `json:"inf_refmsgid"`
  22935. Infcode int64 `json:"infcode"`
  22936. RefmsgTime string `json:"refmsg_time"`
  22937. RespondTime string `json:"respond_time"`
  22938. Signtype interface{} `json:"signtype"`
  22939. WarnMsg interface{} `json:"warn_msg"`
  22940. }
  22941. type FJ3507Result struct {
  22942. Cainfo interface{} `json:"cainfo"`
  22943. ErrMsg string `json:"err_msg"`
  22944. InfRefmsgid string `json:"inf_refmsgid"`
  22945. Infcode int64 `json:"infcode"`
  22946. Output struct {
  22947. retRslt string `json:"retRslt"`
  22948. msgRslt string `json:"msgRslt"`
  22949. } `json:"output"`
  22950. RefmsgTime string `json:"refmsg_time"`
  22951. RespondTime string `json:"respond_time"`
  22952. Signtype interface{} `json:"signtype"`
  22953. WarnMsg interface{} `json:"warn_msg"`
  22954. }
  22955. type FJ3507ResultFor10188 struct {
  22956. Cainfo interface{} `json:"cainfo"`
  22957. ErrMsg string `json:"err_msg"`
  22958. InfRefmsgid string `json:"inf_refmsgid"`
  22959. Infcode string `json:"infcode"`
  22960. RefmsgTime string `json:"refmsg_time"`
  22961. RespondTime string `json:"respond_time"`
  22962. Signtype interface{} `json:"signtype"`
  22963. WarnMsg interface{} `json:"warn_msg"`
  22964. }
  22965. type Result2406 struct {
  22966. Cainfo interface{} `json:"cainfo"`
  22967. ErrMsg string `json:"err_msg"`
  22968. InfRefmsgid string `json:"inf_refmsgid"`
  22969. Infcode int64 `json:"infcode"`
  22970. Output struct {
  22971. Result struct {
  22972. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22973. } `json:"result"`
  22974. } `json:"output"`
  22975. RefmsgTime string `json:"refmsg_time"`
  22976. RespondTime string `json:"respond_time"`
  22977. Signtype interface{} `json:"signtype"`
  22978. WarnMsg interface{} `json:"warn_msg"`
  22979. }
  22980. type GZResultSix struct {
  22981. Cainfo interface{} `json:"cainfo"`
  22982. ErrMsg string `json:"err_msg"`
  22983. InfRefmsgid string `json:"inf_refmsgid"`
  22984. Infcode int64 `json:"infcode"`
  22985. Output string `json:"output"`
  22986. RefmsgTime string `json:"refmsg_time"`
  22987. RespondTime string `json:"respond_time"`
  22988. Signtype interface{} `json:"signtype"`
  22989. WarnMsg interface{} `json:"warn_msg"`
  22990. }
  22991. type ResultSix10265 struct {
  22992. Cainfo interface{} `json:"cainfo"`
  22993. ErrMsg string `json:"err_msg"`
  22994. InfRefmsgid string `json:"inf_refmsgid"`
  22995. Infcode string `json:"infcode"`
  22996. Output struct {
  22997. } `json:"output"`
  22998. RefmsgTime string `json:"refmsg_time"`
  22999. RespondTime string `json:"respond_time"`
  23000. Signtype interface{} `json:"signtype"`
  23001. WarnMsg interface{} `json:"warn_msg"`
  23002. }
  23003. type ResultSeven struct {
  23004. Cainfo string `json:"cainfo"`
  23005. ErrMsg string `json:"err_msg"`
  23006. InfRefmsgid string `json:"inf_refmsgid"`
  23007. Infcode int64 `json:"infcode"`
  23008. Output struct {
  23009. Setlinfo struct {
  23010. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23011. AcctPay float64 `json:"acct_pay"`
  23012. ActPayDedc float64 `json:"act_pay_dedc"`
  23013. Age float64 `json:"age"`
  23014. Balc float64 `json:"balc"`
  23015. Certno string `json:"certno"`
  23016. ClrOptins string `json:"clr_optins"`
  23017. ClrType string `json:"clr_type"`
  23018. ClrWay string `json:"clr_way"`
  23019. CvlservFlag string `json:"cvlserv_flag"`
  23020. CvlservPay float64 `json:"cvlserv_pay"`
  23021. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23022. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23023. Gend string `json:"gend"`
  23024. HifesPay float64 `json:"hifes_pay"`
  23025. HifmiPay float64 `json:"hifmi_pay"`
  23026. HifpPay float64 `json:"hifp_pay"`
  23027. HospPartAmt float64 `json:"hosp_part_amt"`
  23028. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23029. Insutype string `json:"insutype"`
  23030. MafPay float64 `json:"maf_pay"`
  23031. MdtrtCertType string `json:"mdtrt_cert_type"`
  23032. HifobPay float64 `json:"hifob_pay"`
  23033. MdtrtID string `json:"mdtrt_id"`
  23034. MedType string `json:"med_type"`
  23035. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23036. MedinsSetlID string `json:"medins_setl_id"`
  23037. Naty string `json:"naty"`
  23038. OthPay float64 `json:"oth_pay"`
  23039. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23040. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23041. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23042. PsnCashPay float64 `json:"psn_cash_pay"`
  23043. PsnCertType string `json:"psn_cert_type"`
  23044. PsnName string `json:"psn_name"`
  23045. PsnNo string `json:"psn_no"`
  23046. PsnPartAmt float64 `json:"psn_part_amt"`
  23047. PsnType string `json:"psn_type"`
  23048. SetlID string `json:"setl_id"`
  23049. SetlTime string `json:"setl_time"`
  23050. } `json:"setlinfo"`
  23051. Setldetail interface{} `json:"setldetail"`
  23052. } `json:"output"`
  23053. RefmsgTime string `json:"refmsg_time"`
  23054. RespondTime string `json:"respond_time"`
  23055. Signtype interface{} `json:"signtype"`
  23056. WarnMsg interface{} `json:"warn_msg"`
  23057. }
  23058. type ResultSevenAH struct {
  23059. Cainfo string `json:"cainfo"`
  23060. ErrMsg string `json:"err_msg"`
  23061. InfRefmsgid string `json:"inf_refmsgid"`
  23062. Infcode int64 `json:"infcode"`
  23063. Output struct {
  23064. Setlinfo struct {
  23065. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23066. AcctPay float64 `json:"acct_pay"`
  23067. ActPayDedc float64 `json:"act_pay_dedc"`
  23068. Age float64 `json:"age"`
  23069. Balc float64 `json:"balc"`
  23070. Certno string `json:"certno"`
  23071. ClrOptins string `json:"clr_optins"`
  23072. ClrType string `json:"clr_type"`
  23073. ClrWay string `json:"clr_way"`
  23074. CvlservFlag string `json:"cvlserv_flag"`
  23075. CvlservPay float64 `json:"cvlserv_pay"`
  23076. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23077. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23078. Gend string `json:"gend"`
  23079. HifesPay float64 `json:"hifes_pay"`
  23080. HifmiPay float64 `json:"hifmi_pay"`
  23081. HifpPay float64 `json:"hifp_pay"`
  23082. HospPartAmt float64 `json:"hosp_part_amt"`
  23083. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23084. Insutype string `json:"insutype"`
  23085. MafPay float64 `json:"maf_pay"`
  23086. MdtrtCertType string `json:"mdtrt_cert_type"`
  23087. HifobPay float64 `json:"hifob_pay"`
  23088. MdtrtID string `json:"mdtrt_id"`
  23089. MedType string `json:"med_type"`
  23090. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23091. MedinsSetlID string `json:"medins_setl_id"`
  23092. Naty string `json:"naty"`
  23093. OthPay float64 `json:"oth_pay"`
  23094. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23095. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23096. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23097. PsnCashPay float64 `json:"psn_cash_pay"`
  23098. PsnCertType string `json:"psn_cert_type"`
  23099. PsnName string `json:"psn_name"`
  23100. PsnNo string `json:"psn_no"`
  23101. PsnPartAmt float64 `json:"psn_part_amt"`
  23102. PsnType string `json:"psn_type"`
  23103. SetlID string `json:"setl_id"`
  23104. SetlTime int64 `json:"setl_time"`
  23105. } `json:"setlinfo"`
  23106. Setldetail interface{} `json:"setldetail"`
  23107. } `json:"output"`
  23108. RefmsgTime string `json:"refmsg_time"`
  23109. RespondTime string `json:"respond_time"`
  23110. Signtype interface{} `json:"signtype"`
  23111. WarnMsg interface{} `json:"warn_msg"`
  23112. }
  23113. type ResultSeven10265 struct {
  23114. Cainfo string `json:"cainfo"`
  23115. ErrMsg string `json:"err_msg"`
  23116. InfRefmsgid string `json:"inf_refmsgid"`
  23117. Infcode string `json:"infcode"`
  23118. Output struct {
  23119. Setlinfo struct {
  23120. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23121. AcctPay float64 `json:"acct_pay"`
  23122. ActPayDedc float64 `json:"act_pay_dedc"`
  23123. Age float64 `json:"age"`
  23124. Balc float64 `json:"balc"`
  23125. Certno string `json:"certno"`
  23126. ClrOptins string `json:"clr_optins"`
  23127. ClrType string `json:"clr_type"`
  23128. ClrWay string `json:"clr_way"`
  23129. CvlservFlag string `json:"cvlserv_flag"`
  23130. CvlservPay float64 `json:"cvlserv_pay"`
  23131. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23132. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23133. Gend string `json:"gend"`
  23134. HifesPay float64 `json:"hifes_pay"`
  23135. HifmiPay float64 `json:"hifmi_pay"`
  23136. HifpPay float64 `json:"hifp_pay"`
  23137. HospPartAmt float64 `json:"hosp_part_amt"`
  23138. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23139. Insutype string `json:"insutype"`
  23140. MafPay float64 `json:"maf_pay"`
  23141. MdtrtCertType string `json:"mdtrt_cert_type"`
  23142. HifobPay float64 `json:"hifob_pay"`
  23143. MdtrtID string `json:"mdtrt_id"`
  23144. MedType string `json:"med_type"`
  23145. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23146. MedinsSetlID string `json:"medins_setl_id"`
  23147. Naty string `json:"naty"`
  23148. OthPay float64 `json:"oth_pay"`
  23149. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23150. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23151. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23152. PsnCashPay float64 `json:"psn_cash_pay"`
  23153. PsnCertType string `json:"psn_cert_type"`
  23154. PsnName string `json:"psn_name"`
  23155. PsnNo string `json:"psn_no"`
  23156. PsnPartAmt float64 `json:"psn_part_amt"`
  23157. PsnType string `json:"psn_type"`
  23158. SetlID string `json:"setl_id"`
  23159. SetlTime string `json:"setl_time"`
  23160. } `json:"setlinfo"`
  23161. Setldetail interface{} `json:"setldetail"`
  23162. } `json:"output"`
  23163. RefmsgTime string `json:"refmsg_time"`
  23164. RespondTime string `json:"respond_time"`
  23165. Signtype interface{} `json:"signtype"`
  23166. WarnMsg interface{} `json:"warn_msg"`
  23167. }
  23168. type ResultSeven10265Two struct {
  23169. Cainfo string `json:"cainfo"`
  23170. ErrMsg string `json:"err_msg"`
  23171. InfRefmsgid string `json:"inf_refmsgid"`
  23172. Infcode string `json:"infcode"`
  23173. Output struct {
  23174. Setlinfo struct {
  23175. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23176. AcctPay float64 `json:"acct_pay"`
  23177. ActPayDedc float64 `json:"act_pay_dedc"`
  23178. Age float64 `json:"age"`
  23179. Balc float64 `json:"balc"`
  23180. Certno string `json:"certno"`
  23181. ClrOptins string `json:"clr_optins"`
  23182. ClrType string `json:"clr_type"`
  23183. ClrWay string `json:"clr_way"`
  23184. CvlservFlag string `json:"cvlserv_flag"`
  23185. CvlservPay float64 `json:"cvlserv_pay"`
  23186. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23187. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23188. Gend string `json:"gend"`
  23189. HifesPay float64 `json:"hifes_pay"`
  23190. HifmiPay float64 `json:"hifmi_pay"`
  23191. HifpPay float64 `json:"hifp_pay"`
  23192. HospPartAmt string `json:"hosp_part_amt"`
  23193. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23194. Insutype string `json:"insutype"`
  23195. MafPay float64 `json:"maf_pay"`
  23196. MdtrtCertType string `json:"mdtrt_cert_type"`
  23197. HifobPay float64 `json:"hifob_pay"`
  23198. MdtrtID string `json:"mdtrt_id"`
  23199. MedType string `json:"med_type"`
  23200. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23201. MedinsSetlID string `json:"medins_setl_id"`
  23202. Naty string `json:"naty"`
  23203. OthPay float64 `json:"oth_pay"`
  23204. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23205. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23206. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23207. PsnCashPay float64 `json:"psn_cash_pay"`
  23208. PsnCertType string `json:"psn_cert_type"`
  23209. PsnName string `json:"psn_name"`
  23210. PsnNo string `json:"psn_no"`
  23211. PsnPartAmt float64 `json:"psn_part_amt"`
  23212. PsnType string `json:"psn_type"`
  23213. SetlID string `json:"setl_id"`
  23214. SetlTime string `json:"setl_time"`
  23215. } `json:"setlinfo"`
  23216. Setldetail interface{} `json:"setldetail"`
  23217. } `json:"output"`
  23218. RefmsgTime string `json:"refmsg_time"`
  23219. RespondTime string `json:"respond_time"`
  23220. Signtype interface{} `json:"signtype"`
  23221. WarnMsg interface{} `json:"warn_msg"`
  23222. }
  23223. type ResultSeven10633Two struct {
  23224. Cainfo string `json:"cainfo"`
  23225. ErrMsg string `json:"err_msg"`
  23226. InfRefmsgid string `json:"inf_refmsgid"`
  23227. Infcode string `json:"infcode"`
  23228. Output struct {
  23229. Setlinfo struct {
  23230. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23231. AcctPay float64 `json:"acct_pay"`
  23232. ActPayDedc float64 `json:"act_pay_dedc"`
  23233. Age float64 `json:"age"`
  23234. Balc float64 `json:"balc"`
  23235. Certno string `json:"certno"`
  23236. ClrOptins string `json:"clr_optins"`
  23237. ClrType string `json:"clr_type"`
  23238. ClrWay string `json:"clr_way"`
  23239. CvlservFlag string `json:"cvlserv_flag"`
  23240. CvlservPay float64 `json:"cvlserv_pay"`
  23241. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23242. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23243. Gend string `json:"gend"`
  23244. HifesPay float64 `json:"hifes_pay"`
  23245. HifmiPay float64 `json:"hifmi_pay"`
  23246. HifpPay float64 `json:"hifp_pay"`
  23247. HospPartAmt float64 `json:"hosp_part_amt"`
  23248. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23249. Insutype string `json:"insutype"`
  23250. MafPay float64 `json:"maf_pay"`
  23251. MdtrtCertType string `json:"mdtrt_cert_type"`
  23252. HifobPay float64 `json:"hifob_pay"`
  23253. MdtrtID string `json:"mdtrt_id"`
  23254. MedType string `json:"med_type"`
  23255. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23256. MedinsSetlID string `json:"medins_setl_id"`
  23257. Naty string `json:"naty"`
  23258. OthPay float64 `json:"oth_pay"`
  23259. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23260. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23261. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23262. PsnCashPay float64 `json:"psn_cash_pay"`
  23263. PsnCertType string `json:"psn_cert_type"`
  23264. PsnName string `json:"psn_name"`
  23265. PsnNo string `json:"psn_no"`
  23266. PsnPartAmt float64 `json:"psn_part_amt"`
  23267. PsnType string `json:"psn_type"`
  23268. SetlID string `json:"setl_id"`
  23269. SetlTime string `json:"setl_time"`
  23270. } `json:"setlinfo"`
  23271. Setldetail interface{} `json:"setldetail"`
  23272. } `json:"output"`
  23273. RefmsgTime string `json:"refmsg_time"`
  23274. RespondTime string `json:"respond_time"`
  23275. Signtype interface{} `json:"signtype"`
  23276. WarnMsg interface{} `json:"warn_msg"`
  23277. }
  23278. type ResultSeven10633Three struct {
  23279. Cainfo string `json:"cainfo"`
  23280. ErrMsg string `json:"err_msg"`
  23281. InfRefmsgid string `json:"inf_refmsgid"`
  23282. Infcode string `json:"infcode"`
  23283. Output struct {
  23284. Setlinfo struct {
  23285. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23286. AcctPay float64 `json:"acct_pay"`
  23287. ActPayDedc float64 `json:"act_pay_dedc"`
  23288. Age float64 `json:"age"`
  23289. Balc float64 `json:"balc"`
  23290. Certno string `json:"certno"`
  23291. ClrOptins string `json:"clr_optins"`
  23292. ClrType string `json:"clr_type"`
  23293. ClrWay string `json:"clr_way"`
  23294. CvlservFlag string `json:"cvlserv_flag"`
  23295. CvlservPay float64 `json:"cvlserv_pay"`
  23296. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23297. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23298. Gend string `json:"gend"`
  23299. HifesPay float64 `json:"hifes_pay"`
  23300. HifmiPay float64 `json:"hifmi_pay"`
  23301. HifpPay float64 `json:"hifp_pay"`
  23302. HospPartAmt string `json:"hosp_part_amt"`
  23303. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23304. Insutype string `json:"insutype"`
  23305. MafPay float64 `json:"maf_pay"`
  23306. MdtrtCertType string `json:"mdtrt_cert_type"`
  23307. HifobPay float64 `json:"hifob_pay"`
  23308. MdtrtID string `json:"mdtrt_id"`
  23309. MedType string `json:"med_type"`
  23310. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23311. MedinsSetlID string `json:"medins_setl_id"`
  23312. Naty string `json:"naty"`
  23313. OthPay float64 `json:"oth_pay"`
  23314. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23315. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23316. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23317. PsnCashPay float64 `json:"psn_cash_pay"`
  23318. PsnCertType string `json:"psn_cert_type"`
  23319. PsnName string `json:"psn_name"`
  23320. PsnNo string `json:"psn_no"`
  23321. PsnPartAmt float64 `json:"psn_part_amt"`
  23322. PsnType string `json:"psn_type"`
  23323. SetlID string `json:"setl_id"`
  23324. SetlTime string `json:"setl_time"`
  23325. } `json:"setlinfo"`
  23326. Setldetail interface{} `json:"setldetail"`
  23327. } `json:"output"`
  23328. RefmsgTime string `json:"refmsg_time"`
  23329. RespondTime string `json:"respond_time"`
  23330. Signtype interface{} `json:"signtype"`
  23331. WarnMsg interface{} `json:"warn_msg"`
  23332. }
  23333. type GZResultSeven10265Two struct {
  23334. Cainfo string `json:"cainfo"`
  23335. ErrMsg string `json:"err_msg"`
  23336. InfRefmsgid string `json:"inf_refmsgid"`
  23337. Infcode int64 `json:"infcode"`
  23338. Output struct {
  23339. Setlinfo struct {
  23340. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23341. AcctPay float64 `json:"acct_pay"`
  23342. ActPayDedc float64 `json:"act_pay_dedc"`
  23343. Age float64 `json:"age"`
  23344. Balc float64 `json:"balc"`
  23345. Certno string `json:"certno"`
  23346. ClrOptins string `json:"clr_optins"`
  23347. ClrType string `json:"clr_type"`
  23348. ClrWay string `json:"clr_way"`
  23349. CvlservFlag string `json:"cvlserv_flag"`
  23350. CvlservPay float64 `json:"cvlserv_pay"`
  23351. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23352. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23353. Gend string `json:"gend"`
  23354. HifesPay float64 `json:"hifes_pay"`
  23355. HifmiPay float64 `json:"hifmi_pay"`
  23356. HifpPay float64 `json:"hifp_pay"`
  23357. HospPartAmt float64 `json:"hosp_part_amt"`
  23358. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23359. Insutype string `json:"insutype"`
  23360. MafPay float64 `json:"maf_pay"`
  23361. MdtrtCertType string `json:"mdtrt_cert_type"`
  23362. HifobPay float64 `json:"hifob_pay"`
  23363. MdtrtID string `json:"mdtrt_id"`
  23364. MedType string `json:"med_type"`
  23365. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23366. MedinsSetlID string `json:"medins_setl_id"`
  23367. Naty string `json:"naty"`
  23368. OthPay float64 `json:"oth_pay"`
  23369. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23370. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23371. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23372. PsnCashPay float64 `json:"psn_cash_pay"`
  23373. PsnCertType string `json:"psn_cert_type"`
  23374. PsnName string `json:"psn_name"`
  23375. PsnNo string `json:"psn_no"`
  23376. PsnPartAmt float64 `json:"psn_part_amt"`
  23377. PsnType string `json:"psn_type"`
  23378. SetlID string `json:"setl_id"`
  23379. SetlTime string `json:"setl_time"`
  23380. } `json:"setlinfo"`
  23381. Setldetail interface{} `json:"setldetail"`
  23382. } `json:"output"`
  23383. RefmsgTime string `json:"refmsg_time"`
  23384. RespondTime string `json:"respond_time"`
  23385. Signtype interface{} `json:"signtype"`
  23386. WarnMsg interface{} `json:"warn_msg"`
  23387. }
  23388. type ResultEight struct {
  23389. Cainfo string `json:"cainfo"`
  23390. ErrMsg string `json:"err_msg"`
  23391. InfRefmsgid string `json:"inf_refmsgid"`
  23392. Infcode int64 `json:"infcode"`
  23393. Output struct {
  23394. Stmtinfo struct {
  23395. SetlOptins string `json:"setl_optins"`
  23396. StmtRslt string `json:"stmt_rslt"`
  23397. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23398. } `json:"stmtinfo"`
  23399. } `json:"output"`
  23400. RefmsgTime string `json:"refmsg_time"`
  23401. RespondTime string `json:"respond_time"`
  23402. Signtype interface{} `json:"signtype"`
  23403. WarnMsg interface{} `json:"warn_msg"`
  23404. }
  23405. type ResultEightFor10188 struct {
  23406. Cainfo string `json:"cainfo"`
  23407. ErrMsg string `json:"err_msg"`
  23408. InfRefmsgid string `json:"inf_refmsgid"`
  23409. Infcode string `json:"infcode"`
  23410. Output struct {
  23411. Stmtinfo struct {
  23412. SetlOptins string `json:"setl_optins"`
  23413. StmtRslt string `json:"stmt_rslt"`
  23414. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23415. } `json:"stmtinfo"`
  23416. } `json:"output"`
  23417. RefmsgTime string `json:"refmsg_time"`
  23418. RespondTime string `json:"respond_time"`
  23419. Signtype interface{} `json:"signtype"`
  23420. WarnMsg interface{} `json:"warn_msg"`
  23421. }
  23422. type ResultNine struct {
  23423. Cainfo string `json:"cainfo"`
  23424. ErrMsg string `json:"err_msg"`
  23425. InfRefmsgid string `json:"inf_refmsgid"`
  23426. Infcode int64 `json:"infcode"`
  23427. Output struct {
  23428. FileQuryNo string `json:"file_qury_no"`
  23429. } `json:"output"`
  23430. RefmsgTime string `json:"refmsg_time"`
  23431. RespondTime string `json:"respond_time"`
  23432. Signtype interface{} `json:"signtype"`
  23433. WarnMsg interface{} `json:"warn_msg"`
  23434. }
  23435. type ResultTen struct {
  23436. Cainfo string `json:"cainfo"`
  23437. ErrMsg string `json:"err_msg"`
  23438. InfRefmsgid string `json:"inf_refmsgid"`
  23439. Infcode int64 `json:"infcode"`
  23440. Output struct {
  23441. Fileinfo struct {
  23442. DldEndtime string `json:"dld_endtime"`
  23443. FileQuryNo string `json:"file_qury_no"`
  23444. Filename string `json:"filename"`
  23445. } `json:"fileinfo"`
  23446. } `json:"output"`
  23447. RefmsgTime string `json:"refmsg_time"`
  23448. RespondTime string `json:"respond_time"`
  23449. Signtype interface{} `json:"signtype"`
  23450. WarnMsg interface{} `json:"warn_msg"`
  23451. }
  23452. type Result5262 struct {
  23453. ErrMsg string `json:"err_msg"`
  23454. InfRefmsgid string `json:"inf_refmsgid"`
  23455. Infcode int64 `json:"infcode"`
  23456. Output struct {
  23457. PageInfo struct {
  23458. Size int `json:"size"`
  23459. RecordCounts int `json:"record_counts"`
  23460. } `json:"page_info"`
  23461. Idetinfo []interface{} `json:"idetinfo"`
  23462. Result []struct {
  23463. SetlID string `json:"setl_id"`
  23464. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23465. MdtrtID string `json:"mdtrt_id"`
  23466. InitSetlID string `json:"init_setl_id,omitempty"`
  23467. PsnNo string `json:"psn_no"`
  23468. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23469. PsnName string `json:"psn_name"`
  23470. PsnCertType string `json:"psn_cert_type"`
  23471. Certno string `json:"certno"`
  23472. Gend string `json:"gend,omitempty"`
  23473. Naty string `json:"naty,omitempty"`
  23474. Brdy string `json:"brdy,omitempty"`
  23475. Age float64 `json:"age,omitempty"`
  23476. Insutype string `json:"insutype,omitempty"`
  23477. PsnType string `json:"psn_type"`
  23478. CvlservFlag string `json:"cvlserv_flag"`
  23479. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23480. SpPsnType string `json:"sp_psn_type,omitempty"`
  23481. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23482. ClctGrde string `json:"clct_grde,omitempty"`
  23483. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23484. NwbFlag string `json:"nwb_flag,omitempty"`
  23485. InsuAdmdvs string `json:"insu_admdvs"`
  23486. EmpNo string `json:"emp_no,omitempty"`
  23487. EmpName string `json:"emp_name,omitempty"`
  23488. EmpType string `json:"emp_type,omitempty"`
  23489. EconType string `json:"econ_type,omitempty"`
  23490. AfilIndu string `json:"afil_indu,omitempty"`
  23491. AfilRlts string `json:"afil_rlts,omitempty"`
  23492. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23493. PayLoc string `json:"pay_loc,omitempty"`
  23494. FixmedinsCode string `json:"fixmedins_code"`
  23495. FixmedinsName string `json:"fixmedins_name"`
  23496. HospLv string `json:"hosp_lv,omitempty"`
  23497. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23498. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23499. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23500. Begndate string `json:"begndate"`
  23501. Enddate string `json:"enddate"`
  23502. SetlTime string `json:"setl_time"`
  23503. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23504. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23505. MedType string `json:"med_type"`
  23506. SetlType string `json:"setl_type,omitempty"`
  23507. ClrType string `json:"clr_type,omitempty"`
  23508. ClrWay string `json:"clr_way,omitempty"`
  23509. PsnSetlway string `json:"psn_setlway,omitempty"`
  23510. ClrOptins string `json:"clr_optins,omitempty"`
  23511. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23512. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23513. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23514. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23515. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23516. DedcStd float64 `json:"dedc_std,omitempty"`
  23517. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23518. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23519. HifpPay float64 `json:"hifp_pay,omitempty"`
  23520. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23521. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23522. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23523. HifesPay float64 `json:"hifes_pay,omitempty"`
  23524. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23525. HifobPay float64 `json:"hifob_pay,omitempty"`
  23526. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23527. MafPay float64 `json:"maf_pay,omitempty"`
  23528. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23529. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23530. PsnPay float64 `json:"psn_pay,omitempty"`
  23531. AcctPay float64 `json:"acct_pay,omitempty"`
  23532. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23533. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23534. Balc float64 `json:"balc,omitempty"`
  23535. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23536. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23537. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23538. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23539. Year string `json:"year,omitempty"`
  23540. DiseNo string `json:"dise_no,omitempty"`
  23541. DiseName string `json:"dise_name,omitempty"`
  23542. Invono string `json:"invono,omitempty"`
  23543. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23544. ValiFlag string `json:"vali_flag,omitempty"`
  23545. Memo string `json:"memo,omitempty"`
  23546. Rid string `json:"rid"`
  23547. UpdtTime string `json:"updt_time,omitempty"`
  23548. CrterID string `json:"crter_id,omitempty"`
  23549. CrterName string `json:"crter_name,omitempty"`
  23550. CrteTime string `json:"crte_time,omitempty"`
  23551. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  23552. OpterID string `json:"opter_id,omitempty"`
  23553. OpterName string `json:"opter_name,omitempty"`
  23554. OptTime string `json:"opt_time,omitempty"`
  23555. OptinsNo string `json:"optins_no,omitempty"`
  23556. PoolareaNo string `json:"poolarea_no,omitempty"`
  23557. } `json:"result"`
  23558. } `json:"output"`
  23559. RefmsgTime string `json:"refmsg_time"`
  23560. RespondTime string `json:"respond_time"`
  23561. Signtype interface{} `json:"signtype"`
  23562. WarnInfo interface{} `json:"warn_info"`
  23563. }
  23564. type Result5267 struct {
  23565. ErrMsg string `json:"err_msg"`
  23566. InfRefmsgid string `json:"inf_refmsgid"`
  23567. Infcode int64 `json:"infcode"`
  23568. Output struct {
  23569. PageInfo struct {
  23570. Size int `json:"size"`
  23571. RecordCounts int `json:"record_counts"`
  23572. } `json:"pageinfo"`
  23573. Result []struct {
  23574. SetlID string `json:"setl_id"`
  23575. ClrOptins string `json:"clr_optins"`
  23576. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23577. MdtrtID string `json:"mdtrt_id"`
  23578. InitSetlID string `json:"init_setl_id,omitempty"`
  23579. PsnNo string `json:"psn_no"`
  23580. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23581. PsnName string `json:"psn_name"`
  23582. PsnCertType string `json:"psn_cert_type"`
  23583. Certno string `json:"certno"`
  23584. Gend string `json:"gend,omitempty"`
  23585. Naty string `json:"naty,omitempty"`
  23586. Brdy string `json:"brdy,omitempty"`
  23587. Age float64 `json:"age,omitempty"`
  23588. Insutype string `json:"insutype,omitempty"`
  23589. PsnType string `json:"psn_type"`
  23590. CvlservFlag string `json:"cvlserv_flag"`
  23591. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23592. SpPsnType string `json:"sp_psn_type,omitempty"`
  23593. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23594. ClctGrde string `json:"clct_grde,omitempty"`
  23595. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23596. NwbFlag string `json:"nwb_flag,omitempty"`
  23597. InsuAdmdvs string `json:"insu_admdvs"`
  23598. EmpNo string `json:"emp_no,omitempty"`
  23599. EmpName string `json:"emp_name,omitempty"`
  23600. EmpType string `json:"emp_type,omitempty"`
  23601. EconType string `json:"econ_type,omitempty"`
  23602. AfilIndu string `json:"afil_indu,omitempty"`
  23603. AfilRlts string `json:"afil_rlts,omitempty"`
  23604. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23605. PayLoc string `json:"pay_loc,omitempty"`
  23606. FixmedinsCode string `json:"fixmedins_code"`
  23607. FixmedinsName string `json:"fixmedins_name"`
  23608. HospLv string `json:"hosp_lv,omitempty"`
  23609. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23610. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23611. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23612. Begndate string `json:"begndate,omitempty"`
  23613. Enddate string `json:"enddate,omitempty"`
  23614. SetlTime string `json:"setl_time,omitempty"`
  23615. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23616. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23617. MedType string `json:"med_type"`
  23618. SetlType string `json:"setl_type,omitempty"`
  23619. ClrType string `json:"clr_type,omitempty"`
  23620. ClrWay string `json:"clr_way,omitempty"`
  23621. PsnSetlway string `json:"psn_setlway,omitempty"`
  23622. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23623. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23624. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23625. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23626. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23627. DedcStd float64 `json:"dedc_std,omitempty"`
  23628. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23629. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23630. HifpPay float64 `json:"hifp_pay,omitempty"`
  23631. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23632. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23633. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23634. HifesPay float64 `json:"hifes_pay,omitempty"`
  23635. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23636. HifobPay float64 `json:"hifob_pay,omitempty"`
  23637. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23638. MafPay float64 `json:"maf_pay,omitempty"`
  23639. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23640. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23641. PsnPay float64 `json:"psn_pay,omitempty"`
  23642. AcctPay float64 `json:"acct_pay,omitempty"`
  23643. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23644. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23645. Balc float64 `json:"balc,omitempty"`
  23646. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23647. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23648. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23649. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23650. Year string `json:"year,omitempty"`
  23651. DiseNo string `json:"dise_no,omitempty"`
  23652. DiseName string `json:"dise_name,omitempty"`
  23653. Invono string `json:"invono,omitempty"`
  23654. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23655. Memo string `json:"memo,omitempty"`
  23656. UpdtTime string `json:"updt_time,omitempty"`
  23657. OpterID string `json:"opter_id,omitempty"`
  23658. OpterName string `json:"opter_name,omitempty"`
  23659. OptTime string `json:"opt_time,omitempty"`
  23660. OptinsNo string `json:"optins_no,omitempty"`
  23661. PoolareaNo string `json:"poolarea_no,omitempty"`
  23662. } `json:"result"`
  23663. } `json:"output"`
  23664. RefmsgTime string `json:"refmsg_time"`
  23665. RespondTime string `json:"respond_time"`
  23666. Signtype interface{} `json:"signtype"`
  23667. WarnInfo interface{} `json:"warn_info"`
  23668. }
  23669. // type Autogenerated struct {
  23670. // Output struct {
  23671. // Setlinfo struct {
  23672. // SetlTime string `json:"setl_time"`
  23673. // CvlservPay float64 `json:"cvlserv_pay"`
  23674. // Year string `json:"year"`
  23675. // MedType string `json:"med_type"`
  23676. // PsnPay float64 `json:"psn_pay"`
  23677. // OpterID string `json:"opter_id"`
  23678. // Begndate string `json:"begndate"`
  23679. // FlxempeFlag string `json:"flxempe_flag"`
  23680. // HifmiPay float64 `json:"hifmi_pay"`
  23681. // PsnNo string `json:"psn_no"`
  23682. // ActPayDedc float64 `json:"act_pay_dedc"`
  23683. // MedinsSetlID interface{} `json:"medins_setl_id"`
  23684. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23685. // ClrWay string `json:"clr_way"`
  23686. // OthPay float64 `json:"oth_pay"`
  23687. // Gend string `json:"gend"`
  23688. // MdtrtID string `json:"mdtrt_id"`
  23689. // AcctPay float64 `json:"acct_pay"`
  23690. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  23691. // Insutype string `json:"insutype"`
  23692. // Invono interface{} `json:"invono"`
  23693. // Enddate string `json:"enddate"`
  23694. // CashPayamt float64 `json:"cash_payamt"`
  23695. // PsnType string `json:"psn_type"`
  23696. // FixmedinsName string `json:"fixmedins_name"`
  23697. // HifpPay float64 `json:"hifp_pay"`
  23698. // NewFlag interface{} `json:"new_flag"`
  23699. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23700. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  23701. // PayLoc string `json:"pay_loc"`
  23702. // ClrType string `json:"clr_type"`
  23703. // RefdSetlFlag string `json:"refd_setl_flag"`
  23704. // CvlservFlag string `json:"cvlserv_flag"`
  23705. // EmpName string `json:"emp_name"`
  23706. // Brdy string `json:"brdy"`
  23707. // Naty string `json:"naty"`
  23708. // Certno string `json:"certno"`
  23709. // DiseCode string `json:"dise_code"`
  23710. // FixmedinsCode string `json:"fixmedins_code"`
  23711. // DedcHospLv string `json:"dedc_hosp_lv"`
  23712. // OpterName string `json:"opter_name"`
  23713. // Balc float64 `json:"balc"`
  23714. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23715. // PsnCertType string `json:"psn_cert_type"`
  23716. // HifobPay float64 `json:"hifob_pay"`
  23717. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  23718. // HifesPay float64 `json:"hifes_pay"`
  23719. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23720. // OptTime string `json:"opt_time"`
  23721. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23722. // SetlID string `json:"setl_id"`
  23723. // MafPay float64 `json:"maf_pay"`
  23724. // PsnName string `json:"psn_name"`
  23725. // InsuOptins interface{} `json:"insu_optins"`
  23726. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23727. // ClrOptins string `json:"clr_optins"`
  23728. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23729. // DiseName string `json:"dise_name"`
  23730. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23731. // Age float64 `json:"age"`
  23732. // DtrtCertType string `json:"dtrt_cert_type"`
  23733. // HospLv string `json:"hosp_lv"`
  23734. // } `json:"setlinfo"`
  23735. // Setldetail []struct {
  23736. // FundPayType string `json:"fund_pay_type"`
  23737. // FundPayamt float64 `json:"fund_payamt"`
  23738. // SetlProcInfo interface{} `json:"setl_proc_info"`
  23739. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  23740. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  23741. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  23742. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23743. // } `json:"setldetail"`
  23744. // } `json:"output"`
  23745. // Infcode int `json:"infcode"`
  23746. // WarnMsg interface{} `json:"warn_msg"`
  23747. // Cainfo interface{} `json:"cainfo"`
  23748. // ErrMsg interface{} `json:"err_msg"`
  23749. // RefmsgTime string `json:"refmsg_time"`
  23750. // Signtype interface{} `json:"signtype"`
  23751. // RespondTime string `json:"respond_time"`
  23752. // InfRefmsgid string `json:"inf_refmsgid"`
  23753. // }
  23754. type Result002 struct {
  23755. Cainfo interface{} `json:"cainfo"`
  23756. ErrMsg string `json:"err_msg"`
  23757. InfRefmsgid string `json:"inf_refmsgid"`
  23758. Infcode int64 `json:"infcode"`
  23759. Output struct {
  23760. RxFile string `json:"rx_file"`
  23761. SignDigest string `json:"sign_digest"`
  23762. SignCertSn string `json:"sign_cert_sn"`
  23763. SignCertDn string `json:"sign_cert_dn"`
  23764. } `json:"output"`
  23765. RefmsgTime string `json:"refmsg_time"`
  23766. RespondTime string `json:"respond_time"`
  23767. Signtype interface{} `json:"signtype"`
  23768. WarnMsg interface{} `json:"warn_msg"`
  23769. }
  23770. type AhResult002 struct {
  23771. RxFile string `json:"rxFile"`
  23772. SignDigest string `json:"signDigest"`
  23773. SignCertSn string `json:"signCertSn"`
  23774. SignCertDn string `json:"signCertDn"`
  23775. }
  23776. type Result003 struct {
  23777. Cainfo interface{} `json:"cainfo"`
  23778. ErrMsg string `json:"err_msg"`
  23779. InfRefmsgid string `json:"inf_refmsgid"`
  23780. Infcode int64 `json:"infcode"`
  23781. Output struct {
  23782. HiRxno string `json:"hi_rxno"`
  23783. RxStasCodg string `json:"rx_stas_codg"`
  23784. RxStasName string `json:"rx_stas_name"`
  23785. } `json:"output"`
  23786. RefmsgTime string `json:"refmsg_time"`
  23787. RespondTime string `json:"respond_time"`
  23788. Signtype interface{} `json:"signtype"`
  23789. WarnMsg interface{} `json:"warn_msg"`
  23790. }
  23791. type AHResult003 struct {
  23792. HiRxno string `json:"hiRxno"`
  23793. RxStasCodg string `json:"rxStasCodg"`
  23794. RxStasName string `json:"rxStasName"`
  23795. }
  23796. type ResultEleven struct {
  23797. Cainfo string `json:"cainfo"`
  23798. ErrMsg string `json:"err_msg"`
  23799. InfRefmsgid string `json:"inf_refmsgid"`
  23800. Infcode int64 `json:"infcode"`
  23801. Output struct {
  23802. Setlinfo struct {
  23803. SetlTime string `json:"setl_time"`
  23804. CvlservPay float64 `json:"cvlserv_pay"`
  23805. Year string `json:"year"`
  23806. MedType string `json:"med_type"`
  23807. PsnPay float64 `json:"psn_pay"`
  23808. OpterID string `json:"opter_id"`
  23809. Begndate string `json:"begndate"`
  23810. FlxempeFlag string `json:"flxempe_flag"`
  23811. HifmiPay float64 `json:"hifmi_pay"`
  23812. PsnNo string `json:"psn_no"`
  23813. ActPayDedc float64 `json:"act_pay_dedc"`
  23814. MedinsSetlID interface{} `json:"medins_setl_id"`
  23815. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23816. ClrWay string `json:"clr_way"`
  23817. OthPay float64 `json:"oth_pay"`
  23818. Gend string `json:"gend"`
  23819. MdtrtID string `json:"mdtrt_id"`
  23820. AcctPay float64 `json:"acct_pay"`
  23821. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23822. Insutype string `json:"insutype"`
  23823. Invono interface{} `json:"invono"`
  23824. Enddate string `json:"enddate"`
  23825. CashPayamt float64 `json:"cash_payamt"`
  23826. PsnType string `json:"psn_type"`
  23827. FixmedinsName string `json:"fixmedins_name"`
  23828. HifpPay float64 `json:"hifp_pay"`
  23829. NewFlag interface{} `json:"new_flag"`
  23830. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23831. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23832. PayLoc string `json:"pay_loc"`
  23833. ClrType string `json:"clr_type"`
  23834. RefdSetlFlag string `json:"refd_setl_flag"`
  23835. CvlservFlag string `json:"cvlserv_flag"`
  23836. EmpName string `json:"emp_name"`
  23837. Brdy string `json:"brdy"`
  23838. Naty string `json:"naty"`
  23839. Certno string `json:"certno"`
  23840. DiseCode string `json:"dise_code"`
  23841. FixmedinsCode string `json:"fixmedins_code"`
  23842. DedcHospLv string `json:"dedc_hosp_lv"`
  23843. OpterName string `json:"opter_name"`
  23844. Balc float64 `json:"balc"`
  23845. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23846. PsnCertType string `json:"psn_cert_type"`
  23847. HifobPay float64 `json:"hifob_pay"`
  23848. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23849. HifesPay float64 `json:"hifes_pay"`
  23850. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23851. OptTime string `json:"opt_time"`
  23852. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23853. SetlID string `json:"setl_id"`
  23854. MafPay float64 `json:"maf_pay"`
  23855. PsnName string `json:"psn_name"`
  23856. InsuOptins interface{} `json:"insu_optins"`
  23857. PrefFundPay interface{} `json:"pref_fund_pay"`
  23858. ClrOptins string `json:"clr_optins"`
  23859. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23860. DiseName string `json:"dise_name"`
  23861. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23862. Age float64 `json:"age"`
  23863. DtrtCertType string `json:"dtrt_cert_type"`
  23864. HospLv string `json:"hosp_lv"`
  23865. PsnCashPay float64 `json:"psn_cash_pay"`
  23866. } `json:"setlinfo"`
  23867. } `json:"output"`
  23868. RefmsgTime string `json:"refmsg_time"`
  23869. RespondTime string `json:"respond_time"`
  23870. Signtype interface{} `json:"signtype"`
  23871. WarnMsg interface{} `json:"warn_msg"`
  23872. }
  23873. type ResultElevenah struct {
  23874. Cainfo string `json:"cainfo"`
  23875. ErrMsg string `json:"err_msg"`
  23876. InfRefmsgid string `json:"inf_refmsgid"`
  23877. Infcode int64 `json:"infcode"`
  23878. Output struct {
  23879. Setlinfo struct {
  23880. SetlTime int64 `json:"setl_time"`
  23881. CvlservPay float64 `json:"cvlserv_pay"`
  23882. Year string `json:"year"`
  23883. MedType string `json:"med_type"`
  23884. PsnPay float64 `json:"psn_pay"`
  23885. OpterID string `json:"opter_id"`
  23886. Begndate int64 `json:"begndate"`
  23887. FlxempeFlag string `json:"flxempe_flag"`
  23888. HifmiPay float64 `json:"hifmi_pay"`
  23889. PsnNo string `json:"psn_no"`
  23890. ActPayDedc float64 `json:"act_pay_dedc"`
  23891. MedinsSetlID interface{} `json:"medins_setl_id"`
  23892. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23893. ClrWay string `json:"clr_way"`
  23894. OthPay float64 `json:"oth_pay"`
  23895. Gend string `json:"gend"`
  23896. MdtrtID string `json:"mdtrt_id"`
  23897. AcctPay float64 `json:"acct_pay"`
  23898. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23899. Insutype string `json:"insutype"`
  23900. Invono interface{} `json:"invono"`
  23901. Enddate int64 `json:"enddate"`
  23902. CashPayamt float64 `json:"cash_payamt"`
  23903. PsnType string `json:"psn_type"`
  23904. FixmedinsName string `json:"fixmedins_name"`
  23905. HifpPay float64 `json:"hifp_pay"`
  23906. NewFlag interface{} `json:"new_flag"`
  23907. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23908. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23909. PayLoc string `json:"pay_loc"`
  23910. ClrType string `json:"clr_type"`
  23911. RefdSetlFlag string `json:"refd_setl_flag"`
  23912. CvlservFlag string `json:"cvlserv_flag"`
  23913. EmpName string `json:"emp_name"`
  23914. Brdy int64 `json:"brdy"`
  23915. Naty string `json:"naty"`
  23916. Certno string `json:"certno"`
  23917. DiseCode string `json:"dise_code"`
  23918. FixmedinsCode string `json:"fixmedins_code"`
  23919. DedcHospLv string `json:"dedc_hosp_lv"`
  23920. OpterName string `json:"opter_name"`
  23921. Balc float64 `json:"balc"`
  23922. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23923. PsnCertType string `json:"psn_cert_type"`
  23924. HifobPay float64 `json:"hifob_pay"`
  23925. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23926. HifesPay float64 `json:"hifes_pay"`
  23927. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23928. OptTime int64 `json:"opt_time"`
  23929. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23930. SetlID string `json:"setl_id"`
  23931. MafPay float64 `json:"maf_pay"`
  23932. PsnName string `json:"psn_name"`
  23933. InsuOptins interface{} `json:"insu_optins"`
  23934. PrefFundPay interface{} `json:"pref_fund_pay"`
  23935. ClrOptins string `json:"clr_optins"`
  23936. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23937. DiseName string `json:"dise_name"`
  23938. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23939. Age float64 `json:"age"`
  23940. DtrtCertType string `json:"dtrt_cert_type"`
  23941. HospLv string `json:"hosp_lv"`
  23942. PsnCashPay float64 `json:"psn_cash_pay"`
  23943. } `json:"setlinfo"`
  23944. } `json:"output"`
  23945. RefmsgTime string `json:"refmsg_time"`
  23946. RespondTime string `json:"respond_time"`
  23947. Signtype interface{} `json:"signtype"`
  23948. WarnMsg interface{} `json:"warn_msg"`
  23949. }
  23950. type ResultEleven10265 struct {
  23951. Cainfo string `json:"cainfo"`
  23952. ErrMsg string `json:"err_msg"`
  23953. InfRefmsgid string `json:"inf_refmsgid"`
  23954. Infcode string `json:"infcode"`
  23955. Output struct {
  23956. Setlinfo struct {
  23957. SetlTime string `json:"setl_time"`
  23958. CvlservPay float64 `json:"cvlserv_pay"`
  23959. Year string `json:"year"`
  23960. MedType string `json:"med_type"`
  23961. PsnPay float64 `json:"psn_pay"`
  23962. OpterID string `json:"opter_id"`
  23963. Begndate string `json:"begndate"`
  23964. FlxempeFlag string `json:"flxempe_flag"`
  23965. HifmiPay float64 `json:"hifmi_pay"`
  23966. PsnNo string `json:"psn_no"`
  23967. ActPayDedc float64 `json:"act_pay_dedc"`
  23968. MedinsSetlID interface{} `json:"medins_setl_id"`
  23969. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23970. ClrWay string `json:"clr_way"`
  23971. OthPay float64 `json:"oth_pay"`
  23972. Gend string `json:"gend"`
  23973. MdtrtID string `json:"mdtrt_id"`
  23974. AcctPay float64 `json:"acct_pay"`
  23975. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23976. Insutype string `json:"insutype"`
  23977. Invono interface{} `json:"invono"`
  23978. Enddate string `json:"enddate"`
  23979. CashPayamt float64 `json:"cash_payamt"`
  23980. PsnType string `json:"psn_type"`
  23981. FixmedinsName string `json:"fixmedins_name"`
  23982. HifpPay float64 `json:"hifp_pay"`
  23983. NewFlag interface{} `json:"new_flag"`
  23984. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23985. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23986. PayLoc string `json:"pay_loc"`
  23987. ClrType string `json:"clr_type"`
  23988. RefdSetlFlag string `json:"refd_setl_flag"`
  23989. CvlservFlag string `json:"cvlserv_flag"`
  23990. EmpName string `json:"emp_name"`
  23991. Brdy string `json:"brdy"`
  23992. Naty string `json:"naty"`
  23993. Certno string `json:"certno"`
  23994. DiseCode string `json:"dise_code"`
  23995. FixmedinsCode string `json:"fixmedins_code"`
  23996. DedcHospLv string `json:"dedc_hosp_lv"`
  23997. OpterName string `json:"opter_name"`
  23998. Balc float64 `json:"balc"`
  23999. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  24000. PsnCertType string `json:"psn_cert_type"`
  24001. HifobPay float64 `json:"hifob_pay"`
  24002. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24003. HifesPay float64 `json:"hifes_pay"`
  24004. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24005. OptTime string `json:"opt_time"`
  24006. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24007. SetlID string `json:"setl_id"`
  24008. MafPay float64 `json:"maf_pay"`
  24009. PsnName string `json:"psn_name"`
  24010. InsuOptins interface{} `json:"insu_optins"`
  24011. PrefFundPay interface{} `json:"pref_fund_pay"`
  24012. ClrOptins string `json:"clr_optins"`
  24013. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  24014. DiseName string `json:"dise_name"`
  24015. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  24016. Age float64 `json:"age"`
  24017. DtrtCertType string `json:"dtrt_cert_type"`
  24018. HospLv string `json:"hosp_lv"`
  24019. PsnCashPay float64 `json:"psn_cash_pay"`
  24020. } `json:"setlinfo"`
  24021. } `json:"output"`
  24022. RefmsgTime string `json:"refmsg_time"`
  24023. RespondTime string `json:"respond_time"`
  24024. Signtype interface{} `json:"signtype"`
  24025. WarnMsg interface{} `json:"warn_msg"`
  24026. }
  24027. type ResultTwelve struct {
  24028. Cainfo string `json:"cainfo"`
  24029. ErrMsg string `json:"err_msg"`
  24030. InfRefmsgid string `json:"inf_refmsgid"`
  24031. Infcode int64 `json:"infcode"`
  24032. Output struct {
  24033. MdtrtId string `json:"mdtrt_id"`
  24034. ChrgBchno string `json:"chrg_bchno"`
  24035. PsnNo string `json:"psn_no"`
  24036. } `json:"output"`
  24037. RefmsgTime string `json:"refmsg_time"`
  24038. RespondTime string `json:"respond_time"`
  24039. Signtype interface{} `json:"signtype"`
  24040. WarnMsg interface{} `json:"warn_msg"`
  24041. }
  24042. type ResultThirteen struct {
  24043. ErrMsg string `json:"err_msg"`
  24044. InfRefmsgid string `json:"inf_refmsgid"`
  24045. Infcode int64 `json:"infcode"`
  24046. Output struct {
  24047. Result struct {
  24048. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  24049. } `json:"result"`
  24050. } `json:"output"`
  24051. RefmsgTime string `json:"refmsg_time"`
  24052. RespondTime string `json:"respond_time"`
  24053. Signtype interface{} `json:"signtype"`
  24054. WarnInfo interface{} `json:"warn_info"`
  24055. }
  24056. type ResultThirteen10265 struct {
  24057. ErrMsg string `json:"err_msg"`
  24058. InfRefmsgid string `json:"inf_refmsgid"`
  24059. Infcode string `json:"infcode"`
  24060. Output struct {
  24061. Result struct {
  24062. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  24063. } `json:"result"`
  24064. } `json:"output"`
  24065. RefmsgTime string `json:"refmsg_time"`
  24066. RespondTime string `json:"respond_time"`
  24067. Signtype interface{} `json:"signtype"`
  24068. WarnInfo interface{} `json:"warn_info"`
  24069. }
  24070. type ResultFourteen struct {
  24071. ErrMsg string `json:"err_msg"`
  24072. InfRefmsgid string `json:"inf_refmsgid"`
  24073. Infcode int64 `json:"infcode"`
  24074. Output struct {
  24075. } `json:"output"`
  24076. RefmsgTime string `json:"refmsg_time"`
  24077. RespondTime string `json:"respond_time"`
  24078. Signtype interface{} `json:"signtype"`
  24079. WarnInfo interface{} `json:"warn_info"`
  24080. }
  24081. type ResultCFYLJG001 struct {
  24082. ErrMsg string `json:"err_msg"`
  24083. InfRefmsgid string `json:"inf_refmsgid"`
  24084. Infcode int64 `json:"infcode"`
  24085. Output struct {
  24086. RxTraceCode string `json:"rx_trace_code"`
  24087. HiRxno string `json:"hi_rxno"`
  24088. } `json:"output"`
  24089. RefmsgTime string `json:"refmsg_time"`
  24090. RespondTime string `json:"respond_time"`
  24091. Signtype interface{} `json:"signtype"`
  24092. WarnInfo interface{} `json:"warn_info"`
  24093. }
  24094. type ResultCFYLJG001AH struct {
  24095. RxTraceCode string `json:"rxTraceCode"`
  24096. HiRxno string `json:"hiRxno"`
  24097. }
  24098. type ResultCFYLJG007 struct {
  24099. ErrMsg string `json:"err_msg"`
  24100. InfRefmsgid string `json:"inf_refmsgid"`
  24101. Infcode int64 `json:"infcode"`
  24102. Output struct {
  24103. HiRxno string `json:"hi_rxno"`
  24104. RxStasName string `json:"rx_stas_name"`
  24105. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  24106. Seltdelts []interface{} `json:"seltdelts"`
  24107. RxUsedStasName string `json:"rx_used_stas_name"`
  24108. RxStasCodg string `json:"rx_stas_codg"`
  24109. } `json:"output"`
  24110. RefmsgTime string `json:"refmsg_time"`
  24111. RespondTime string `json:"respond_time"`
  24112. Signtype interface{} `json:"signtype"`
  24113. WarnInfo interface{} `json:"warn_info"`
  24114. }
  24115. type ResultCFYLJG002 struct {
  24116. ErrMsg string `json:"err_msg"`
  24117. InfRefmsgid string `json:"inf_refmsgid"`
  24118. Infcode int64 `json:"infcode"`
  24119. Output struct {
  24120. RxFile string `json:"rx_file"`
  24121. SignDigest string `json:"sign_digest"`
  24122. SignCertSn string `json:"sign_cert_sn"`
  24123. SignCertDn string `json:"sign_cert_dn"`
  24124. } `json:"output"`
  24125. RefmsgTime string `json:"refmsg_time"`
  24126. RespondTime string `json:"respond_time"`
  24127. Signtype interface{} `json:"signtype"`
  24128. WarnInfo interface{} `json:"warn_info"`
  24129. }
  24130. type ResultCFYLJG003 struct {
  24131. ErrMsg string `json:"err_msg"`
  24132. InfRefmsgid string `json:"inf_refmsgid"`
  24133. Infcode int64 `json:"infcode"`
  24134. Output struct {
  24135. HiRxno string `json:"hi_rxno"`
  24136. RxStasCodg string `json:"rx_stas_codg"`
  24137. RxStasName string `json:"rx_stas_name"`
  24138. } `json:"output"`
  24139. RefmsgTime string `json:"refmsg_time"`
  24140. RespondTime string `json:"respond_time"`
  24141. Signtype interface{} `json:"signtype"`
  24142. WarnInfo interface{} `json:"warn_info"`
  24143. }
  24144. type ResultCFYLJG004 struct {
  24145. ErrMsg string `json:"err_msg"`
  24146. InfRefmsgid string `json:"inf_refmsgid"`
  24147. Infcode int64 `json:"infcode"`
  24148. Output struct {
  24149. HiRxno string `json:"hi_rxno"`
  24150. RxStasCodg string `json:"rx_stas_codg"`
  24151. RxStasName string `json:"rx_stas_name"`
  24152. } `json:"output"`
  24153. RefmsgTime string `json:"refmsg_time"`
  24154. RespondTime string `json:"respond_time"`
  24155. Signtype interface{} `json:"signtype"`
  24156. WarnInfo interface{} `json:"warn_info"`
  24157. }
  24158. type ResultCFYLJG008 struct {
  24159. ErrMsg string `json:"err_msg"`
  24160. InfRefmsgid string `json:"inf_refmsgid"`
  24161. Infcode int64 `json:"infcode"`
  24162. Output struct {
  24163. PoolareaNo string `json:"poolareaNo"`
  24164. AdmdvsName string `json:"admdvsName"`
  24165. Count string `json:"count"`
  24166. } `json:"output"`
  24167. RefmsgTime string `json:"refmsg_time"`
  24168. RespondTime string `json:"respond_time"`
  24169. Signtype interface{} `json:"signtype"`
  24170. WarnInfo interface{} `json:"warn_info"`
  24171. }
  24172. type ResultCFYLJG005 struct {
  24173. ErrMsg string `json:"err_msg"`
  24174. InfRefmsgid string `json:"inf_refmsgid"`
  24175. Infcode int64 `json:"infcode"`
  24176. Output struct {
  24177. HiRxNo string `json:"hi_rxno"`
  24178. FixMedinsCode string `json:"fixmedins_code"`
  24179. FixMedinsName string `json:"fixmedins_name"`
  24180. RxStasCodg string `json:"rx_stas_codg"`
  24181. RxStasName string `json:"rx_stas_name"`
  24182. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  24183. RxUserdStasName string `json:"rx_userd_stas_name"`
  24184. PrscTime string `json:"prsc_time"`
  24185. RxDrugCnt float64 `json:"rx_drug_cnt"`
  24186. RxUsedWayCodg string `json:"rx_used_way_codg"`
  24187. RxUsedWayName string `json:"rx_used_way_name"`
  24188. RxFrquCodg string `json:"rx_frqu_codg"`
  24189. RxFrquName string `json:"rx_frqu_name"`
  24190. RxDosunt string `json:"rx_dosunt"`
  24191. RxDoscnt float64 `json:"rx_doscnt"`
  24192. RxDrordDscr string `json:"rx_drord_dscr"`
  24193. ValiDays int64 `json:"vali_days"`
  24194. ValiEndTime string `json:"vali_end_time"`
  24195. ReptFlag string `json:"rept_flag"`
  24196. MaxReptCnt int64 `json:"max_rept_cnt"`
  24197. ReptdCnt int64 `json:"reptd_cnt"`
  24198. MinInrvDays int64 `json:"min_inrv_days"`
  24199. RxTypeCode string `json:"rx_type_code"`
  24200. RxTypeName string `json:"rx_type_name"`
  24201. LongRxFlag string `json:"long_rx_flag"`
  24202. RxDetlList []struct {
  24203. MedListCodg string `json:"med_list_codg"`
  24204. MedinsListCodg string `json:"medins_list_codg"`
  24205. HospPrepFlag string `json:"hosp_prep_flag"`
  24206. RxItemTypeCode string `json:"rx_item_type_code"`
  24207. RxItemTypeName string `json:"rx_item_type_name"`
  24208. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  24209. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  24210. TcmHerbFoote string `json:"tcmherb_foote"`
  24211. MednTypeCode string `json:"medn_type_code"`
  24212. MednTypeName string `json:"medn_type_name"`
  24213. MainMedcFlag string `json:"main_medc_flag"`
  24214. UrgtFlag string `json:"urgt_flag"`
  24215. BasMednFlag string `json:"bas_medn_flag"`
  24216. ImpDrugFlag string `json:"imp_drug_flag"`
  24217. ProdBarc string `json:"prod_barc"`
  24218. DrugProdname string `json:"drug_prodname"`
  24219. GennameCodg string `json:"genname_codg"`
  24220. DrugGenname string `json:"drug_genname"`
  24221. DrugDosform string `json:"drug_dosform"`
  24222. DrugSpec string `json:"drug_spec"`
  24223. PrdrName string `json:"prdr_name"`
  24224. MedcWayCodg string `json:"medc_way_codg"`
  24225. MedcWayDscr string `json:"medc_way_dscr"`
  24226. MedcBegntime string `json:"medc_begntime"`
  24227. MedcEndtime string `json:"medc_endtime"`
  24228. MedcDays float64 `json:"medc_days"`
  24229. DrugPric float64 `json:"drug_pric"`
  24230. DrugSumamt float64 `json:"drug_sumamt"`
  24231. DrugCnt float64 `json:"drug_cnt"`
  24232. DrugDosunt string `json:"drug_dosunt"`
  24233. SinDoscnt float64 `json:"sin_doscnt"`
  24234. SinDosunt string `json:"sin_dosunt"`
  24235. UsedFrquCodg string `json:"used_frqu_codg"`
  24236. UsedFrquName string `json:"used_frqu_name"`
  24237. DrugTotlcnt string `json:"drug_totlcnt"`
  24238. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  24239. DiseCodg string `json:"dise_codg"`
  24240. HospApprFlag string `json:"hosp_appr_flag"`
  24241. } `json:"rx_detl_list"`
  24242. RxOtpinfo struct {
  24243. MedType string `json:"med_type"`
  24244. IptOtpNo string `json:"ipt_otp_no"`
  24245. OtpIptFlag string `json:"otp_ipt_flag"`
  24246. PatnName string `json:"patn_name"`
  24247. PatnAge float64 `json:"patn_age"`
  24248. PatnHgt float64 `json:"patn_hgt"`
  24249. PatnWt float64 `json:"patn_wt"`
  24250. Gend string `json:"gend"`
  24251. GesoVal float64 `json:"geso_val"`
  24252. NwbFlag string `json:"nwb_flag"`
  24253. NwbAge string `json:"nwb_age"`
  24254. SuckPrdFlag string `json:"suck_prd_flag"`
  24255. AlgsHis string `json:"algs_his"`
  24256. Insutype string `json:"insutype"`
  24257. PrscDeptName string `json:"prsc_dept_name"`
  24258. PrscDrName string `json:"prsc_dr_name"`
  24259. PharName string `json:"phar_name"`
  24260. PharChkTime string `json:"phar_chk_time"`
  24261. MdtrtTime string `json:"mdtrt_time"`
  24262. DiseCodg string `json:"dise_codg"`
  24263. DiseName string `json:"dise_name"`
  24264. SpDiseFlag string `json:"sp_dise_flag"`
  24265. MaindiagCode string `json:"maindiag_code"`
  24266. MaindiagName string `json:"maindiag_name"`
  24267. DiseCondDscr string `json:"dise_cond_dscr"`
  24268. FstdiagFlag string `json:"fstdiag_flag"`
  24269. } `json:"rx_otpinfo"`
  24270. RxDiseList []struct {
  24271. DiagType string `json:"diag_type"`
  24272. MaindiagFlag string `json:"maindiag_flag"`
  24273. DiagSrtNo string `json:"diag_srt_no"`
  24274. DiagCode string `json:"diag_code"`
  24275. DiagName string `json:"diag_name"`
  24276. DiagDept string `json:"diag_dept"`
  24277. DiagDrNo string `json:"diag_dr_no"`
  24278. DiagDrName string `json:"diag_dr_name"`
  24279. DiagTime string `json:"diag_time"`
  24280. TcmDiseCode string `json:"tcm_dise_code"`
  24281. TcmDiseName string `json:"tcm_dise_name"`
  24282. TcmSympCode string `json:"tcmsymp_code"`
  24283. TcmSymp string `json:"tcmsymp"`
  24284. } `json:"rx_dise_list"`
  24285. } `json:"output"`
  24286. RefmsgTime string `json:"refmsg_time"`
  24287. RespondTime string `json:"respond_time"`
  24288. Signtype interface{} `json:"signtype"`
  24289. WarnInfo interface{} `json:"warn_info"`
  24290. }
  24291. type ResultCFYLJG006 struct {
  24292. ErrMsg string `json:"err_msg"`
  24293. InfRefmsgid string `json:"inf_refmsgid"`
  24294. Infcode int64 `json:"infcode"`
  24295. Output struct {
  24296. HiRxNo string `json:"hi_rxno"`
  24297. PharCode string `json:"phar_code"`
  24298. PharName string `json:"phar_name"`
  24299. RxChkOpnn string `json:"rx_chk_opnn"`
  24300. RxChkTime string `json:"rx_chk_time"`
  24301. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  24302. RxChkStasName string `json:"rx_chk_stas_name"`
  24303. RxStasCodg string `json:"rx_stas_codg"`
  24304. RxStasName string `json:"rx_stas_name"`
  24305. } `json:"output"`
  24306. RefmsgTime string `json:"refmsg_time"`
  24307. RespondTime string `json:"respond_time"`
  24308. Signtype interface{} `json:"signtype"`
  24309. WarnInfo interface{} `json:"warn_info"`
  24310. }
  24311. type ResultFourteen10265 struct {
  24312. ErrMsg string `json:"err_msg"`
  24313. InfRefmsgid string `json:"inf_refmsgid"`
  24314. Infcode string `json:"infcode"`
  24315. Output struct {
  24316. } `json:"output"`
  24317. RefmsgTime string `json:"refmsg_time"`
  24318. RespondTime string `json:"respond_time"`
  24319. Signtype interface{} `json:"signtype"`
  24320. WarnInfo interface{} `json:"warn_info"`
  24321. }
  24322. type ResultSixteen struct {
  24323. Cainfo string `json:"cainfo"`
  24324. ErrMsg string `json:"err_msg"`
  24325. InfRefmsgid string `json:"inf_refmsgid"`
  24326. Infcode int64 `json:"infcode"`
  24327. Output struct {
  24328. Setlinfo struct {
  24329. MdtrtID string `json:"mdtrt_id"`
  24330. SetlID string `json:"setl_id"`
  24331. ClrOptins string `json:"clr_optins"`
  24332. SetlTime string `json:"setl_time"`
  24333. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24334. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24335. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24336. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24337. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24338. ActPayDedc float64 `json:"act_pay_dedc"`
  24339. HifpPay float64 `json:"hifp_pay"`
  24340. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24341. Lfpay float64 `json:"selfpay"`
  24342. CvlservPay float64 `json:"cvlserv_pay"`
  24343. HifesPay float64 `json:"hifes_pay"`
  24344. HifmiPay float64 `json:"hifmi_pay"`
  24345. HifobPay float64 `json:"hifob_pay"`
  24346. MafPay float64 `json:"maf_pay"`
  24347. OthPay float64 `json:"oth_pay"`
  24348. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24349. PsnPartAmt float64 `json:"psn_part_amt"`
  24350. AcctPay float64 `json:"acct_pay"`
  24351. Balc float64 `json:"balc"`
  24352. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24353. HospPartAmt float64 `json:"hosp_part_amt"`
  24354. MedinsSetlID string `json:"medins_setl_id"`
  24355. PdnCashPay string `json:"pdn_cash_pay"`
  24356. } `json:"setlinfo"`
  24357. } `json:"output"`
  24358. RefmsgTime string `json:"refmsg_time"`
  24359. RespondTime string `json:"respond_time"`
  24360. Signtype interface{} `json:"signtype"`
  24361. WarnMsg interface{} `json:"warn_msg"`
  24362. }
  24363. type ResultSixteen10265 struct {
  24364. Cainfo string `json:"cainfo"`
  24365. ErrMsg string `json:"err_msg"`
  24366. InfRefmsgid string `json:"inf_refmsgid"`
  24367. Infcode string `json:"infcode"`
  24368. Output struct {
  24369. Setlinfo struct {
  24370. MdtrtID string `json:"mdtrt_id"`
  24371. SetlID string `json:"setl_id"`
  24372. ClrOptins string `json:"clr_optins"`
  24373. SetlTime string `json:"setl_time"`
  24374. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24375. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24376. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24377. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24378. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24379. ActPayDedc float64 `json:"act_pay_dedc"`
  24380. HifpPay float64 `json:"hifp_pay"`
  24381. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24382. Lfpay float64 `json:"selfpay"`
  24383. CvlservPay float64 `json:"cvlserv_pay"`
  24384. HifesPay float64 `json:"hifes_pay"`
  24385. HifmiPay float64 `json:"hifmi_pay"`
  24386. HifobPay float64 `json:"hifob_pay"`
  24387. MafPay float64 `json:"maf_pay"`
  24388. OthPay float64 `json:"oth_pay"`
  24389. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24390. PsnPartAmt float64 `json:"psn_part_amt"`
  24391. AcctPay float64 `json:"acct_pay"`
  24392. Balc float64 `json:"balc"`
  24393. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24394. HospPartAmt float64 `json:"hosp_part_amt"`
  24395. MedinsSetlID string `json:"medins_setl_id"`
  24396. PdnCashPay string `json:"pdn_cash_pay"`
  24397. } `json:"setlinfo"`
  24398. } `json:"output"`
  24399. RefmsgTime string `json:"refmsg_time"`
  24400. RespondTime string `json:"respond_time"`
  24401. Signtype interface{} `json:"signtype"`
  24402. WarnMsg interface{} `json:"warn_msg"`
  24403. }
  24404. type ResultSixteen10265Two struct {
  24405. Cainfo string `json:"cainfo"`
  24406. ErrMsg string `json:"err_msg"`
  24407. InfRefmsgid string `json:"inf_refmsgid"`
  24408. Infcode string `json:"infcode"`
  24409. Output struct {
  24410. Setlinfo interface{} `json:"setlinfo"`
  24411. } `json:"output"`
  24412. RefmsgTime string `json:"refmsg_time"`
  24413. RespondTime string `json:"respond_time"`
  24414. Signtype interface{} `json:"signtype"`
  24415. WarnMsg interface{} `json:"warn_msg"`
  24416. }
  24417. type ResultgzSixteen10265Two struct {
  24418. Cainfo string `json:"cainfo"`
  24419. ErrMsg string `json:"err_msg"`
  24420. InfRefmsgid string `json:"inf_refmsgid"`
  24421. Infcode int64 `json:"infcode"`
  24422. Output struct {
  24423. Setlinfo interface{} `json:"setlinfo"`
  24424. } `json:"output"`
  24425. RefmsgTime string `json:"refmsg_time"`
  24426. RespondTime string `json:"respond_time"`
  24427. Signtype interface{} `json:"signtype"`
  24428. WarnMsg interface{} `json:"warn_msg"`
  24429. }
  24430. type ResultSeventeen struct {
  24431. ErrMsg string `json:"err_msg"`
  24432. InfRefmsgid string `json:"inf_refmsgid"`
  24433. Infcode int64 `json:"infcode"`
  24434. Output struct {
  24435. SetlListId string `json:"setl_list_id"`
  24436. } `json:"output"`
  24437. RefmsgTime string `json:"refmsg_time"`
  24438. RespondTime string `json:"respond_time"`
  24439. Signtype string `json:"signtype"`
  24440. WarnInfo string `json:"warn_info"`
  24441. }
  24442. type ResultSeventeenOther struct {
  24443. ErrMsg string `json:"err_msg"`
  24444. InfRefmsgid string `json:"inf_refmsgid"`
  24445. Infcode string `json:"infcode"`
  24446. Output struct {
  24447. SetlListId string `json:"setl_list_id"`
  24448. } `json:"output"`
  24449. RefmsgTime string `json:"refmsg_time"`
  24450. RespondTime string `json:"respond_time"`
  24451. Signtype string `json:"signtype"`
  24452. WarnInfo string `json:"warn_info"`
  24453. }
  24454. type Result90991 struct {
  24455. ErrMsg string `json:"err_msg"`
  24456. InfRefmsgid string `json:"inf_refmsgid"`
  24457. Infcode int64 `json:"infcode"`
  24458. Output struct {
  24459. Result struct {
  24460. PsnNo string `json:"psn_no"`
  24461. CardStat string `json:"card_stat"`
  24462. Certno string `json:"certno"`
  24463. PsnName string `json:"psn_name"`
  24464. CheckStat string `json:"check_stat"`
  24465. SscnoCheckStat string `json:"sscno_check_stat"`
  24466. } `json:"result"`
  24467. } `json:"output"`
  24468. RefmsgTime string `json:"refmsg_time"`
  24469. RespondTime string `json:"respond_time"`
  24470. Signtype interface{} `json:"signtype"`
  24471. WarnInfo interface{} `json:"warn_info"`
  24472. }
  24473. type Result90100 struct {
  24474. ErrMsg string `json:"err_msg"`
  24475. InfRefmsgid string `json:"inf_refmsgid"`
  24476. Infcode int64 `json:"infcode"`
  24477. Output struct {
  24478. PoolareaNo string `json:"poolarea_no"`
  24479. PoolareaNoName string `json:"poolarea_no_name"`
  24480. Insutype string `json:"insutype"`
  24481. InsutypeName string `json:"insutype_name"`
  24482. ClctType string `json:"clct_type"`
  24483. ClctTypeName string `json:"clct_type_name"`
  24484. ClctFlag string `json:"clct_flag"`
  24485. ClctFlagName string `json:"clct_flag_name"`
  24486. AccrymBegn string `json:"accrym_begn"`
  24487. AccrymEnd string `json:"accrym_end"`
  24488. ClctTime string `json:"clct_time"`
  24489. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  24490. } `json:"output"`
  24491. RefmsgTime string `json:"refmsg_time"`
  24492. RespondTime string `json:"respond_time"`
  24493. Signtype interface{} `json:"signtype"`
  24494. WarnInfo interface{} `json:"warn_info"`
  24495. }
  24496. type Custom struct {
  24497. DetItemFeeSumamt string
  24498. Cut string
  24499. FeedetlSn string
  24500. Price string
  24501. MedListCodg string
  24502. Type int64
  24503. AdviceId int64
  24504. ProjectId int64
  24505. ItemId int64
  24506. }
  24507. type Result5301 struct {
  24508. ErrMsg string `json:"err_msg"`
  24509. InfRefmsgid string `json:"inf_refmsgid"`
  24510. Infcode int64 `json:"infcode"`
  24511. Output struct {
  24512. Result []struct {
  24513. OpspDiseCode string `json:"opsp_dise_code"`
  24514. OpspDiseName string `json:"opsp_dise_name"`
  24515. Begndate string `json:"begndate"`
  24516. Enddate string `json:"enddate"`
  24517. } `json:"feedetail"`
  24518. } `json:"output"`
  24519. RefmsgTime string `json:"refmsg_time"`
  24520. RespondTime string `json:"respond_time"`
  24521. Signtype interface{} `json:"signtype"`
  24522. WarnInfo interface{} `json:"warn_info"`
  24523. }
  24524. type Result5301For10265 struct {
  24525. ErrMsg string `json:"err_msg"`
  24526. InfRefmsgid string `json:"inf_refmsgid"`
  24527. Infcode string `json:"infcode"`
  24528. Output struct {
  24529. Result []struct {
  24530. OpspDiseCode string `json:"opsp_dise_code"`
  24531. OpspDiseName string `json:"opsp_dise_name"`
  24532. Begndate string `json:"begndate"`
  24533. Enddate string `json:"enddate"`
  24534. } `json:"feedetail"`
  24535. } `json:"output"`
  24536. RefmsgTime string `json:"refmsg_time"`
  24537. RespondTime string `json:"respond_time"`
  24538. Signtype interface{} `json:"signtype"`
  24539. WarnInfo interface{} `json:"warn_info"`
  24540. }
  24541. //获取个人信息----挂号-----上传就诊信息
  24542. func (c *HisApiController) GetRegisterInfo() {
  24543. id, _ := c.GetInt64("id")
  24544. record_time := c.GetString("record_time")
  24545. settlementValue, _ := c.GetInt64("settlement_value")
  24546. medical_insurance_card := c.GetString("medical_insurance_card")
  24547. name := c.GetString("name")
  24548. id_card_type, _ := c.GetInt64("id_card_type")
  24549. certificates, _ := c.GetInt64("certificates")
  24550. medical_care, _ := c.GetInt64("medical_care")
  24551. birthday := c.GetString("birthday")
  24552. id_card := c.GetString("id_card")
  24553. register_type, _ := c.GetInt64("register")
  24554. doctor, _ := c.GetInt64("doctor")
  24555. department, _ := c.GetInt64("department")
  24556. gender, _ := c.GetInt64("sex")
  24557. registration_fee, _ := c.GetFloat("registration_fee")
  24558. medical_expenses, _ := c.GetFloat("medical_expenses")
  24559. social_type, _ := c.GetInt64("social_type")
  24560. admin_user_id, _ := c.GetInt64("admin_user_id")
  24561. insuplc_admdvs := c.GetString("insuplc_admdvs")
  24562. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  24563. mdtrt_type := c.GetString("mdtrt_type")
  24564. if id_card_type == 5 {
  24565. id_card_type = 4
  24566. }
  24567. timeLayout := "2006-01-02"
  24568. loc, _ := time.LoadLocation("Local")
  24569. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  24570. birthUnix := birthdays.Unix()
  24571. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24572. if err != nil {
  24573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24574. return
  24575. }
  24576. recordDateTime := theTime.Unix()
  24577. adminInfo := c.GetAdminUserInfo()
  24578. var patient service.Patients
  24579. if id == 0 {
  24580. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  24581. } else {
  24582. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  24583. }
  24584. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24585. if patientPrescription.ID == 0 {
  24586. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24587. }
  24588. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  24589. if patient.ID == 0 {
  24590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  24591. return
  24592. }
  24593. if len(patient.IdCardNo) == 0 {
  24594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  24595. return
  24596. }
  24597. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  24598. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  24599. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  24600. //就诊结算未完成,不能进行二次挂号
  24601. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  24602. if len(his) >= 1 {
  24603. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  24604. if len(his) >= 1 && order.ID == 0 {
  24605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  24606. return
  24607. }
  24608. }
  24609. var aaaa string
  24610. //var register_log string
  24611. if config.IsOpen == 1 {
  24612. var res ResultTwo
  24613. var res10265 ResultTwo10265
  24614. var PsnNo string
  24615. var PsnCertType string
  24616. var Certno string
  24617. var PsnName string
  24618. var Gend string
  24619. var Naty string
  24620. var Brdy string
  24621. var Age float64
  24622. var infoStr string
  24623. var idetinfoStr string
  24624. var infocode int64
  24625. var verify_number string
  24626. fmt.Println(verify_number)
  24627. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  24628. psn_info, _ := service.GetPsnByPatientId(id)
  24629. PsnNo = psn_info.PsnNo
  24630. PsnCertType = psn_info.PsnCertType
  24631. Certno = psn_info.Certno
  24632. PsnName = psn_info.PsnName
  24633. Gend = psn_info.Gend
  24634. Naty = psn_info.Naty
  24635. Brdy = psn_info.Brdy
  24636. Age = psn_info.Age
  24637. infoStr = psn_info.Insuinfo
  24638. idetinfoStr = psn_info.Idetinfo
  24639. infocode = 0
  24640. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  24641. psn_info, _ := service.GetPsnByPatientId(id)
  24642. PsnNo = psn_info.PsnNo
  24643. PsnCertType = psn_info.PsnCertType
  24644. Certno = psn_info.Certno
  24645. PsnName = psn_info.PsnName
  24646. Gend = psn_info.Gend
  24647. Naty = psn_info.Naty
  24648. Brdy = psn_info.Brdy
  24649. Age = psn_info.Age
  24650. infoStr = psn_info.Insuinfo
  24651. idetinfoStr = psn_info.Idetinfo
  24652. infocode = 0
  24653. verify_number = psn_info.VerifyNumber
  24654. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24655. if id_card_type == 2 {
  24656. //请求内网数据
  24657. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  24658. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24659. "&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
  24660. resp, requestErr := http.Get(api)
  24661. if requestErr != nil {
  24662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24663. return
  24664. }
  24665. body, ioErr := ioutil.ReadAll(resp.Body)
  24666. if ioErr != nil {
  24667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24669. return
  24670. }
  24671. var respJSON map[string]interface{}
  24672. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24675. return
  24676. }
  24677. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24678. result_byte, _ := json.Marshal(respJSON)
  24679. result := string(result_byte)
  24680. var dat map[string]interface{}
  24681. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24682. fmt.Println(dat)
  24683. } else {
  24684. fmt.Println(err)
  24685. }
  24686. userJSONBytes, _ := json.Marshal(dat)
  24687. var res ResultTwo
  24688. var resTwo10265 ResultTwo10265
  24689. if miConfig.Code == "H15049901371" {
  24690. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  24691. utils.ErrorLog("解析失败:%v", err)
  24692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24693. return
  24694. }
  24695. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  24696. res.Infcode = Infcode
  24697. res.ErrMsg = resTwo10265.ErrMsg
  24698. res.Output = resTwo10265.Output
  24699. res.InfRefmsgid = resTwo10265.InfRefmsgid
  24700. res.RespondTime = resTwo10265.RespondTime
  24701. res.WarnInfo = resTwo10265.WarnInfo
  24702. } else {
  24703. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24704. utils.ErrorLog("解析失败:%v", err)
  24705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24706. return
  24707. }
  24708. }
  24709. //var insutypes []string
  24710. //var insutype string
  24711. //var is390 int = 0
  24712. //var is310 int = 0
  24713. //for _, item := range res.Output.Iinfo {
  24714. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24715. // insutypes = append(insutypes, item.Insutype)
  24716. // }
  24717. //}
  24718. //if len(insutypes) == 1 {
  24719. // insutype = insutypes[0]
  24720. //} else {
  24721. // for _, i := range insutypes {
  24722. // if i == "390" {
  24723. // is390 = 1
  24724. // }
  24725. //
  24726. // if i == "310" {
  24727. // is310 = 1
  24728. // }
  24729. // }
  24730. //}
  24731. //if is390 == 1 {
  24732. // insutype = "390"
  24733. //}
  24734. //if is310 == 1 {
  24735. // insutype = "310"
  24736. //}
  24737. //if len(insutypes) == 0 {
  24738. // insutype = "310"
  24739. //}
  24740. PsnNo = res.Output.Baseinfo.PsnNo
  24741. PsnCertType = res.Output.Baseinfo.PsnCertType
  24742. Certno = res.Output.Baseinfo.Certno
  24743. PsnName = res.Output.Baseinfo.PsnName
  24744. Gend = res.Output.Baseinfo.Gend
  24745. Naty = res.Output.Baseinfo.Naty
  24746. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24747. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24748. infoStr = string(Iinfos)
  24749. idetinfoStr = string(Idetinfos)
  24750. infocode = res.Infcode
  24751. //infocode = 0
  24752. //verify_number = psn_info.VerifyNumber
  24753. } else {
  24754. psn_info, _ := service.GetPsnByPatientId(id)
  24755. PsnNo = psn_info.PsnNo
  24756. PsnCertType = psn_info.PsnCertType
  24757. Certno = psn_info.Certno
  24758. PsnName = psn_info.PsnName
  24759. Gend = psn_info.Gend
  24760. Naty = psn_info.Naty
  24761. Brdy = psn_info.Brdy
  24762. Age = psn_info.Age
  24763. infoStr = psn_info.Insuinfo
  24764. idetinfoStr = psn_info.Idetinfo
  24765. infocode = 0
  24766. verify_number = psn_info.VerifyNumber
  24767. }
  24768. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24769. if id_card_type == 1 {
  24770. psn_info, _ := service.GetPsnByPatientId(id)
  24771. PsnNo = psn_info.PsnNo
  24772. PsnCertType = psn_info.PsnCertType
  24773. Certno = psn_info.Certno
  24774. PsnName = psn_info.PsnName
  24775. Gend = psn_info.Gend
  24776. Naty = psn_info.Naty
  24777. Brdy = psn_info.Brdy
  24778. Age = psn_info.Age
  24779. infoStr = psn_info.Insuinfo
  24780. idetinfoStr = psn_info.Idetinfo
  24781. infocode = 0
  24782. verify_number = psn_info.VerifyNumber
  24783. } else if id_card_type == 2 {
  24784. 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)
  24785. fmt.Println(errMsgLog)
  24786. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24787. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24788. utils.ErrorLog("解析失败:%v", err)
  24789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24790. return
  24791. }
  24792. PsnNo = res.Output.Baseinfo.PsnNo
  24793. PsnCertType = res.Output.Baseinfo.PsnCertType
  24794. Certno = res.Output.Baseinfo.Certno
  24795. PsnName = res.Output.Baseinfo.PsnName
  24796. Gend = res.Output.Baseinfo.Gend
  24797. Naty = res.Output.Baseinfo.Naty
  24798. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24799. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24800. infoStr = string(Iinfos)
  24801. idetinfoStr = string(Idetinfos)
  24802. infocode = res.Infcode
  24803. }
  24804. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24805. if id_card_type == 1 {
  24806. psn_info, _ := service.GetPsnByPatientId(id)
  24807. PsnNo = psn_info.PsnNo
  24808. PsnCertType = psn_info.PsnCertType
  24809. Certno = psn_info.Certno
  24810. PsnName = psn_info.PsnName
  24811. Gend = psn_info.Gend
  24812. Naty = psn_info.Naty
  24813. Brdy = psn_info.Brdy
  24814. Age = psn_info.Age
  24815. infoStr = psn_info.Insuinfo
  24816. idetinfoStr = psn_info.Idetinfo
  24817. infocode = 0
  24818. verify_number = psn_info.VerifyNumber
  24819. } else if id_card_type == 2 {
  24820. 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, "")
  24821. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24822. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24823. utils.ErrorLog("解析失败:%v", err)
  24824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24825. return
  24826. }
  24827. PsnNo = res.Output.Baseinfo.PsnNo
  24828. PsnCertType = res.Output.Baseinfo.PsnCertType
  24829. Certno = res.Output.Baseinfo.Certno
  24830. PsnName = res.Output.Baseinfo.PsnName
  24831. Gend = res.Output.Baseinfo.Gend
  24832. Naty = res.Output.Baseinfo.Naty
  24833. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24834. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24835. infoStr = string(Iinfos)
  24836. idetinfoStr = string(Idetinfos)
  24837. infocode = res.Infcode
  24838. } else {
  24839. psn_info, _ := service.GetPsnByPatientId(id)
  24840. PsnNo = psn_info.PsnNo
  24841. PsnCertType = psn_info.PsnCertType
  24842. Certno = psn_info.Certno
  24843. PsnName = psn_info.PsnName
  24844. Gend = psn_info.Gend
  24845. Naty = psn_info.Naty
  24846. Brdy = psn_info.Brdy
  24847. Age = psn_info.Age
  24848. infoStr = psn_info.Insuinfo
  24849. idetinfoStr = psn_info.Idetinfo
  24850. infocode = 0
  24851. verify_number = psn_info.VerifyNumber
  24852. }
  24853. } else if miConfig.MdtrtareaAdmvs == "361025" {
  24854. if id_card_type == 1 {
  24855. psn_info, _ := service.GetPsnByPatientId(id)
  24856. PsnNo = psn_info.PsnNo
  24857. PsnCertType = psn_info.PsnCertType
  24858. Certno = psn_info.Certno
  24859. PsnName = psn_info.PsnName
  24860. Gend = psn_info.Gend
  24861. Naty = psn_info.Naty
  24862. Brdy = psn_info.Brdy
  24863. Age = psn_info.Age
  24864. infoStr = psn_info.Insuinfo
  24865. idetinfoStr = psn_info.Idetinfo
  24866. infocode = 0
  24867. verify_number = psn_info.VerifyNumber
  24868. } else if id_card_type == 2 {
  24869. psn_info, _ := service.GetPsnByPatientId(id)
  24870. PsnNo = psn_info.PsnNo
  24871. PsnCertType = psn_info.PsnCertType
  24872. Certno = psn_info.Certno
  24873. PsnName = psn_info.PsnName
  24874. Gend = psn_info.Gend
  24875. Naty = psn_info.Naty
  24876. Brdy = psn_info.Brdy
  24877. Age = psn_info.Age
  24878. infoStr = psn_info.Insuinfo
  24879. idetinfoStr = psn_info.Idetinfo
  24880. infocode = 0
  24881. verify_number = psn_info.VerifyNumber
  24882. } else {
  24883. psn_info, _ := service.GetPsnByPatientId(id)
  24884. PsnNo = psn_info.PsnNo
  24885. PsnCertType = psn_info.PsnCertType
  24886. Certno = psn_info.Certno
  24887. PsnName = psn_info.PsnName
  24888. Gend = psn_info.Gend
  24889. Naty = psn_info.Naty
  24890. Brdy = psn_info.Brdy
  24891. Age = psn_info.Age
  24892. infoStr = psn_info.Insuinfo
  24893. idetinfoStr = psn_info.Idetinfo
  24894. infocode = 0
  24895. verify_number = psn_info.VerifyNumber
  24896. }
  24897. } else if miConfig.MdtrtareaAdmvs == "360100" {
  24898. if id_card_type == 1 {
  24899. psn_info, _ := service.GetPsnByPatientId(id)
  24900. PsnNo = psn_info.PsnNo
  24901. PsnCertType = psn_info.PsnCertType
  24902. Certno = psn_info.Certno
  24903. PsnName = psn_info.PsnName
  24904. Gend = psn_info.Gend
  24905. Naty = psn_info.Naty
  24906. Brdy = psn_info.Brdy
  24907. Age = psn_info.Age
  24908. infoStr = psn_info.Insuinfo
  24909. idetinfoStr = psn_info.Idetinfo
  24910. infocode = 0
  24911. verify_number = psn_info.VerifyNumber
  24912. } else if id_card_type == 2 {
  24913. psn_info, _ := service.GetPsnByPatientId(id)
  24914. PsnNo = psn_info.PsnNo
  24915. PsnCertType = psn_info.PsnCertType
  24916. Certno = psn_info.Certno
  24917. PsnName = psn_info.PsnName
  24918. Gend = psn_info.Gend
  24919. Naty = psn_info.Naty
  24920. Brdy = psn_info.Brdy
  24921. Age = psn_info.Age
  24922. infoStr = psn_info.Insuinfo
  24923. idetinfoStr = psn_info.Idetinfo
  24924. infocode = 0
  24925. verify_number = psn_info.VerifyNumber
  24926. } else {
  24927. psn_info, _ := service.GetPsnByPatientId(id)
  24928. PsnNo = psn_info.PsnNo
  24929. PsnCertType = psn_info.PsnCertType
  24930. Certno = psn_info.Certno
  24931. PsnName = psn_info.PsnName
  24932. Gend = psn_info.Gend
  24933. Naty = psn_info.Naty
  24934. Brdy = psn_info.Brdy
  24935. Age = psn_info.Age
  24936. infoStr = psn_info.Insuinfo
  24937. idetinfoStr = psn_info.Idetinfo
  24938. infocode = 0
  24939. verify_number = psn_info.VerifyNumber
  24940. }
  24941. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  24942. psn_info, _ := service.GetPsnByPatientId(id)
  24943. PsnNo = psn_info.PsnNo
  24944. PsnCertType = psn_info.PsnCertType
  24945. Certno = psn_info.Certno
  24946. PsnName = psn_info.PsnName
  24947. Gend = psn_info.Gend
  24948. Naty = psn_info.Naty
  24949. Brdy = psn_info.Brdy
  24950. Age = psn_info.Age
  24951. infoStr = psn_info.Insuinfo
  24952. idetinfoStr = psn_info.Idetinfo
  24953. infocode = 0
  24954. verify_number = psn_info.VerifyNumber
  24955. idetinfoStr = psn_info.Idetinfo
  24956. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24957. if id_card_type == 1 {
  24958. psn_info, _ := service.GetPsnByPatientId(id)
  24959. PsnNo = psn_info.PsnNo
  24960. PsnCertType = psn_info.PsnCertType
  24961. Certno = psn_info.Certno
  24962. PsnName = psn_info.PsnName
  24963. Gend = psn_info.Gend
  24964. Naty = psn_info.Naty
  24965. Brdy = psn_info.Brdy
  24966. Age = psn_info.Age
  24967. infoStr = psn_info.Insuinfo
  24968. idetinfoStr = psn_info.Idetinfo
  24969. infocode = 0
  24970. verify_number = psn_info.VerifyNumber
  24971. } else if id_card_type == 2 {
  24972. 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)
  24973. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24974. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24975. utils.ErrorLog("解析失败:%v", err)
  24976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24977. return
  24978. }
  24979. PsnNo = res.Output.Baseinfo.PsnNo
  24980. PsnCertType = res.Output.Baseinfo.PsnCertType
  24981. Certno = res.Output.Baseinfo.Certno
  24982. PsnName = res.Output.Baseinfo.PsnName
  24983. Gend = res.Output.Baseinfo.Gend
  24984. Naty = res.Output.Baseinfo.Naty
  24985. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24986. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24987. infoStr = string(Iinfos)
  24988. idetinfoStr = string(Idetinfos)
  24989. infocode = res.Infcode
  24990. } else if id_card_type == 4 {
  24991. psn_info, _ := service.GetPsnByPatientId(id)
  24992. PsnNo = psn_info.PsnNo
  24993. PsnCertType = psn_info.PsnCertType
  24994. Certno = psn_info.Certno
  24995. PsnName = psn_info.PsnName
  24996. Gend = psn_info.Gend
  24997. Naty = psn_info.Naty
  24998. Brdy = psn_info.Brdy
  24999. Age = psn_info.Age
  25000. infoStr = psn_info.Insuinfo
  25001. idetinfoStr = psn_info.Idetinfo
  25002. infocode = 0
  25003. verify_number = psn_info.VerifyNumber
  25004. }
  25005. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25006. var result string
  25007. var requestLog string
  25008. 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), "")
  25009. if id_card_type == 4 {
  25010. psn_info, _ := service.GetPsnByPatientId(id)
  25011. PsnNo = psn_info.PsnNo
  25012. PsnCertType = psn_info.PsnCertType
  25013. Certno = psn_info.Certno
  25014. PsnName = psn_info.PsnName
  25015. Gend = psn_info.Gend
  25016. Naty = psn_info.Naty
  25017. Brdy = psn_info.Brdy
  25018. Age = psn_info.Age
  25019. infoStr = psn_info.Insuinfo
  25020. idetinfoStr = psn_info.Idetinfo
  25021. infocode = 0
  25022. verify_number = psn_info.VerifyNumber
  25023. } else {
  25024. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25025. if miConfig.Code == "H15049901371" {
  25026. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  25027. utils.ErrorLog("解析失败:%v", err)
  25028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25029. return
  25030. }
  25031. res.ErrMsg = res10265.ErrMsg
  25032. res.Output = res10265.Output
  25033. res.InfRefmsgid = res10265.InfRefmsgid
  25034. } else {
  25035. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25036. utils.ErrorLog("解析失败:%v", err)
  25037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25038. return
  25039. }
  25040. }
  25041. PsnNo = res.Output.Baseinfo.PsnNo
  25042. PsnCertType = res.Output.Baseinfo.PsnCertType
  25043. Certno = res.Output.Baseinfo.Certno
  25044. PsnName = res.Output.Baseinfo.PsnName
  25045. Gend = res.Output.Baseinfo.Gend
  25046. Naty = res.Output.Baseinfo.Naty
  25047. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25048. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25049. infoStr = string(Iinfos)
  25050. idetinfoStr = string(Idetinfos)
  25051. if miConfig.Code == "H15049901371" {
  25052. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25053. } else {
  25054. infocode = res.Infcode
  25055. }
  25056. }
  25057. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25058. psn_info, _ := service.GetPsnByPatientId(id)
  25059. PsnNo = psn_info.PsnNo
  25060. PsnCertType = psn_info.PsnCertType
  25061. Certno = psn_info.Certno
  25062. PsnName = psn_info.PsnName
  25063. Gend = psn_info.Gend
  25064. Naty = psn_info.Naty
  25065. Brdy = psn_info.Brdy
  25066. Age = psn_info.Age
  25067. infoStr = psn_info.Insuinfo
  25068. idetinfoStr = psn_info.Idetinfo
  25069. infocode = 0
  25070. verify_number = psn_info.VerifyNumber
  25071. } else if miConfig.MdtrtareaAdmvs == "450721" {
  25072. psn_info, _ := service.GetPsnByPatientId(id)
  25073. PsnNo = psn_info.PsnNo
  25074. PsnCertType = psn_info.PsnCertType
  25075. Certno = psn_info.Certno
  25076. PsnName = psn_info.PsnName
  25077. Gend = psn_info.Gend
  25078. Naty = psn_info.Naty
  25079. Brdy = psn_info.Brdy
  25080. Age = psn_info.Age
  25081. infoStr = psn_info.Insuinfo
  25082. idetinfoStr = psn_info.Idetinfo
  25083. infocode = 0
  25084. verify_number = psn_info.VerifyNumber
  25085. } else {
  25086. var result string
  25087. var requestLog string
  25088. //if miConfig.UserOrgId == 10138 {
  25089. if id_card_type != 4 || id_card_type != 1 {
  25090. var insa string
  25091. if len(patient.InsuplcAdmdvs) > 0 {
  25092. insa = patient.InsuplcAdmdvs
  25093. } else {
  25094. insa = miConfig.InsuplcAdmdvs
  25095. }
  25096. //psn_info, _ := service.GetPsnByPatientId(id)
  25097. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  25098. 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)
  25099. }
  25100. //}
  25101. //else {
  25102. // var insa string
  25103. // if len(patient.InsuplcAdmdvs) > 0 {
  25104. // insa = patient.InsuplcAdmdvs
  25105. // } else {
  25106. // insa = miConfig.InsuplcAdmdvs
  25107. // }
  25108. // 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)
  25109. //}
  25110. if id_card_type == 4 || id_card_type == 1 {
  25111. psn_info, _ := service.GetPsnByPatientId(id)
  25112. PsnNo = psn_info.PsnNo
  25113. PsnCertType = psn_info.PsnCertType
  25114. Certno = psn_info.Certno
  25115. PsnName = psn_info.PsnName
  25116. Gend = psn_info.Gend
  25117. Naty = psn_info.Naty
  25118. Brdy = psn_info.Brdy
  25119. Age = psn_info.Age
  25120. infoStr = psn_info.Insuinfo
  25121. idetinfoStr = psn_info.Idetinfo
  25122. infocode = 0
  25123. verify_number = psn_info.VerifyNumber
  25124. } else {
  25125. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25126. if miConfig.Code == "H15049901371" {
  25127. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  25128. utils.ErrorLog("解析失败:%v", err)
  25129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25130. return
  25131. }
  25132. res.ErrMsg = res10265.ErrMsg
  25133. res.Output = res10265.Output
  25134. res.InfRefmsgid = res10265.InfRefmsgid
  25135. } else {
  25136. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25137. utils.ErrorLog("解析失败:%v", err)
  25138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25139. return
  25140. }
  25141. }
  25142. PsnNo = res.Output.Baseinfo.PsnNo
  25143. PsnCertType = res.Output.Baseinfo.PsnCertType
  25144. Certno = res.Output.Baseinfo.Certno
  25145. PsnName = res.Output.Baseinfo.PsnName
  25146. Gend = res.Output.Baseinfo.Gend
  25147. Naty = res.Output.Baseinfo.Naty
  25148. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25149. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25150. infoStr = string(Iinfos)
  25151. idetinfoStr = string(Idetinfos)
  25152. if miConfig.Code == "H15049901371" {
  25153. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25154. } else {
  25155. infocode = res.Infcode
  25156. }
  25157. }
  25158. }
  25159. if infocode == 0 {
  25160. his := models.VMHisPatient{
  25161. Name: name,
  25162. Gender: gender,
  25163. Birthday: birthUnix,
  25164. MedicalTreatmentType: medical_care,
  25165. IdType: certificates,
  25166. IdCardNo: id_card,
  25167. BalanceAccountsType: settlementValue,
  25168. SocialType: social_type,
  25169. MedicalInsuranceNumber: medical_insurance_card,
  25170. RegisterType: register_type,
  25171. RegisterCost: registration_fee,
  25172. TreatmentCost: medical_expenses,
  25173. Status: 1,
  25174. Ctime: time.Now().Unix(),
  25175. Mtime: time.Now().Unix(),
  25176. PsnNo: PsnNo,
  25177. PsnCertType: PsnCertType,
  25178. Certno: Certno,
  25179. PsnName: PsnName,
  25180. Gend: Gend,
  25181. Naty: Naty,
  25182. Brdy: Brdy,
  25183. Age: Age,
  25184. Iinfo: infoStr,
  25185. Idetinfo: idetinfoStr,
  25186. PatientId: patient.ID,
  25187. RecordDate: theTime.Unix(),
  25188. UserOrgId: adminInfo.CurrentOrgId,
  25189. AdminUserId: admin_user_id,
  25190. IsReturn: 1,
  25191. IdCardType: id_card_type,
  25192. Doctor: doctor,
  25193. Departments: department,
  25194. MdtrtGrpType: mdtrt_type,
  25195. }
  25196. timestamp := time.Now().Unix()
  25197. tempTime := time.Unix(timestamp, 0)
  25198. timeFormat := tempTime.Format("20060102150405")
  25199. chrgBchno := rand.Intn(100000) + 10000
  25200. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25201. his.Number = ipt_otp_no
  25202. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  25203. department, _ := service.GetDepartMentDetail(department)
  25204. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  25205. IdCardNo := ""
  25206. if id_card_type == 1 {
  25207. // IdCardNo = medical_insurance_card
  25208. IdCardNo = patient.IdCardNo
  25209. } else {
  25210. IdCardNo = patient.IdCardNo
  25211. }
  25212. var rf []*ResultFive
  25213. json.Unmarshal([]byte(his.Iinfo), &rf)
  25214. var insutypes []*ResultFive
  25215. var insutype string
  25216. var insuplc_admdvs_temp string
  25217. var is390 int = 0
  25218. var is310 int = 0
  25219. for _, item := range rf {
  25220. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25221. insutypes = append(insutypes, item)
  25222. }
  25223. }
  25224. if len(insutypes) == 1 {
  25225. insutype = insutypes[0].Insutype
  25226. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25227. if insutype == "390" {
  25228. is390 = 1
  25229. }
  25230. if insutype == "310" {
  25231. is310 = 1
  25232. }
  25233. } else {
  25234. for _, i := range insutypes {
  25235. if i.Insutype == "390" {
  25236. is390 = 1
  25237. }
  25238. if i.Insutype == "310" {
  25239. is310 = 1
  25240. }
  25241. }
  25242. }
  25243. if is390 == 1 {
  25244. insutype = "390"
  25245. }
  25246. if is310 == 1 {
  25247. insutype = "310"
  25248. }
  25249. fmt.Println(social_type)
  25250. if social_type > 0 {
  25251. insutype = strconv.FormatInt(social_type, 10)
  25252. }
  25253. var infocode int64
  25254. var resThree ResultThree
  25255. var resThree10265 ResultThree10265
  25256. if len(insuplc_admdvs) == 0 {
  25257. psn_info, _ := service.GetPsnByPatientId(id)
  25258. //if len(psn_info.InsuplcAdmdvs) > 0 {
  25259. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25260. //}
  25261. } else {
  25262. insuplc_admdvs_temp = insuplc_admdvs
  25263. }
  25264. if miConfig.MdtrtareaAdmvs == "421300" {
  25265. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25266. psn_info, _ := service.GetPsnByPatientId(id)
  25267. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25268. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25269. "&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
  25270. resp, requestErr := http.Get(api)
  25271. if requestErr != nil {
  25272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25273. return
  25274. }
  25275. body, ioErr := ioutil.ReadAll(resp.Body)
  25276. if ioErr != nil {
  25277. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25279. return
  25280. }
  25281. var respJSON map[string]interface{}
  25282. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25285. return
  25286. }
  25287. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25288. result, _ := json.Marshal(respJSON)
  25289. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25290. utils.ErrorLog("解析失败:%v", err)
  25291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25292. return
  25293. }
  25294. infocode = resThree.Infcode
  25295. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25296. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25297. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25298. // insuplc_admdvs_temp =
  25299. //}
  25300. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25301. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25302. //}
  25303. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25304. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25305. "&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
  25306. resp, requestErr := http.Get(api)
  25307. if requestErr != nil {
  25308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25309. return
  25310. }
  25311. body, ioErr := ioutil.ReadAll(resp.Body)
  25312. if ioErr != nil {
  25313. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25315. return
  25316. }
  25317. var respJSON map[string]interface{}
  25318. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25321. return
  25322. }
  25323. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25324. result, _ := json.Marshal(respJSON)
  25325. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25326. utils.ErrorLog("解析失败:%v", err)
  25327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25328. return
  25329. }
  25330. infocode = resThree.Infcode
  25331. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25332. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25333. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25334. // insuplc_admdvs_temp =
  25335. //}
  25336. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25337. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25338. //}
  25339. utils.ErrorLog("解析失败:%v", insutype)
  25340. utils.ErrorLog("解析失败:%v", PsnNo)
  25341. utils.ErrorLog("解析失败:%v", Certno)
  25342. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  25343. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  25344. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  25345. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  25346. utils.ErrorLog("解析失败:%v", PsnNo)
  25347. utils.ErrorLog("解析失败:%v", department.Number)
  25348. utils.ErrorLog("解析失败:%v", department.Name)
  25349. utils.ErrorLog("解析失败:%v", roles.UserName)
  25350. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25351. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25352. "&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
  25353. resp, requestErr := http.Get(api)
  25354. if requestErr != nil {
  25355. utils.ErrorLog("解析失败:%v", requestErr)
  25356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25357. return
  25358. }
  25359. body, ioErr := ioutil.ReadAll(resp.Body)
  25360. if ioErr != nil {
  25361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25363. return
  25364. }
  25365. var respJSON map[string]interface{}
  25366. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25369. return
  25370. }
  25371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25372. result, _ := json.Marshal(respJSON)
  25373. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25374. utils.ErrorLog("解析失败:%v", err)
  25375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25376. return
  25377. }
  25378. infocode = resThree.Infcode
  25379. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25380. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25381. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25382. // insuplc_admdvs_temp =
  25383. //}
  25384. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25385. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25386. //}
  25387. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25388. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25389. "&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
  25390. resp, requestErr := http.Get(api)
  25391. if requestErr != nil {
  25392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25393. return
  25394. }
  25395. body, ioErr := ioutil.ReadAll(resp.Body)
  25396. if ioErr != nil {
  25397. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25399. return
  25400. }
  25401. var respJSON map[string]interface{}
  25402. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25405. return
  25406. }
  25407. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25408. result, _ := json.Marshal(respJSON)
  25409. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25410. utils.ErrorLog("解析失败:%v", err)
  25411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25412. return
  25413. }
  25414. infocode = resThree.Infcode
  25415. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25416. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25417. psn_info, _ := service.GetPsnByPatientId(id)
  25418. var verify_number string
  25419. if id_card_type == 4 {
  25420. verify_number = psn_info.VerifyNumber
  25421. } else if id_card_type == 1 {
  25422. bas := strings.Split(psn_info.CardInfo, "|")
  25423. cardNumber := bas[2]
  25424. verify_number = cardNumber
  25425. }
  25426. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25427. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25428. "&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
  25429. resp, requestErr := http.Get(api)
  25430. if requestErr != nil {
  25431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25432. return
  25433. }
  25434. body, ioErr := ioutil.ReadAll(resp.Body)
  25435. if ioErr != nil {
  25436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25438. return
  25439. }
  25440. var respJSON map[string]interface{}
  25441. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25444. return
  25445. }
  25446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25447. result, _ := json.Marshal(respJSON)
  25448. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25449. // utils.ErrorLog("解析失败:%v", err)
  25450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25451. // return
  25452. //}
  25453. //infocode = resThree.Infcode
  25454. //result, _ := json.Marshal(respJSON)
  25455. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25456. utils.ErrorLog("解析失败:%v", err)
  25457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25458. return
  25459. }
  25460. resThree.ErrMsg = resThree10265.ErrMsg
  25461. resThree.Output = resThree10265.Output
  25462. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25463. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25464. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  25465. psn_info, _ := service.GetPsnByPatientId(id)
  25466. his.PsnNo = psn_info.PsnNo
  25467. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25468. var cert_no string
  25469. if id_card_type == 3 {
  25470. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  25471. cert_no = IdCardNo
  25472. } else if id_card_type == 4 {
  25473. cert_no = IdCardNo
  25474. psn_info.VerifyNumber = psn_info.VerifyNumber
  25475. } else {
  25476. bas := strings.Split(psn_info.CardInfo, "|")
  25477. cert_no = bas[2]
  25478. }
  25479. var hisPrescription []*models.HisPrescription
  25480. fmt.Println(hisPrescription)
  25481. for _, item := range rf {
  25482. if item.Insutype == insutype {
  25483. //insuplc_admdvs = item.InsuplcAdmdvs
  25484. his.InsuplcAdmdvs = insuplc_admdvs
  25485. }
  25486. }
  25487. his.Insutype = insutype
  25488. var res3101 Result3101
  25489. res3101.Infcode = "0"
  25490. //res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25491. if res3101.Infcode == "0" {
  25492. fmt.Println("33333333")
  25493. if len(res3101.Output.Result) > 0 {
  25494. fmt.Println("222222")
  25495. for _, item := range res3101.Output.Result {
  25496. if len(res3101.ErrMsg) == 0 {
  25497. res3101.ErrMsg = item.VolaCont
  25498. } else {
  25499. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25500. }
  25501. }
  25502. c.ServeSuccessJSON(map[string]interface{}{
  25503. "failed_code": -10,
  25504. "msg": res3101.ErrMsg,
  25505. })
  25506. return
  25507. } else {
  25508. fmt.Println("11111")
  25509. var api string
  25510. if miConfig.MdtrtareaAdmvs == "320830" {
  25511. ipt_otp_no = timeFormat
  25512. api = miConfig.AppSecret + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25513. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25514. "&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
  25515. } else if miConfig.MdtrtareaAdmvs == "320921" {
  25516. ipt_otp_no = timeFormat
  25517. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25518. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25519. "&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
  25520. } else {
  25521. ipt_otp_no = timeFormat
  25522. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25523. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25524. "&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
  25525. }
  25526. resp, requestErr := http.Get(api)
  25527. if requestErr != nil {
  25528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25529. return
  25530. }
  25531. body, ioErr := ioutil.ReadAll(resp.Body)
  25532. if ioErr != nil {
  25533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25535. return
  25536. }
  25537. var respJSON map[string]interface{}
  25538. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25541. return
  25542. }
  25543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25544. result, _ := json.Marshal(respJSON)
  25545. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25546. utils.ErrorLog("解析失败:%v", err)
  25547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25548. return
  25549. }
  25550. resThree.ErrMsg = resThree10265.ErrMsg
  25551. resThree.Output = resThree10265.Output
  25552. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25553. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25554. }
  25555. } else if res3101.Infcode != "0" {
  25556. c.ServeSuccessJSON(map[string]interface{}{
  25557. "failed_code": -10,
  25558. "msg": res3101.ErrMsg,
  25559. })
  25560. return
  25561. }
  25562. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25563. psn_info, _ := service.GetPsnByPatientId(id)
  25564. var cert_no string
  25565. if id_card_type == 1 {
  25566. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25567. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25568. } else if id_card_type == 4 {
  25569. cert_no = psn_info.VerifyNumber
  25570. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25571. } else {
  25572. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25573. cert_no = psn_info.VerifyNumber
  25574. }
  25575. 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)
  25576. saveLog(result, requestLog, "2201", "挂号")
  25577. if miConfig.Code == "H15049901371" {
  25578. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25579. utils.ErrorLog("解析失败:%v", err)
  25580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25581. return
  25582. }
  25583. resThree.ErrMsg = resThree10265.ErrMsg
  25584. resThree.Output = resThree10265.Output
  25585. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25586. } else {
  25587. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25588. utils.ErrorLog("解析失败:%v", err)
  25589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25590. return
  25591. }
  25592. }
  25593. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25594. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  25595. psn_info, _ := service.GetPsnByPatientId(id)
  25596. var result string
  25597. var requestLog string
  25598. if id_card_type == 1 {
  25599. bas := strings.Split(psn_info.CardInfo, "|")
  25600. basNumber := bas[2]
  25601. card_sn := bas[3]
  25602. 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)
  25603. saveLog(result, requestLog, "2201A", "挂号")
  25604. } else if id_card_type == 2 {
  25605. 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, "", "", "", "", "", "")
  25606. saveLog(result, requestLog, "2201A", "挂号")
  25607. } else {
  25608. result, requestLog = service.Jxyb2201(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, psn_info.VerifyNumber, "", "", "01", IdCardNo, "15", psn_info.PsnName)
  25609. saveLog(result, requestLog, "2201A", "挂号")
  25610. }
  25611. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25612. utils.ErrorLog("解析失败:%v", err)
  25613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25614. return
  25615. }
  25616. infocode = resThree.Infcode
  25617. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  25618. psn_info, _ := service.GetPsnByPatientId(id)
  25619. var result string
  25620. var requestLog string
  25621. if id_card_type == 1 {
  25622. bas := strings.Split(psn_info.CardInfo, "|")
  25623. basNumber := bas[2]
  25624. card_sn := ""
  25625. 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)
  25626. saveLog(result, requestLog, "2201A", "挂号")
  25627. } else if id_card_type == 2 {
  25628. 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, "", "", "", "", "", "")
  25629. saveLog(result, requestLog, "2201A", "挂号")
  25630. } else {
  25631. result, requestLog = service.Jxyb2201(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, psn_info.VerifyNumber, "", "", "01", IdCardNo, "15", psn_info.PsnName)
  25632. saveLog(result, requestLog, "2201A", "挂号")
  25633. }
  25634. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25635. utils.ErrorLog("解析失败:%v", err)
  25636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25637. return
  25638. }
  25639. infocode = resThree.Infcode
  25640. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  25641. psn_info, _ := service.GetPsnByPatientId(id)
  25642. var result string
  25643. var requestLog string
  25644. if id_card_type == 1 {
  25645. bas := strings.Split(psn_info.CardInfo, "|")
  25646. basNumber := bas[2]
  25647. card_sn := ""
  25648. 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)
  25649. saveLog(result, requestLog, "2201A", "挂号")
  25650. } else if id_card_type == 2 {
  25651. 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, "", "", "", "", "", "")
  25652. saveLog(result, requestLog, "2201A", "挂号")
  25653. } else {
  25654. result, requestLog = service.Jxyb2201(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, psn_info.VerifyNumber, "", "", "01", IdCardNo, "15", psn_info.PsnName)
  25655. saveLog(result, requestLog, "2201A", "挂号")
  25656. }
  25657. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25658. utils.ErrorLog("解析失败:%v", err)
  25659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25660. return
  25661. }
  25662. infocode = resThree.Infcode
  25663. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25664. psn_info, _ := service.GetPsnByPatientId(id)
  25665. his.PsnNo = psn_info.PsnNo
  25666. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25667. var cert_no string
  25668. if id_card_type == 1 {
  25669. bas := strings.Split(psn_info.CardInfo, "|")
  25670. cert_no = bas[2]
  25671. } else if id_card_type == 4 {
  25672. cert_no = psn_info.VerifyNumber
  25673. psn_info.VerifyNumber = psn_info.VerifyNumber
  25674. IdCardNo = psn_info.VerifyNumber
  25675. } else {
  25676. cert_no = IdCardNo
  25677. psn_info.VerifyNumber = cert_no
  25678. }
  25679. for _, item := range rf {
  25680. if item.Insutype == insutype {
  25681. his.InsuplcAdmdvs = insuplc_admdvs
  25682. }
  25683. }
  25684. his.Insutype = insutype
  25685. var api string
  25686. ipt_otp_no = timeFormat
  25687. api = miConfig.SecretKey + "ahyb/2201?verify_number=" + cert_no + "&cert_no=" + IdCardNo + "&psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25688. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25689. "&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
  25690. resp, requestErr := http.Get(api)
  25691. if requestErr != nil {
  25692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25693. return
  25694. }
  25695. body, ioErr := ioutil.ReadAll(resp.Body)
  25696. if ioErr != nil {
  25697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25699. return
  25700. }
  25701. var respJSON map[string]interface{}
  25702. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25705. return
  25706. }
  25707. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25708. if status == "0" {
  25709. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25710. c.ServeSuccessJSON(map[string]interface{}{
  25711. "failed_code": -10,
  25712. "msg": err_msg,
  25713. })
  25714. return
  25715. }
  25716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25717. result, _ := json.Marshal(respJSON)
  25718. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25719. utils.ErrorLog("解析失败:%v", err)
  25720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25721. return
  25722. }
  25723. infocode = resThree.Infcode
  25724. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25725. psn_info, _ := service.GetPsnByPatientId(id)
  25726. his.PsnNo = psn_info.PsnNo
  25727. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25728. var cert_no string
  25729. if id_card_type == 1 {
  25730. bas := strings.Split(psn_info.CardInfo, "|")
  25731. cert_no = bas[2]
  25732. } else if id_card_type == 4 {
  25733. cert_no = psn_info.VerifyNumber
  25734. psn_info.VerifyNumber = psn_info.VerifyNumber
  25735. IdCardNo = psn_info.VerifyNumber
  25736. } else {
  25737. cert_no = IdCardNo
  25738. psn_info.VerifyNumber = cert_no
  25739. }
  25740. for _, item := range rf {
  25741. if item.Insutype == insutype {
  25742. his.InsuplcAdmdvs = insuplc_admdvs
  25743. patient.InsuplcAdmdvs = insuplc_admdvs
  25744. }
  25745. }
  25746. his.Insutype = insutype
  25747. var api string
  25748. ipt_otp_no = timeFormat
  25749. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&verify_number=" + cert_no + "&cert_no=" + IdCardNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25750. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25751. "&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
  25752. resp, requestErr := http.Get(api)
  25753. if requestErr != nil {
  25754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25755. return
  25756. }
  25757. body, ioErr := ioutil.ReadAll(resp.Body)
  25758. if ioErr != nil {
  25759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25761. return
  25762. }
  25763. var respJSON map[string]interface{}
  25764. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25767. return
  25768. }
  25769. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25770. if status == "0" {
  25771. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25772. c.ServeSuccessJSON(map[string]interface{}{
  25773. "failed_code": -10,
  25774. "msg": err_msg,
  25775. })
  25776. return
  25777. }
  25778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25779. result, _ := json.Marshal(respJSON)
  25780. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25781. utils.ErrorLog("解析失败:%v", err)
  25782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25783. return
  25784. }
  25785. infocode = resThree.Infcode
  25786. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25787. hour := time.Now().Format("15")
  25788. min := time.Now().Format("04")
  25789. sec := time.Now().Format("05")
  25790. begin := record_time + " " + hour + ":" + min + ":" + sec
  25791. psn_info, _ := service.GetPsnByPatientId(id)
  25792. var result string
  25793. var requestLog string
  25794. if id_card_type == 1 {
  25795. bas := strings.Split(psn_info.CardInfo, "|")
  25796. basNumber := bas[2]
  25797. card_sn := bas[3]
  25798. 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, begin)
  25799. saveLog(result, requestLog, "2201A", "挂号")
  25800. } else if id_card_type == 2 {
  25801. 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, "", "", begin)
  25802. saveLog(result, requestLog, "2201A", "挂号")
  25803. } else {
  25804. 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, "", "", begin)
  25805. saveLog(result, requestLog, "2201A", "挂号")
  25806. }
  25807. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25808. utils.ErrorLog("解析失败:%v", err)
  25809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25810. return
  25811. }
  25812. infocode = resThree.Infcode
  25813. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25814. psn_info, _ := service.GetPsnByPatientId(id)
  25815. 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)
  25816. saveLog(result, requestLog, "2201A", "挂号")
  25817. if miConfig.Code == "H15049901371" {
  25818. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25819. utils.ErrorLog("解析失败:%v", err)
  25820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25821. return
  25822. }
  25823. resThree.ErrMsg = resThree10265.ErrMsg
  25824. resThree.Output = resThree10265.Output
  25825. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25826. } else {
  25827. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25828. utils.ErrorLog("解析失败:%v", err)
  25829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25830. return
  25831. }
  25832. }
  25833. if miConfig.Code == "H15049901371" {
  25834. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25835. } else {
  25836. infocode = resThree.Infcode
  25837. }
  25838. } else {
  25839. psn_info, _ := service.GetPsnByPatientId(id)
  25840. if id_card_type == 4 || id_card_type == 1 {
  25841. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25842. }
  25843. var rf []*ResultFive
  25844. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25845. var insutypes []*ResultFive
  25846. var insutype string
  25847. var is390 int = 0
  25848. var is310 int = 0
  25849. for _, item := range rf {
  25850. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25851. insutypes = append(insutypes, item)
  25852. }
  25853. }
  25854. if len(insutypes) == 1 {
  25855. insutype = insutypes[0].Insutype
  25856. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25857. } else {
  25858. for _, i := range insutypes {
  25859. if i.Insutype == "390" {
  25860. is390 = 1
  25861. }
  25862. if i.Insutype == "310" {
  25863. is310 = 1
  25864. }
  25865. }
  25866. }
  25867. if is390 == 1 {
  25868. insutype = "390"
  25869. }
  25870. if is310 == 1 {
  25871. insutype = "310"
  25872. }
  25873. fmt.Println(len(insutypes))
  25874. if len(insutypes) == 0 {
  25875. for index, item := range rf {
  25876. if index == 0 {
  25877. insutype = item.Insutype
  25878. insuplc_admdvs = item.InsuplcAdmdvs
  25879. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25880. }
  25881. }
  25882. fmt.Println(insutype)
  25883. fmt.Println(insuplc_admdvs)
  25884. }
  25885. if social_type > 0 {
  25886. insutype = strconv.FormatInt(social_type, 10)
  25887. }
  25888. fmt.Println("--------")
  25889. fmt.Println(psn_info)
  25890. fmt.Println(psn_info.PsnNo)
  25891. for _, item := range rf {
  25892. if item.Insutype == insutype {
  25893. insutype = item.Insutype
  25894. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25895. }
  25896. }
  25897. if miConfig.MdtrtareaAdmvs == "441202" {
  25898. var hisPrescription []*models.HisPrescription
  25899. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25900. if res3101.Infcode == 0 {
  25901. fmt.Println("33333333")
  25902. if len(res3101.Output.Result) > 0 {
  25903. fmt.Println("222222")
  25904. for _, item := range res3101.Output.Result {
  25905. if len(res3101.ErrMsg) == 0 {
  25906. res3101.ErrMsg = item.VolaCont
  25907. } else {
  25908. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25909. }
  25910. }
  25911. c.ServeSuccessJSON(map[string]interface{}{
  25912. "failed_code": -10,
  25913. "msg": res3101.ErrMsg,
  25914. })
  25915. return
  25916. } else {
  25917. hour := time.Now().Format("15")
  25918. min := time.Now().Format("04")
  25919. sec := time.Now().Format("05")
  25920. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25921. fmt.Println(record_time_two)
  25922. 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)
  25923. saveLog(result, requestLog, "2201A", "挂号")
  25924. if miConfig.Code == "H15049901371" {
  25925. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25926. utils.ErrorLog("解析失败:%v", err)
  25927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25928. return
  25929. }
  25930. resThree.ErrMsg = resThree10265.ErrMsg
  25931. resThree.Output = resThree10265.Output
  25932. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25933. } else {
  25934. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25935. utils.ErrorLog("解析失败:%v", err)
  25936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25937. return
  25938. }
  25939. }
  25940. if miConfig.Code == "H15049901371" {
  25941. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25942. } else {
  25943. infocode = resThree.Infcode
  25944. }
  25945. }
  25946. } else if res3101.Infcode != 0 {
  25947. c.ServeSuccessJSON(map[string]interface{}{
  25948. "failed_code": -10,
  25949. "msg": res3101.ErrMsg,
  25950. })
  25951. return
  25952. }
  25953. } else if miConfig.MdtrtareaAdmvs == "440205" {
  25954. var hisPrescription []*models.HisPrescription
  25955. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25956. if res3101.Infcode == 0 {
  25957. fmt.Println("33333333")
  25958. if len(res3101.Output.Result) > 0 {
  25959. fmt.Println("222222")
  25960. for _, item := range res3101.Output.Result {
  25961. if len(res3101.ErrMsg) == 0 {
  25962. res3101.ErrMsg = item.VolaCont
  25963. } else {
  25964. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25965. }
  25966. }
  25967. c.ServeSuccessJSON(map[string]interface{}{
  25968. "failed_code": -10,
  25969. "msg": res3101.ErrMsg,
  25970. })
  25971. return
  25972. } else {
  25973. hour := time.Now().Format("15")
  25974. min := time.Now().Format("04")
  25975. sec := time.Now().Format("05")
  25976. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25977. fmt.Println(record_time_two)
  25978. 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)
  25979. saveLog(result, requestLog, "2201A", "挂号")
  25980. if miConfig.Code == "H15049901371" {
  25981. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25982. utils.ErrorLog("解析失败:%v", err)
  25983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25984. return
  25985. }
  25986. resThree.ErrMsg = resThree10265.ErrMsg
  25987. resThree.Output = resThree10265.Output
  25988. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25989. } else {
  25990. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25991. utils.ErrorLog("解析失败:%v", err)
  25992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25993. return
  25994. }
  25995. }
  25996. if miConfig.Code == "H15049901371" {
  25997. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25998. } else {
  25999. infocode = resThree.Infcode
  26000. }
  26001. }
  26002. } else if res3101.Infcode != 0 {
  26003. c.ServeSuccessJSON(map[string]interface{}{
  26004. "failed_code": -10,
  26005. "msg": res3101.ErrMsg,
  26006. })
  26007. return
  26008. }
  26009. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26010. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  26011. psn_info, _ := service.GetPsnByPatientId(id)
  26012. var verify_number string
  26013. if id_card_type == 4 {
  26014. verify_number = psn_info.VerifyNumber
  26015. } else if id_card_type == 1 {
  26016. bas := strings.Split(psn_info.CardInfo, "|")
  26017. cardNumber := bas[2]
  26018. verify_number = cardNumber
  26019. } else {
  26020. verify_number = psn_info.Certno
  26021. }
  26022. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  26023. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  26024. "&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
  26025. resp, requestErr := http.Get(api)
  26026. if requestErr != nil {
  26027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26028. return
  26029. }
  26030. body, ioErr := ioutil.ReadAll(resp.Body)
  26031. if ioErr != nil {
  26032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26034. return
  26035. }
  26036. var respJSON map[string]interface{}
  26037. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26040. return
  26041. }
  26042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26043. result, _ := json.Marshal(respJSON)
  26044. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26045. utils.ErrorLog("解析失败:%v", err)
  26046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26047. return
  26048. }
  26049. infocode = resThree.Infcode
  26050. } else {
  26051. hour := time.Now().Format("15")
  26052. min := time.Now().Format("04")
  26053. sec := time.Now().Format("05")
  26054. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26055. if id_card_type == 1 {
  26056. for _, item := range rf {
  26057. if item.Insutype == strconv.FormatInt(social_type, 10) {
  26058. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  26059. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26060. } else if strconv.FormatInt(social_type, 10) == "390" {
  26061. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26062. } else {
  26063. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26064. }
  26065. }
  26066. }
  26067. }
  26068. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  26069. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26070. }
  26071. if id_card_type == 1 {
  26072. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  26073. bas := strings.Split(psn_info.CardInfo, "|")
  26074. basNumber := bas[1]
  26075. IdCardNo = basNumber
  26076. }
  26077. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  26078. IdCardNo = psn_info.VerifyNumber
  26079. }
  26080. if len(insuplc_admdvs_temp) == 0 {
  26081. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26082. }
  26083. var result string
  26084. var requestLog string
  26085. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998"{
  26086. var hisPrescription []*models.HisPrescription
  26087. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  26088. if res3101.Infcode == 0 {
  26089. if len(res3101.Output.Result) > 0 {
  26090. if len(res3101.Output.Result) > 0 {
  26091. c.ServeSuccessJSON(map[string]interface{}{
  26092. "failed_code": -10,
  26093. "failed_type": 100,
  26094. "warm_type": 1,
  26095. "msg": res3101,
  26096. })
  26097. return
  26098. } else {
  26099. c.ServeSuccessJSON(map[string]interface{}{
  26100. "failed_code": -10,
  26101. "msg": res3101.ErrMsg,
  26102. })
  26103. return
  26104. }
  26105. } else {
  26106. hour := time.Now().Format("15")
  26107. min := time.Now().Format("04")
  26108. sec := time.Now().Format("05")
  26109. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26110. fmt.Println(record_time_two)
  26111. if his.IdCardType == 2 {
  26112. IdCardNo = psn_info.Certno
  26113. psn_info.VerifyNumber = psn_info.Certno
  26114. } else if his.IdCardType == 4 {
  26115. IdCardNo = psn_info.Certno
  26116. } else {
  26117. bas := strings.Split(psn_info.CardInfo, "|")
  26118. IdCardNo = bas[2]
  26119. }
  26120. aaaa = insutype
  26121. 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)
  26122. saveLog(result, requestLog, "2201A", "挂号")
  26123. if miConfig.Code == "H15049901371" {
  26124. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26125. utils.ErrorLog("解析失败:%v", err)
  26126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26127. return
  26128. }
  26129. resThree.ErrMsg = resThree10265.ErrMsg
  26130. resThree.Output = resThree10265.Output
  26131. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26132. } else {
  26133. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26134. utils.ErrorLog("解析失败:%v", err)
  26135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26136. return
  26137. }
  26138. }
  26139. if miConfig.Code == "H15049901371" {
  26140. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26141. } else {
  26142. infocode = resThree.Infcode
  26143. }
  26144. }
  26145. } else if res3101.Infcode != 0 {
  26146. c.ServeSuccessJSON(map[string]interface{}{
  26147. "failed_code": -10,
  26148. "msg": res3101.ErrMsg,
  26149. })
  26150. return
  26151. }
  26152. } else {
  26153. psn_info, _ := service.GetPsnByPatientId(id)
  26154. var rf []*ResultFive
  26155. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  26156. //var insutypes []*ResultFive
  26157. var insutype string
  26158. var insutypes []*ResultFive
  26159. var is390 int = 0
  26160. var is310 int = 0
  26161. for _, item := range rf {
  26162. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26163. insutypes = append(insutypes, item)
  26164. }
  26165. }
  26166. if len(insutypes) == 1 {
  26167. insutype = insutypes[0].Insutype
  26168. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  26169. } else {
  26170. for _, i := range insutypes {
  26171. if i.Insutype == "390" {
  26172. is390 = 1
  26173. }
  26174. if i.Insutype == "310" {
  26175. is310 = 1
  26176. }
  26177. }
  26178. }
  26179. if is390 == 1 {
  26180. insutype = "390"
  26181. }
  26182. if is310 == 1 {
  26183. insutype = "310"
  26184. }
  26185. if len(insutypes) == 0 {
  26186. insutype = "310"
  26187. }
  26188. if social_type > 0 {
  26189. insutype = strconv.FormatInt(social_type, 10)
  26190. }
  26191. for _, item := range rf {
  26192. if item.Insutype == insutype {
  26193. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26194. }
  26195. }
  26196. if len(insuplc_admdvs_tt) > 0 {
  26197. insuplc_admdvs_temp = insuplc_admdvs_tt
  26198. }
  26199. 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)
  26200. saveLog(result, requestLog, "2201A", "挂号")
  26201. }
  26202. if miConfig.Code == "H15049901371" {
  26203. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26204. utils.ErrorLog("解析失败:%v", err)
  26205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26206. return
  26207. }
  26208. resThree.ErrMsg = resThree10265.ErrMsg
  26209. resThree.Output = resThree10265.Output
  26210. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26211. } else {
  26212. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26213. utils.ErrorLog("解析失败:%v", err)
  26214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26215. return
  26216. }
  26217. }
  26218. if miConfig.Code == "H15049901371" {
  26219. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26220. } else {
  26221. infocode = resThree.Infcode
  26222. }
  26223. }
  26224. }
  26225. if infocode == -1 {
  26226. adminUser := c.GetAdminUserInfo()
  26227. errlog := &models.HisOrderError{
  26228. UserOrgId: adminUser.CurrentOrgId,
  26229. Ctime: time.Now().Unix(),
  26230. Mtime: time.Now().Unix(),
  26231. ErrMsg: resThree.ErrMsg,
  26232. Status: 1,
  26233. PatientId: id,
  26234. RecordTime: recordDateTime,
  26235. Stage: 2,
  26236. }
  26237. service.CreateErrMsgLog(errlog)
  26238. c.ServeSuccessJSON(map[string]interface{}{
  26239. "failed_code": -10,
  26240. "msg": resThree.ErrMsg,
  26241. })
  26242. return
  26243. }
  26244. utils.ErrorLog("解析失败:%v", insutype)
  26245. his.Number = resThree.Output.Data.MdtrtID
  26246. his.PsnNo = resThree.Output.Data.PsnNo
  26247. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  26248. his.IdCardNo = patient.IdCardNo
  26249. his.PhoneNumber = patient.Phone
  26250. his.UserOrgId = adminInfo.CurrentOrgId
  26251. his.Insutype = insutype
  26252. if miConfig.Code == "H44030500255" {
  26253. his.Insutype = aaaa
  26254. }
  26255. his.Ctime = time.Now().Unix()
  26256. his.Mtime = time.Now().Unix()
  26257. his.InsuplcAdmdvs = insuplc_admdvs_temp
  26258. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  26259. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26260. }
  26261. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  26262. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26263. }
  26264. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  26265. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26266. }
  26267. his.Status = 1
  26268. his.MdtrtGrpType = mdtrt_type
  26269. service.UpdateHisPatientStatus(&his)
  26270. service.UpdateHisPatient123(&patient)
  26271. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  26272. c.ServeSuccessJSON(map[string]interface{}{
  26273. "his_info": his,
  26274. })
  26275. } else {
  26276. adminUser := c.GetAdminUserInfo()
  26277. errlog := &models.HisOrderError{
  26278. UserOrgId: adminUser.CurrentOrgId,
  26279. Ctime: time.Now().Unix(),
  26280. Mtime: time.Now().Unix(),
  26281. ErrMsg: res.ErrMsg,
  26282. Status: 1,
  26283. PatientId: id,
  26284. RecordTime: recordDateTime,
  26285. Stage: 1,
  26286. }
  26287. service.CreateErrMsgLog(errlog)
  26288. c.ServeSuccessJSON(map[string]interface{}{
  26289. "failed_code": -10,
  26290. "msg": res.ErrMsg,
  26291. })
  26292. return
  26293. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26294. }
  26295. }
  26296. }
  26297. func (c *HisApiController) GetUploadInfo() {
  26298. id, _ := c.GetInt64("id")
  26299. record_time := c.GetString("record_time")
  26300. his_patient_id, _ := c.GetInt64("his_patient_id")
  26301. order_id, _ := c.GetInt64("order_id")
  26302. pay_way, _ := c.GetInt64("pay_way")
  26303. pay_ways := c.GetString("pay_ways")
  26304. oth_desc := c.GetString("oth_desc")
  26305. pay_price, _ := c.GetFloat("pay_price")
  26306. pay_card_no := c.GetString("pay_card_no")
  26307. discount_price, _ := c.GetFloat("discount_price")
  26308. preferential_price, _ := c.GetFloat("preferential_price")
  26309. reality_price, _ := c.GetFloat("reality_price")
  26310. found_price, _ := c.GetFloat("found_price")
  26311. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  26312. private_price, _ := c.GetFloat("private_price")
  26313. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  26314. admin_user_id, _ := c.GetInt64("admin_user_id")
  26315. fapiao_code := c.GetString("fapiao_code")
  26316. fapiao_number := c.GetString("fapiao_number")
  26317. diagnosis_id := c.GetString("diagnosis")
  26318. sick_type, _ := c.GetInt64("sick_type")
  26319. reg_type, _ := c.GetInt64("p_type")
  26320. begin_time := c.GetString("begin_time")
  26321. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  26322. cash_pay := c.GetString("cash_pay")
  26323. band_card_pay := c.GetString("band_card_pay")
  26324. wechat_pay := c.GetString("wechat_pay")
  26325. ali_pay := c.GetString("ali_pay")
  26326. jifen_pay := c.GetString("jifen_pay")
  26327. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  26328. fmt.Println(acct_used_flag)
  26329. id_str := c.GetString("ids")
  26330. ids_arr := strings.Split(id_str, ",")
  26331. timeLayout := "2006-01-02"
  26332. loc, _ := time.LoadLocation("Local")
  26333. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26334. if err != nil {
  26335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26336. return
  26337. }
  26338. recordDateTime := theTime.Unix()
  26339. adminUser := c.GetAdminUserInfo()
  26340. var tempOrder models.HisOrder
  26341. tempOrder, _ = service.GetHisOrderByID(order_id)
  26342. var prescriptions []*models.HisPrescription
  26343. var start_time int64
  26344. var end_time int64
  26345. //押金模块
  26346. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  26347. tmp_decimal := c.GetString("tmp_decimal")
  26348. var decimal float64 //本次使用的押金
  26349. var errmsg error
  26350. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  26351. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  26352. return
  26353. }
  26354. if len(tmp_decimal) > 0 {
  26355. if tmp_decimal[0] == 45 {
  26356. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  26357. return
  26358. }
  26359. }
  26360. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  26361. fmt.Println(errs)
  26362. decimal = tt
  26363. //if adminUser.CurrentOrgId == 10106{
  26364. // if len(fapiao_code) == 0{
  26365. // fapiao_code = "144072080589"
  26366. // }
  26367. // if len(fapiao_number) == 0{
  26368. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  26369. // if order.ID == 0{
  26370. // fapiao_number = "00001520"
  26371. // }else{
  26372. // //fapiao_code = "00001520"
  26373. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  26374. // var zero string
  26375. // if fpNumber >= 1000{
  26376. // zero = "0000" + strconv.Itoa(fpNumber)
  26377. // }else if fpNumber >= 10000{
  26378. // zero = "000" + strconv.Itoa(fpNumber)
  26379. // } else if fpNumber >= 100000{
  26380. // zero = "00" + strconv.Itoa(fpNumber)
  26381. // } else if fpNumber >= 1000000{
  26382. // zero = "0" + strconv.Itoa(fpNumber)
  26383. // }else {
  26384. // zero = strconv.Itoa(fpNumber)
  26385. // }
  26386. // fapiao_number = zero
  26387. // }
  26388. // }
  26389. //}
  26390. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26391. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26392. var patientPrescription models.HisPrescriptionInfo
  26393. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26394. if patientPrescription.ID == 0 {
  26395. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26396. }
  26397. //if patientPrescription.Do
  26398. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26399. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26400. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26401. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26402. var config []*models.HisXtDiagnoseConfig
  26403. for _, item := range diagnosis_ids {
  26404. id, _ := strconv.ParseInt(item, 10, 64)
  26405. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26406. config = append(config, &diagnosisConfig)
  26407. }
  26408. sickConfig, _ := service.FindSickById(sick_type)
  26409. //if tempOrder.ID == 0 {
  26410. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  26411. //}
  26412. if tempOrder.ID == 0 {
  26413. var result string
  26414. var requestLog string
  26415. var res2 ResultSix
  26416. var res3 GZResultSix
  26417. var ressix10265 ResultSix10265
  26418. if miConfig.MdtrtareaAdmvs == "421300" {
  26419. data := make(map[string]interface{})
  26420. client := &http.Client{}
  26421. data["psn_no"] = his.PsnNo
  26422. data["mdtrt_id"] = his.Number
  26423. data["opter"] = roles.UserName
  26424. data["org_name"] = miConfig.OrgName
  26425. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26426. data["doctor_id"] = doctor_info.DoctorNumber
  26427. data["doctor_name"] = doctor_info.UserName
  26428. data["department"] = department.Name
  26429. data["fixmedins_code"] = miConfig.Code
  26430. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26431. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26432. data["secret_key"] = miConfig.SecretKey
  26433. data["sick_code"] = sickConfig.CountryCode
  26434. data["sick_name"] = sickConfig.ClassName
  26435. data["dept"] = strconv.FormatInt(department.ID, 10)
  26436. data["config"] = config
  26437. data["begin_time"] = begin_time
  26438. bytesData, _ := json.Marshal(data)
  26439. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26440. resp, _ := client.Do(req)
  26441. defer resp.Body.Close()
  26442. body, ioErr := ioutil.ReadAll(resp.Body)
  26443. if ioErr != nil {
  26444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26446. return
  26447. }
  26448. var respJSON map[string]interface{}
  26449. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26452. return
  26453. }
  26454. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26455. userJSONBytes, _ := json.Marshal(respJSON)
  26456. fmt.Println("log")
  26457. fmt.Println(string(userJSONBytes))
  26458. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26459. utils.ErrorLog("解析失败:%v", err)
  26460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26461. return
  26462. }
  26463. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26464. data := make(map[string]interface{})
  26465. client := &http.Client{}
  26466. data["psn_no"] = his.PsnNo
  26467. data["mdtrt_id"] = his.Number
  26468. data["opter"] = roles.UserName
  26469. data["org_name"] = miConfig.OrgName
  26470. if reg_type == 11 && his.Insutype == "390" {
  26471. data["med_type"] = "110104"
  26472. } else {
  26473. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26474. }
  26475. data["doctor_id"] = doctor_info.DoctorNumber
  26476. data["doctor_name"] = doctor_info.UserName
  26477. data["department"] = department.Name
  26478. data["fixmedins_code"] = miConfig.Code
  26479. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26480. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26481. data["secret_key"] = miConfig.SecretKey
  26482. data["sick_code"] = sickConfig.CountryCode
  26483. data["sick_name"] = sickConfig.ClassName
  26484. data["dept"] = strconv.FormatInt(department.ID, 10)
  26485. data["config"] = config
  26486. data["begin_time"] = begin_time
  26487. bytesData, _ := json.Marshal(data)
  26488. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26489. resp, _ := client.Do(req)
  26490. defer resp.Body.Close()
  26491. body, ioErr := ioutil.ReadAll(resp.Body)
  26492. if ioErr != nil {
  26493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26495. return
  26496. }
  26497. var respJSON map[string]interface{}
  26498. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26501. return
  26502. }
  26503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26504. userJSONBytes, _ := json.Marshal(respJSON)
  26505. fmt.Println("log")
  26506. fmt.Println(string(userJSONBytes))
  26507. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26508. utils.ErrorLog("解析失败:%v", err)
  26509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26510. return
  26511. }
  26512. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26513. data := make(map[string]interface{})
  26514. client := &http.Client{}
  26515. data["psn_no"] = his.PsnNo
  26516. data["mdtrt_id"] = his.Number
  26517. data["opter"] = roles.UserName
  26518. data["org_name"] = miConfig.OrgName
  26519. if reg_type == 11 && his.Insutype == "390" {
  26520. data["med_type"] = "110104"
  26521. } else {
  26522. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26523. }
  26524. data["doctor_id"] = doctor_info.DoctorNumber
  26525. data["doctor_name"] = doctor_info.UserName
  26526. data["department"] = department.Name
  26527. data["fixmedins_code"] = miConfig.Code
  26528. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26529. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26530. data["secret_key"] = miConfig.SecretKey
  26531. data["sick_code"] = sickConfig.CountryCode
  26532. data["sick_name"] = sickConfig.ClassName
  26533. data["dept"] = strconv.FormatInt(department.ID, 10)
  26534. data["config"] = config
  26535. data["begin_time"] = begin_time
  26536. bytesData, _ := json.Marshal(data)
  26537. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26538. resp, _ := client.Do(req)
  26539. defer resp.Body.Close()
  26540. body, ioErr := ioutil.ReadAll(resp.Body)
  26541. if ioErr != nil {
  26542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26544. return
  26545. }
  26546. var respJSON map[string]interface{}
  26547. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26550. return
  26551. }
  26552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26553. userJSONBytes, _ := json.Marshal(respJSON)
  26554. fmt.Println("log")
  26555. fmt.Println(string(userJSONBytes))
  26556. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26557. utils.ErrorLog("解析失败:%v", err)
  26558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26559. return
  26560. }
  26561. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26562. data := make(map[string]interface{})
  26563. client := &http.Client{}
  26564. data["psn_no"] = his.PsnNo
  26565. data["mdtrt_id"] = his.Number
  26566. data["opter"] = roles.UserName
  26567. data["org_name"] = miConfig.OrgName
  26568. if reg_type == 11 && his.Insutype == "390" {
  26569. data["med_type"] = "110104"
  26570. } else {
  26571. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26572. }
  26573. data["doctor_id"] = doctor_info.DoctorNumber
  26574. data["doctor_name"] = doctor_info.UserName
  26575. data["department"] = department.Name
  26576. data["fixmedins_code"] = miConfig.Code
  26577. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26578. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26579. data["secret_key"] = miConfig.SecretKey
  26580. data["sick_code"] = sickConfig.CountryCode
  26581. data["sick_name"] = sickConfig.ClassName
  26582. data["dept"] = strconv.FormatInt(department.ID, 10)
  26583. data["config"] = config
  26584. data["begin_time"] = begin_time
  26585. bytesData, _ := json.Marshal(data)
  26586. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26587. resp, _ := client.Do(req)
  26588. defer resp.Body.Close()
  26589. body, ioErr := ioutil.ReadAll(resp.Body)
  26590. if ioErr != nil {
  26591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26593. return
  26594. }
  26595. var respJSON map[string]interface{}
  26596. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26599. return
  26600. }
  26601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26602. userJSONBytes, _ := json.Marshal(respJSON)
  26603. fmt.Println("log")
  26604. fmt.Println(string(userJSONBytes))
  26605. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26606. utils.ErrorLog("解析失败:%v", err)
  26607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26608. return
  26609. }
  26610. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26611. utils.ErrorLog("解析失败:%v", doctor_info)
  26612. data := make(map[string]interface{})
  26613. client := &http.Client{}
  26614. data["psn_no"] = his.PsnNo
  26615. data["mdtrt_id"] = his.Number
  26616. data["doctor"] = roles.UserName
  26617. data["department"] = department.Name
  26618. data["org_name"] = miConfig.OrgName
  26619. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26620. data["doctor_id"] = doctor_info.DoctorNumber
  26621. data["new_doctor_name"] = doctor_info.UserName
  26622. data["fixmedins_code"] = miConfig.Code
  26623. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26624. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26625. data["secret_key"] = miConfig.SecretKey
  26626. data["sick_code"] = sickConfig.CountryCode
  26627. data["sick_name"] = sickConfig.ClassName
  26628. data["url"] = miConfig.Url
  26629. data["ak"] = miConfig.AccessKey
  26630. data["begin_time"] = begin_time
  26631. data["cainfo"] = miConfig.Cainfo
  26632. data["dept"] = strconv.FormatInt(department.ID, 10)
  26633. data["config"] = config
  26634. bytesData, _ := json.Marshal(data)
  26635. var req *http.Request
  26636. if miConfig.MdtrtareaAdmvs == "320830" {
  26637. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  26638. //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 +
  26639. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26640. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26641. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26642. //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 +
  26643. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26644. } else {
  26645. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26646. }
  26647. resp, _ := client.Do(req)
  26648. defer resp.Body.Close()
  26649. body, ioErr := ioutil.ReadAll(resp.Body)
  26650. if ioErr != nil {
  26651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26653. return
  26654. }
  26655. var respJSON map[string]interface{}
  26656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26659. return
  26660. }
  26661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26662. userJSONBytes, _ := json.Marshal(respJSON)
  26663. fmt.Println("log")
  26664. fmt.Println(string(userJSONBytes))
  26665. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26666. utils.ErrorLog("解析失败:%v", err)
  26667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26668. return
  26669. }
  26670. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26671. res2.Output = ressix10265.Output
  26672. res2.ErrMsg = ressix10265.ErrMsg
  26673. res2.Cainfo = ressix10265.Cainfo
  26674. res2.WarnMsg = ressix10265.WarnMsg
  26675. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26676. res2.Infcode = infocode
  26677. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26678. data := make(map[string]interface{})
  26679. client := &http.Client{}
  26680. data["psn_no"] = his.PsnNo
  26681. data["mdtrt_id"] = his.Number
  26682. data["doctor"] = roles.UserName
  26683. data["department"] = department.Name
  26684. data["org_name"] = miConfig.OrgName
  26685. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26686. data["doctor_id"] = doctor_info.DoctorNumber
  26687. data["new_doctor_name"] = doctor_info.UserName
  26688. data["fixmedins_code"] = miConfig.Code
  26689. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26690. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26691. data["secret_key"] = miConfig.SecretKey
  26692. data["sick_code"] = sickConfig.CountryCode
  26693. data["sick_name"] = sickConfig.ClassName
  26694. data["url"] = miConfig.Url
  26695. data["ak"] = miConfig.AccessKey
  26696. data["begin_time"] = begin_time
  26697. data["cainfo"] = miConfig.Cainfo
  26698. data["dept"] = strconv.FormatInt(department.ID, 10)
  26699. data["config"] = config
  26700. bytesData, _ := json.Marshal(data)
  26701. var req *http.Request
  26702. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26703. resp, _ := client.Do(req)
  26704. defer resp.Body.Close()
  26705. body, ioErr := ioutil.ReadAll(resp.Body)
  26706. if ioErr != nil {
  26707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26709. return
  26710. }
  26711. var respJSON map[string]interface{}
  26712. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26715. return
  26716. }
  26717. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26718. userJSONBytes, _ := json.Marshal(respJSON)
  26719. fmt.Println("log")
  26720. fmt.Println(string(userJSONBytes))
  26721. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26722. utils.ErrorLog("解析失败:%v", err)
  26723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26724. return
  26725. }
  26726. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26727. res2.Output = ressix10265.Output
  26728. res2.ErrMsg = ressix10265.ErrMsg
  26729. res2.Cainfo = ressix10265.Cainfo
  26730. res2.WarnMsg = ressix10265.WarnMsg
  26731. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26732. res2.Infcode = infocode
  26733. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26734. 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)
  26735. saveLog(result, requestLog, "2203", "上传就诊信息")
  26736. var respJSON2 map[string]interface{}
  26737. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26740. return
  26741. }
  26742. userJSONBytes2, _ := json.Marshal(respJSON2)
  26743. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26744. utils.ErrorLog("解析失败:%v", err)
  26745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26746. return
  26747. }
  26748. 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)
  26749. fmt.Println(result2)
  26750. fmt.Println(src_request)
  26751. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26752. data := make(map[string]interface{})
  26753. client := &http.Client{}
  26754. data["psn_no"] = his.PsnNo
  26755. data["mdtrt_id"] = his.Number
  26756. data["doctor"] = roles.UserName
  26757. data["department"] = department.Name
  26758. data["org_name"] = miConfig.OrgName
  26759. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26760. data["doctor_id"] = doctor_info.DoctorNumber
  26761. data["new_doctor_name"] = doctor_info.UserName
  26762. data["fixmedins_code"] = miConfig.Code
  26763. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26764. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26765. data["secret_key"] = miConfig.SecretKey
  26766. data["sick_code"] = sickConfig.CountryCode
  26767. data["sick_name"] = sickConfig.ClassName
  26768. data["url"] = miConfig.Url
  26769. data["ak"] = miConfig.AccessKey
  26770. data["begin_time"] = begin_time
  26771. data["cainfo"] = miConfig.Cainfo
  26772. data["dept"] = strconv.FormatInt(department.ID, 10)
  26773. data["config"] = config
  26774. bytesData, _ := json.Marshal(data)
  26775. var req *http.Request
  26776. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  26777. resp, _ := client.Do(req)
  26778. defer resp.Body.Close()
  26779. body, ioErr := ioutil.ReadAll(resp.Body)
  26780. if ioErr != nil {
  26781. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26783. return
  26784. }
  26785. var respJSON map[string]interface{}
  26786. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26789. return
  26790. }
  26791. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26792. userJSONBytes, _ := json.Marshal(respJSON)
  26793. fmt.Println("log")
  26794. fmt.Println(string(userJSONBytes))
  26795. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26796. utils.ErrorLog("解析失败:%v", err)
  26797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26798. return
  26799. }
  26800. } else {
  26801. if miConfig.MdtrtareaAdmvs == "440781" { //
  26802. 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)
  26803. } else {
  26804. if miConfig.Code == "H15049901371" {
  26805. //赤峰地区国家医保医疗类别
  26806. //职工透析:医疗类别选特殊情况门诊990502
  26807. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26808. var med_type string
  26809. if his.Insutype == "390" {
  26810. if reg_type == 14 {
  26811. med_type = "9933"
  26812. } else if reg_type == 11 {
  26813. med_type = "11"
  26814. }
  26815. } else if his.Insutype == "310" {
  26816. if reg_type == 14 {
  26817. med_type = "990502"
  26818. } else if reg_type == 11 {
  26819. med_type = "11"
  26820. }
  26821. }
  26822. 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)
  26823. } else {
  26824. 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)
  26825. }
  26826. }
  26827. saveLog(result, requestLog, "2203", "上传就诊信息")
  26828. var respJSON2 map[string]interface{}
  26829. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26832. return
  26833. }
  26834. userJSONBytes2, _ := json.Marshal(respJSON2)
  26835. if miConfig.Code == "H15049901371" {
  26836. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  26837. utils.ErrorLog("解析失败:%v", err)
  26838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26839. return
  26840. }
  26841. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26842. res2.Output = ressix10265.Output
  26843. res2.ErrMsg = ressix10265.ErrMsg
  26844. res2.Cainfo = ressix10265.Cainfo
  26845. res2.WarnMsg = ressix10265.WarnMsg
  26846. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26847. res2.Infcode = infocode
  26848. } else {
  26849. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26850. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26851. utils.ErrorLog("解析失败:%v", err)
  26852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26853. return
  26854. }
  26855. res2.Infcode = res3.Infcode
  26856. } else {
  26857. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26858. utils.ErrorLog("解析失败:%v", err)
  26859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26860. return
  26861. }
  26862. }
  26863. }
  26864. }
  26865. if res2.Infcode == -1 {
  26866. adminUser := c.GetAdminUserInfo()
  26867. errlog := &models.HisOrderError{
  26868. UserOrgId: adminUser.CurrentOrgId,
  26869. Ctime: time.Now().Unix(),
  26870. Mtime: time.Now().Unix(),
  26871. ErrMsg: res2.ErrMsg,
  26872. Status: 1,
  26873. PatientId: id,
  26874. RecordTime: recordDateTime,
  26875. Stage: 3,
  26876. }
  26877. service.CreateErrMsgLog(errlog)
  26878. c.ServeSuccessJSON(map[string]interface{}{
  26879. "failed_code": -10,
  26880. "msg": res2.ErrMsg,
  26881. })
  26882. return
  26883. } else {
  26884. his.Diagnosis = diagnosis_id
  26885. his.SickType = sickConfig.ID
  26886. //var p_type int64
  26887. //if reg_type == 1111 || reg_type == 1112 {
  26888. // p_type = 11
  26889. //
  26890. //}
  26891. his.PType = fmt.Sprintf("%d", reg_type)
  26892. service.UpdateHisPatientThree(&his)
  26893. data := make(map[string]interface{})
  26894. if settle_accounts_type == 1 { //日结
  26895. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26896. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26897. } else {
  26898. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26899. }
  26900. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  26901. data["pre"] = prescriptions
  26902. } else { //月结
  26903. start_time_str := c.GetString("start_time")
  26904. end_time_str := c.GetString("end_time")
  26905. timeLayout := "2006-01-02"
  26906. loc, _ := time.LoadLocation("Local")
  26907. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26908. if err != nil {
  26909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26910. return
  26911. }
  26912. recordStartTime := theStartTime.Unix()
  26913. start_time = recordStartTime
  26914. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26915. if err != nil {
  26916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26917. return
  26918. }
  26919. recordEndTime := theEndTime.Unix()
  26920. end_time = recordEndTime
  26921. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26922. data["pre"] = prescriptions
  26923. }
  26924. timestamp := time.Now().Unix()
  26925. tempTime := time.Unix(timestamp, 0)
  26926. timeFormat := tempTime.Format("20060102150405")
  26927. chrgBchno := rand.Intn(100000) + 10000
  26928. new_chrg_bchno := ""
  26929. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  26930. new_chrg_bchno = chrg_bchno
  26931. strconv.FormatInt(his.PatientId, 10)
  26932. client := &http.Client{}
  26933. if adminUser.CurrentOrgId == 10265 {
  26934. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26935. new_chrg_bchno = "0000"
  26936. }
  26937. }
  26938. data["psn_no"] = his.PsnNo
  26939. data["mdtrt_id"] = his.Number
  26940. data["chrg_bchno"] = new_chrg_bchno
  26941. data["org_name"] = miConfig.OrgName
  26942. data["doctor"] = doctor_info.UserName
  26943. data["doctor_id"] = doctor_info.DoctorNumber
  26944. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  26945. data["fixmedins_code"] = miConfig.Code
  26946. data["dept_code"] = department.Number
  26947. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26948. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26949. data["secret_key"] = miConfig.SecretKey
  26950. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26951. data["url"] = miConfig.Url
  26952. data["ak"] = miConfig.AccessKey
  26953. data["new_doctor_name"] = patientPrescription.Doctor
  26954. data["diag_code"] = sickConfig.CountryCode
  26955. data["cainfo"] = miConfig.Cainfo
  26956. data["opter"] = roles.UserName
  26957. var ids []int64
  26958. for _, item := range prescriptions {
  26959. ids = append(ids, item.ID)
  26960. }
  26961. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26962. if config.IsOpen == 1 { //对接了医保,走医保流程
  26963. var res ResultFour
  26964. var resFour10265 ResultFour10265
  26965. if miConfig.MdtrtareaAdmvs == "421300" {
  26966. bytesData, _ := json.Marshal(data)
  26967. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26968. resp, _ := client.Do(req)
  26969. defer resp.Body.Close()
  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(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. userJSONBytes, _ := json.Marshal(respJSON)
  26984. fmt.Println("log")
  26985. fmt.Println(string(userJSONBytes))
  26986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26987. utils.ErrorLog("解析失败:%v", err)
  26988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26989. return
  26990. }
  26991. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26992. bytesData, _ := json.Marshal(data)
  26993. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26994. resp, _ := client.Do(req)
  26995. defer resp.Body.Close()
  26996. body, ioErr := ioutil.ReadAll(resp.Body)
  26997. if ioErr != nil {
  26998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27000. return
  27001. }
  27002. var respJSON map[string]interface{}
  27003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27006. return
  27007. }
  27008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27009. userJSONBytes, _ := json.Marshal(respJSON)
  27010. fmt.Println("log")
  27011. fmt.Println(string(userJSONBytes))
  27012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27013. utils.ErrorLog("解析失败:%v", err)
  27014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27015. return
  27016. }
  27017. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27018. bytesData, _ := json.Marshal(data)
  27019. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  27020. resp, _ := client.Do(req)
  27021. defer resp.Body.Close()
  27022. body, ioErr := ioutil.ReadAll(resp.Body)
  27023. if ioErr != nil {
  27024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27026. return
  27027. }
  27028. var respJSON map[string]interface{}
  27029. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27032. return
  27033. }
  27034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27035. userJSONBytes, _ := json.Marshal(respJSON)
  27036. fmt.Println("log")
  27037. fmt.Println(string(userJSONBytes))
  27038. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27039. utils.ErrorLog("解析失败:%v", err)
  27040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27041. return
  27042. }
  27043. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27044. bytesData, _ := json.Marshal(data)
  27045. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  27046. resp, _ := client.Do(req)
  27047. defer resp.Body.Close()
  27048. body, ioErr := ioutil.ReadAll(resp.Body)
  27049. if ioErr != nil {
  27050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27052. return
  27053. }
  27054. var respJSON map[string]interface{}
  27055. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27058. return
  27059. }
  27060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27061. userJSONBytes, _ := json.Marshal(respJSON)
  27062. fmt.Println("log")
  27063. fmt.Println(string(userJSONBytes))
  27064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27065. utils.ErrorLog("解析失败:%v", err)
  27066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27067. return
  27068. }
  27069. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27070. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27071. var result3101 Result3101
  27072. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27073. result3101.Infcode = "0"
  27074. if result3101.Infcode == "0" {
  27075. if len(result3101.Output.Result) > 0 {
  27076. var errMsgs []string
  27077. for _, item := range result3101.Output.Result {
  27078. errMsgs = append(errMsgs, item.VolaCont)
  27079. }
  27080. c.ServeSuccessJSON(map[string]interface{}{
  27081. "failed_code": -10,
  27082. "msg": errMsgs,
  27083. })
  27084. return
  27085. }
  27086. }
  27087. bytesData, _ := json.Marshal(data)
  27088. var req *http.Request
  27089. if miConfig.MdtrtareaAdmvs == "320830" {
  27090. data["diag_code"] = sickConfig.CountryCode
  27091. fmt.Println(data)
  27092. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  27093. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27094. data["diag_code"] = sickConfig.CountryCode
  27095. fmt.Println(data)
  27096. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27097. } else {
  27098. data["diag_code"] = sickConfig.CountryCode
  27099. fmt.Println(data)
  27100. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27101. }
  27102. resp, _ := client.Do(req)
  27103. defer resp.Body.Close()
  27104. body, ioErr := ioutil.ReadAll(resp.Body)
  27105. if ioErr != nil {
  27106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27108. return
  27109. }
  27110. var respJSON map[string]interface{}
  27111. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27114. return
  27115. }
  27116. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27117. userJSONBytes, _ := json.Marshal(respJSON)
  27118. fmt.Println("log")
  27119. fmt.Println(string(userJSONBytes))
  27120. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27121. utils.ErrorLog("解析失败:%v", err)
  27122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27123. return
  27124. }
  27125. res.InfRefmsgid = resFour10265.InfRefmsgid
  27126. res.Output = resFour10265.Output
  27127. res.ErrMsg = resFour10265.ErrMsg
  27128. res.Cainfo = resFour10265.Cainfo
  27129. res.WarnMsg = resFour10265.WarnMsg
  27130. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27131. res.Infcode = infocode
  27132. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27133. var pagesize int = 2
  27134. var start int = 1
  27135. var stop int
  27136. var pagecount int
  27137. var curpage int
  27138. var isSuccess bool = true
  27139. data["doctor_id"] = doctor_info.DoctorNumber
  27140. //总页数,向上取整,注意除之前要先转换类型为float64
  27141. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  27142. for curpage = 1; curpage <= pagecount; curpage++ {
  27143. if curpage == 1 {
  27144. start = 1
  27145. } else {
  27146. start = (curpage-1)*pagesize + 1
  27147. }
  27148. stop = curpage * pagesize
  27149. if stop > len(prescriptions) {
  27150. stop = len(prescriptions)
  27151. }
  27152. //var requestLog string
  27153. data["pre"] = prescriptions[start-1 : stop]
  27154. fmt.Println(data["pre"])
  27155. bytesData, _ := json.Marshal(data)
  27156. var req *http.Request
  27157. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  27158. resp, _ := client.Do(req)
  27159. defer resp.Body.Close()
  27160. body, ioErr := ioutil.ReadAll(resp.Body)
  27161. if ioErr != nil {
  27162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27164. return
  27165. }
  27166. var respJSON map[string]interface{}
  27167. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27170. return
  27171. }
  27172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27173. userJSONBytes, _ := json.Marshal(respJSON)
  27174. fmt.Println("log")
  27175. fmt.Println(string(userJSONBytes))
  27176. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27177. utils.ErrorLog("解析失败:%v", err)
  27178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27179. return
  27180. }
  27181. res.InfRefmsgid = resFour10265.InfRefmsgid
  27182. res.Output = resFour10265.Output
  27183. res.ErrMsg = resFour10265.ErrMsg
  27184. res.Cainfo = resFour10265.Cainfo
  27185. res.WarnMsg = resFour10265.WarnMsg
  27186. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27187. res.Infcode = infocode
  27188. if infocode == 0 {
  27189. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  27190. } else {
  27191. isSuccess = false
  27192. errlog := &models.HisOrderError{
  27193. UserOrgId: adminUser.CurrentOrgId,
  27194. Ctime: time.Now().Unix(),
  27195. Mtime: time.Now().Unix(),
  27196. Number: chrg_bchno,
  27197. ErrMsg: "",
  27198. Status: 1,
  27199. PatientId: id,
  27200. RecordTime: recordDateTime,
  27201. Stage: 4,
  27202. }
  27203. service.CreateErrMsgLog(errlog)
  27204. c.ServeSuccessJSON(map[string]interface{}{
  27205. "failed_code": -10,
  27206. "msg": res.ErrMsg,
  27207. })
  27208. return
  27209. }
  27210. }
  27211. if isSuccess {
  27212. res.Infcode = 0
  27213. }
  27214. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27215. 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)
  27216. var dat map[string]interface{}
  27217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27218. fmt.Println(dat)
  27219. } else {
  27220. fmt.Println(err)
  27221. }
  27222. saveLog(result, request_log, "2204", "上传费用明细")
  27223. userJSONBytes, _ := json.Marshal(dat)
  27224. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27225. utils.ErrorLog("解析失败:%v", err)
  27226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27227. return
  27228. }
  27229. res.InfRefmsgid = resFour10265.InfRefmsgid
  27230. res.Output = resFour10265.Output
  27231. res.ErrMsg = resFour10265.ErrMsg
  27232. res.Cainfo = resFour10265.Cainfo
  27233. res.WarnMsg = resFour10265.WarnMsg
  27234. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27235. res.Infcode = infocode
  27236. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27237. bytesData, _ := json.Marshal(data)
  27238. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  27239. resp, _ := client.Do(req)
  27240. defer resp.Body.Close()
  27241. body, ioErr := ioutil.ReadAll(resp.Body)
  27242. if ioErr != nil {
  27243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27245. return
  27246. }
  27247. var respJSON map[string]interface{}
  27248. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27251. return
  27252. }
  27253. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27254. userJSONBytes, _ := json.Marshal(respJSON)
  27255. fmt.Println("log")
  27256. fmt.Println(string(userJSONBytes))
  27257. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27258. utils.ErrorLog("解析失败:%v", err)
  27259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27260. return
  27261. }
  27262. } else {
  27263. if miConfig.Code == "H15049901371" {
  27264. 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)
  27265. var dat map[string]interface{}
  27266. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27267. fmt.Println(dat)
  27268. } else {
  27269. fmt.Println(err)
  27270. }
  27271. saveLog(result, request_log, "2204", "上传费用明细")
  27272. userJSONBytes, _ := json.Marshal(dat)
  27273. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27274. utils.ErrorLog("解析失败:%v", err)
  27275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27276. return
  27277. }
  27278. res.InfRefmsgid = resFour10265.InfRefmsgid
  27279. res.Output = resFour10265.Output
  27280. res.ErrMsg = resFour10265.ErrMsg
  27281. res.Cainfo = resFour10265.Cainfo
  27282. res.WarnMsg = resFour10265.WarnMsg
  27283. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27284. res.Infcode = infocode
  27285. } else {
  27286. 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)
  27287. var dat map[string]interface{}
  27288. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27289. fmt.Println(dat)
  27290. } else {
  27291. fmt.Println(err)
  27292. }
  27293. saveLog(result, request_log, "2204", "上传费用明细")
  27294. userJSONBytes, _ := json.Marshal(dat)
  27295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27296. utils.ErrorLog("解析失败:%v", err)
  27297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27298. return
  27299. }
  27300. }
  27301. }
  27302. if res.Infcode == 0 {
  27303. order := &models.HisOrder{
  27304. UserOrgId: adminUser.CurrentOrgId,
  27305. HisPatientId: his.ID,
  27306. PatientId: his.PatientId,
  27307. SettleAccountsDate: recordDateTime,
  27308. MdtrtId: his.Number,
  27309. PsnNo: his.PsnNo,
  27310. MedType: strconv.FormatInt(reg_type, 10),
  27311. Ctime: time.Now().Unix(),
  27312. Mtime: time.Now().Unix(),
  27313. Status: 1,
  27314. Number: chrg_bchno,
  27315. Infcode: res.Infcode,
  27316. WarnMsg: res.WarnMsg,
  27317. Cainfo: res.Cainfo,
  27318. ErrMsg: res.ErrMsg,
  27319. RespondTime: res.RefmsgTime,
  27320. InfRefmsgid: res.InfRefmsgid,
  27321. OrderStatus: 1,
  27322. PayWay: pay_way,
  27323. PayWays: pay_ways,
  27324. OthDesc: oth_desc,
  27325. PayPrice: pay_price,
  27326. PayCardNo: pay_card_no,
  27327. DiscountPrice: discount_price,
  27328. PreferentialPrice: preferential_price,
  27329. RealityPrice: reality_price,
  27330. FoundPrice: found_price,
  27331. MedicalInsurancePrice: medical_insurance_price,
  27332. PrivatePrice: private_price,
  27333. IsMedicineInsurance: 1,
  27334. SettleType: settle_accounts_type,
  27335. SettleStartTime: start_time,
  27336. SettleEndTime: end_time,
  27337. Creator: roles.AdminUserId,
  27338. Modify: roles.AdminUserId,
  27339. FaPiaoNumber: fapiao_number,
  27340. FaPiaoCode: fapiao_code,
  27341. PType: 2,
  27342. Diagnosis: diagnosis_id,
  27343. CashPay: cash_pay,
  27344. WechatPay: wechat_pay,
  27345. AliPay: ali_pay,
  27346. JifenPay: jifen_pay,
  27347. BandCardPay: band_card_pay,
  27348. }
  27349. err = service.CreateOrder(order)
  27350. if err != nil {
  27351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27352. return
  27353. }
  27354. for _, item := range res.Output.Result {
  27355. temp := strings.Split(item.FeedetlSn, "-")
  27356. var advice_id int64 = 0
  27357. var project_id int64 = 0
  27358. var types int64 = 0
  27359. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27360. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27361. if temp[1] == "1" {
  27362. advice_id = id
  27363. project_id = 0
  27364. } else if temp[1] == "2" {
  27365. advice_id = 0
  27366. project_id = id
  27367. }
  27368. if item.MedChrgitmType == "9" {
  27369. item.MedChrgitmType = "09"
  27370. }
  27371. info := &models.HisOrderInfo{
  27372. OrderNumber: order.Number,
  27373. FeedetlSn: item.FeedetlSn,
  27374. UploadDate: time.Now().Unix(),
  27375. AdviceId: advice_id,
  27376. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27377. Cnt: item.Cnt,
  27378. Pric: float64(item.Pric),
  27379. PatientId: his.PatientId,
  27380. PricUplmtAmt: item.PricUplmtAmt,
  27381. SelfpayProp: item.SelfpayProp,
  27382. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27383. OverlmtAmt: item.OverlmtAmt,
  27384. PreselfpayAmt: item.PreselfpayAmt,
  27385. BasMednFlag: item.BasMednFlag,
  27386. MedChrgitmType: item.MedChrgitmType,
  27387. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27388. Status: 1,
  27389. Memo: item.Memo,
  27390. Mtime: time.Now().Unix(),
  27391. InscpScpAmt: item.InscpScpAmt,
  27392. DrtReimFlag: item.DrtReimFlag,
  27393. Ctime: time.Now().Unix(),
  27394. ListSpItemFlag: item.ListSpItemFlag,
  27395. ChldMedcFlag: item.ChldMedcFlag,
  27396. LmtUsedFlag: item.LmtUsedFlag,
  27397. ChrgitmLv: item.ChrgitmLv,
  27398. UserOrgId: adminUser.CurrentOrgId,
  27399. HisPatientId: his.ID,
  27400. OrderId: order.ID,
  27401. ProjectId: project_id,
  27402. Type: types,
  27403. }
  27404. service.CreateOrderInfo(info)
  27405. }
  27406. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27407. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27408. var total float64
  27409. for _, item := range prescriptions {
  27410. if item.Type == 1 { //药品
  27411. for _, subItem := range item.HisDoctorAdviceInfo {
  27412. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27413. total_one := price * subItem.PrescribingNumber
  27414. total = total + total_one
  27415. }
  27416. }
  27417. if item.Type == 2 { //项目
  27418. for _, subItem := range item.HisPrescriptionProject {
  27419. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27420. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27421. total_one := price * cnt
  27422. total = total + total_one
  27423. }
  27424. }
  27425. }
  27426. allTotal := fmt.Sprintf("%.2f", total)
  27427. //if adminUser.CurrentOrgId == 9919 {
  27428. //
  27429. // allTotal = fmt.Sprintf("%.2f", total)
  27430. //
  27431. //} else {
  27432. //
  27433. // allTotal = fmt.Sprintf("%.2f", total)
  27434. //
  27435. //}
  27436. if res.Infcode == 0 {
  27437. var rf []*ResultFive
  27438. json.Unmarshal([]byte(his.Iinfo), &rf)
  27439. chrg_bchno := chrg_bchno
  27440. cert_no := his.Certno
  27441. var insutypes []string
  27442. var insutype string
  27443. var is390 int = 0
  27444. var is310 int = 0
  27445. for _, item := range rf {
  27446. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27447. insutypes = append(insutypes, item.Insutype)
  27448. }
  27449. }
  27450. if len(insutypes) == 1 {
  27451. insutype = insutypes[0]
  27452. } else {
  27453. for _, i := range insutypes {
  27454. if i == "390" {
  27455. is390 = 1
  27456. }
  27457. if i == "310" {
  27458. is310 = 1
  27459. }
  27460. }
  27461. }
  27462. if is390 == 1 {
  27463. insutype = "390"
  27464. }
  27465. if is310 == 1 {
  27466. insutype = "310"
  27467. }
  27468. if len(insutypes) == 0 {
  27469. insutype = "310"
  27470. }
  27471. if len(insutypes) == 2 {
  27472. insutype = strconv.FormatInt(his.SocialType, 10)
  27473. }
  27474. insutype = strconv.FormatInt(his.SocialType, 10)
  27475. //insutype = "390"
  27476. if his.IdCardType == 1 {
  27477. // cert_no = his.MedicalInsuranceNumber
  27478. cert_no = his.Certno
  27479. } else {
  27480. cert_no = his.Certno
  27481. }
  27482. var res ResultSeven
  27483. var resSeven10265 ResultSeven10265
  27484. var gzresSeven10265Two GZResultSeven10265Two
  27485. var src_resquest string
  27486. var result2 string
  27487. if miConfig.MdtrtareaAdmvs == "421300" {
  27488. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27489. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27490. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27491. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27492. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27493. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27494. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27495. resp, requestErr := http.Get(api)
  27496. if requestErr != nil {
  27497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27498. return
  27499. }
  27500. body, ioErr := ioutil.ReadAll(resp.Body)
  27501. if ioErr != nil {
  27502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27504. return
  27505. }
  27506. var respJSON map[string]interface{}
  27507. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27510. return
  27511. }
  27512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27513. result, _ := json.Marshal(respJSON)
  27514. if miConfig.Code == "H15049901371" {
  27515. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27516. utils.ErrorLog("解析失败:%v", err)
  27517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27518. return
  27519. }
  27520. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27521. res.Output = resSeven10265.Output
  27522. res.ErrMsg = resSeven10265.ErrMsg
  27523. res.Cainfo = resSeven10265.Cainfo
  27524. res.WarnMsg = resSeven10265.WarnMsg
  27525. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27526. res.Infcode = infocode
  27527. } else {
  27528. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27529. utils.ErrorLog("解析失败:%v", err)
  27530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27531. return
  27532. }
  27533. }
  27534. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27535. if reg_type == 11 && his.Insutype == "390" {
  27536. reg_type = 110104
  27537. }
  27538. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27539. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27540. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27541. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27542. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27543. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27544. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27545. resp, requestErr := http.Get(api)
  27546. if requestErr != nil {
  27547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27548. return
  27549. }
  27550. body, ioErr := ioutil.ReadAll(resp.Body)
  27551. if ioErr != nil {
  27552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27554. return
  27555. }
  27556. var respJSON map[string]interface{}
  27557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27560. return
  27561. }
  27562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27563. result, _ := json.Marshal(respJSON)
  27564. if miConfig.Code == "H15049901371" {
  27565. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27566. utils.ErrorLog("解析失败:%v", err)
  27567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27568. return
  27569. }
  27570. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27571. res.Output = resSeven10265.Output
  27572. res.ErrMsg = resSeven10265.ErrMsg
  27573. res.Cainfo = resSeven10265.Cainfo
  27574. res.WarnMsg = resSeven10265.WarnMsg
  27575. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27576. res.Infcode = infocode
  27577. } else {
  27578. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27579. utils.ErrorLog("解析失败:%v", err)
  27580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27581. return
  27582. }
  27583. }
  27584. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27585. if reg_type == 11 && his.Insutype == "390" {
  27586. reg_type = 110104
  27587. }
  27588. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27589. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27590. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27591. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27592. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27593. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27594. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27595. resp, requestErr := http.Get(api)
  27596. if requestErr != nil {
  27597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27598. return
  27599. }
  27600. body, ioErr := ioutil.ReadAll(resp.Body)
  27601. if ioErr != nil {
  27602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27604. return
  27605. }
  27606. var respJSON map[string]interface{}
  27607. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27610. return
  27611. }
  27612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27613. result, _ := json.Marshal(respJSON)
  27614. if miConfig.Code == "H15049901371" {
  27615. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27616. utils.ErrorLog("解析失败:%v", err)
  27617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27618. return
  27619. }
  27620. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27621. res.Output = resSeven10265.Output
  27622. res.ErrMsg = resSeven10265.ErrMsg
  27623. res.Cainfo = resSeven10265.Cainfo
  27624. res.WarnMsg = resSeven10265.WarnMsg
  27625. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27626. res.Infcode = infocode
  27627. } else {
  27628. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27629. utils.ErrorLog("解析失败:%v", err)
  27630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27631. return
  27632. }
  27633. }
  27634. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27635. if reg_type == 11 && his.Insutype == "390" {
  27636. reg_type = 110104
  27637. }
  27638. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27639. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27640. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27641. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27642. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27643. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27644. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27645. resp, requestErr := http.Get(api)
  27646. if requestErr != nil {
  27647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27648. return
  27649. }
  27650. body, ioErr := ioutil.ReadAll(resp.Body)
  27651. if ioErr != nil {
  27652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27654. return
  27655. }
  27656. var respJSON map[string]interface{}
  27657. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27660. return
  27661. }
  27662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27663. result, _ := json.Marshal(respJSON)
  27664. if miConfig.Code == "H15049901371" {
  27665. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27666. utils.ErrorLog("解析失败:%v", err)
  27667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27668. return
  27669. }
  27670. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27671. res.Output = resSeven10265.Output
  27672. res.ErrMsg = resSeven10265.ErrMsg
  27673. res.Cainfo = resSeven10265.Cainfo
  27674. res.WarnMsg = resSeven10265.WarnMsg
  27675. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27676. res.Infcode = infocode
  27677. } else {
  27678. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27679. utils.ErrorLog("解析失败:%v", err)
  27680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27681. return
  27682. }
  27683. }
  27684. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27685. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  27686. var result3101 Result3101
  27687. //utils.ErrorLog("解析失败:%v", result3101)
  27688. result3101.Infcode = "0"
  27689. if result3101.Infcode == "0" {
  27690. if len(result3101.Output.Result) > 0 {
  27691. var errMsgs []string
  27692. for _, item := range result3101.Output.Result {
  27693. errMsgs = append(errMsgs, item.VolaCont)
  27694. }
  27695. c.ServeSuccessJSON(map[string]interface{}{
  27696. "failed_code": -10,
  27697. "msg": errMsgs,
  27698. })
  27699. return
  27700. } else {
  27701. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27702. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27703. bas := strings.Split(psn_info.CardInfo, "|")
  27704. if his.IdCardType == 1 {
  27705. cert_no = bas[2]
  27706. } else if his.IdCardType == 3 {
  27707. cert_no = his.Certno
  27708. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27709. } else if his.IdCardType == 4 {
  27710. cert_no = his.Certno
  27711. psn_info.VerifyNumber = psn_info.VerifyNumber
  27712. }
  27713. var api string
  27714. if miConfig.MdtrtareaAdmvs == "320830" {
  27715. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27716. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27717. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27718. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27719. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27720. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27721. "&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
  27722. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27723. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27724. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27725. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27726. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27727. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27728. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27729. "&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
  27730. } else {
  27731. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27732. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27733. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27734. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27735. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27736. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27737. "&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
  27738. }
  27739. resp, requestErr := http.Get(api)
  27740. if requestErr != nil {
  27741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27742. return
  27743. }
  27744. body, ioErr := ioutil.ReadAll(resp.Body)
  27745. if ioErr != nil {
  27746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27748. return
  27749. }
  27750. var respJSON map[string]interface{}
  27751. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27754. return
  27755. }
  27756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27757. result, _ := json.Marshal(respJSON)
  27758. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27759. utils.ErrorLog("解析失败:%v", err)
  27760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27761. return
  27762. }
  27763. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27764. res.Output = resSeven10265.Output
  27765. res.ErrMsg = resSeven10265.ErrMsg
  27766. res.Cainfo = resSeven10265.Cainfo
  27767. res.WarnMsg = resSeven10265.WarnMsg
  27768. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27769. res.Infcode = infocode
  27770. }
  27771. }
  27772. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27773. psn_info, _ := service.GetPsnByPatientId(id)
  27774. var verify_number string
  27775. if psn_info.IdCardType == 4 {
  27776. verify_number = psn_info.VerifyNumber
  27777. } else if psn_info.IdCardType == 1 {
  27778. bas := strings.Split(psn_info.CardInfo, "|")
  27779. cardNumber := bas[2]
  27780. verify_number = cardNumber
  27781. } else {
  27782. psn_info.IdCardType = 2
  27783. verify_number = psn_info.Certno
  27784. }
  27785. var api string
  27786. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27787. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27788. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27789. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27790. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27791. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27792. "&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
  27793. resp, requestErr := http.Get(api)
  27794. if requestErr != nil {
  27795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27796. return
  27797. }
  27798. body, ioErr := ioutil.ReadAll(resp.Body)
  27799. if ioErr != nil {
  27800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27802. return
  27803. }
  27804. var respJSON map[string]interface{}
  27805. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27808. return
  27809. }
  27810. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27811. result, _ := json.Marshal(respJSON)
  27812. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27813. utils.ErrorLog("解析失败:%v", err)
  27814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27815. return
  27816. }
  27817. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27818. res.Output = resSeven10265.Output
  27819. res.ErrMsg = resSeven10265.ErrMsg
  27820. res.Cainfo = resSeven10265.Cainfo
  27821. res.WarnMsg = resSeven10265.WarnMsg
  27822. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27823. res.Infcode = infocode
  27824. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27825. var cert_no string
  27826. if his.IdCardType == 4 {
  27827. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27828. cert_no = psn_info.VerifyNumber
  27829. 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)
  27830. } else if his.IdCardType == 1 {
  27831. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27832. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27833. 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)
  27834. }
  27835. //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)
  27836. var dat map[string]interface{}
  27837. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27838. fmt.Println(dat)
  27839. } else {
  27840. fmt.Println(err)
  27841. }
  27842. saveLog(result2, src_resquest, "2207", "结算")
  27843. userJSONBytes, _ := json.Marshal(dat)
  27844. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27845. utils.ErrorLog("解析失败:%v", err)
  27846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27847. return
  27848. }
  27849. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27850. res.Output = resSeven10265.Output
  27851. res.ErrMsg = resSeven10265.ErrMsg
  27852. res.Cainfo = resSeven10265.Cainfo
  27853. res.WarnMsg = resSeven10265.WarnMsg
  27854. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27855. res.Infcode = infocode
  27856. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27857. res2 := c.GetoleInfo()
  27858. if res2.Infcode == 0 {
  27859. var result string
  27860. var request_log string
  27861. var result_log string
  27862. if res2.Output.MdtrtCertType == "02" {
  27863. 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)
  27864. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27865. } else if res2.Output.MdtrtCertType == "01" {
  27866. 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)
  27867. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27868. } else {
  27869. 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)
  27870. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27871. }
  27872. var dat map[string]interface{}
  27873. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27874. fmt.Println(dat)
  27875. } else {
  27876. fmt.Println(err)
  27877. }
  27878. userJSONBytes, _ := json.Marshal(dat)
  27879. var res5 ResultTwo
  27880. //var resTwo10265 ResultTwo10265
  27881. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27882. utils.ErrorLog("解析失败:%v", err)
  27883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27884. return
  27885. }
  27886. if res5.Infcode == -1 {
  27887. c.ServeSuccessJSON(map[string]interface{}{
  27888. "failed_code": -10,
  27889. "msg": res5.ErrMsg,
  27890. })
  27891. return
  27892. }
  27893. var insutypes []string
  27894. var insutype string
  27895. var is390 int = 0
  27896. var is310 int = 0
  27897. for _, item := range res5.Output.Iinfo {
  27898. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27899. insutypes = append(insutypes, item.Insutype)
  27900. }
  27901. }
  27902. if len(insutypes) == 1 {
  27903. insutype = insutypes[0]
  27904. } else {
  27905. for _, i := range insutypes {
  27906. if i == "390" {
  27907. is390 = 1
  27908. }
  27909. if i == "310" {
  27910. is310 = 1
  27911. }
  27912. }
  27913. }
  27914. if is390 == 1 {
  27915. insutype = "390"
  27916. }
  27917. if is310 == 1 {
  27918. insutype = "310"
  27919. }
  27920. if len(insutypes) == 0 {
  27921. insutype = "310"
  27922. }
  27923. fmt.Println(insutype)
  27924. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27925. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27926. infoStr := string(Iinfos)
  27927. idetinfoStr := string(Idetinfos)
  27928. psn := &models.HisPsn{
  27929. PsnNo: res5.Output.Baseinfo.PsnNo,
  27930. PatientId: id,
  27931. Certno: res5.Output.Baseinfo.Certno,
  27932. Gend: res5.Output.Baseinfo.Gend,
  27933. Naty: res5.Output.Baseinfo.Naty,
  27934. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27935. PsnName: res5.Output.Baseinfo.PsnName,
  27936. Idetinfo: idetinfoStr,
  27937. Insuinfo: infoStr,
  27938. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27939. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27940. VerifyNumber: res2.Output.EcToken,
  27941. }
  27942. if res2.Output.MdtrtCertType == "01" {
  27943. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27944. psn.VerifyNumber = res2.Output.EcToken
  27945. } else if res2.Output.MdtrtCertType == "02" {
  27946. psn.VerifyNumber = res2.Output.CardNo
  27947. } else {
  27948. psn.VerifyNumber = res2.Output.MdtrtCertNo
  27949. }
  27950. service.CreateHisPsn(psn)
  27951. if res2.Output.MdtrtCertType == "01" {
  27952. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27953. token := res2.Output.EcToken
  27954. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  27955. } else if res2.Output.MdtrtCertType == "02" {
  27956. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  27957. } else {
  27958. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  27959. }
  27960. var dat2 map[string]interface{}
  27961. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27962. fmt.Println(dat2)
  27963. } else {
  27964. fmt.Println(err)
  27965. }
  27966. userJSONBytes3, _ := json.Marshal(dat2)
  27967. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27968. utils.ErrorLog("解析失败:%v", err)
  27969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27970. return
  27971. }
  27972. saveLog(result2, src_resquest, "2207", "结算")
  27973. } else {
  27974. c.ServeSuccessJSON(map[string]interface{}{
  27975. "failed_code": -10,
  27976. "msg": res2.ErrMsg,
  27977. })
  27978. return
  27979. }
  27980. } else {
  27981. if miConfig.Code == "H15049901371" {
  27982. //赤峰地区国家医保医疗类别
  27983. //职工透析:医疗类别选特殊情况门诊990502
  27984. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27985. var med_type string
  27986. if his.Insutype == "390" {
  27987. if reg_type == 14 {
  27988. med_type = "9933"
  27989. } else if reg_type == 11 {
  27990. med_type = "11"
  27991. }
  27992. } else if his.Insutype == "310" {
  27993. if reg_type == 14 {
  27994. med_type = "990502"
  27995. } else if reg_type == 11 {
  27996. med_type = "11"
  27997. }
  27998. }
  27999. 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)
  28000. } else {
  28001. if his.IdCardType == 4 {
  28002. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28003. var token string
  28004. token = psn_info.VerifyNumber
  28005. 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)
  28006. } else {
  28007. if his.IdCardType == 1 {
  28008. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28009. bas := strings.Split(psn_info.CardInfo, "|")
  28010. basNumber := bas[2]
  28011. cert_no = basNumber
  28012. }
  28013. 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)
  28014. }
  28015. }
  28016. //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)
  28017. var dat map[string]interface{}
  28018. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28019. fmt.Println(dat)
  28020. } else {
  28021. fmt.Println(err)
  28022. }
  28023. saveLog(result2, src_resquest, "2207", "结算")
  28024. userJSONBytes, _ := json.Marshal(dat)
  28025. if miConfig.Code == "H15049901371" {
  28026. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28027. utils.ErrorLog("解析失败:%v", err)
  28028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28029. return
  28030. }
  28031. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28032. res.Output = resSeven10265.Output
  28033. res.ErrMsg = resSeven10265.ErrMsg
  28034. res.Cainfo = resSeven10265.Cainfo
  28035. res.WarnMsg = resSeven10265.WarnMsg
  28036. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28037. res.Infcode = infocode
  28038. } else {
  28039. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28040. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  28041. utils.ErrorLog("解析失败:%v", err)
  28042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28043. return
  28044. }
  28045. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  28046. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  28047. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  28048. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28049. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  28050. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  28051. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  28052. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28053. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  28054. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28055. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28056. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28057. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28058. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28059. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  28060. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  28061. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  28062. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  28063. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  28064. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  28065. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28066. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  28067. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  28068. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  28069. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  28070. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  28071. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  28072. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  28073. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  28074. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  28075. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  28076. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  28077. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  28078. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  28079. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28080. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  28081. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  28082. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  28083. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28084. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  28085. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  28086. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  28087. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  28088. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  28089. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  28090. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  28091. res.ErrMsg = gzresSeven10265Two.ErrMsg
  28092. res.Cainfo = gzresSeven10265Two.Cainfo
  28093. res.WarnMsg = gzresSeven10265Two.WarnMsg
  28094. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  28095. //res.Infcode = infocode
  28096. } else {
  28097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28098. utils.ErrorLog("解析失败:%v", err)
  28099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28100. return
  28101. }
  28102. }
  28103. }
  28104. }
  28105. if res.Infcode == -1 {
  28106. errlog := &models.HisOrderError{
  28107. UserOrgId: adminUser.CurrentOrgId,
  28108. Ctime: time.Now().Unix(),
  28109. Mtime: time.Now().Unix(),
  28110. Number: chrg_bchno,
  28111. ErrMsg: res.ErrMsg,
  28112. Status: 1,
  28113. PatientId: id,
  28114. RecordTime: recordDateTime,
  28115. Stage: 6,
  28116. }
  28117. service.CreateErrMsgLog(errlog)
  28118. c.ServeSuccessJSON(map[string]interface{}{
  28119. "failed_code": -10,
  28120. "msg": res.ErrMsg,
  28121. })
  28122. return
  28123. } else {
  28124. sickConfig, _ := service.FindSickById(his.SickType)
  28125. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  28126. order.OrderStatus = 2
  28127. order.Status = 1
  28128. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  28129. order.SetlId = res.Output.Setlinfo.SetlID
  28130. order.PsnNo = res.Output.Setlinfo.PsnNo
  28131. order.PsnName = res.Output.Setlinfo.PsnName
  28132. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  28133. order.Certno = res.Output.Setlinfo.Certno
  28134. order.Gend = res.Output.Setlinfo.Gend
  28135. order.Naty = res.Output.Setlinfo.Naty
  28136. order.Age = res.Output.Setlinfo.Age
  28137. order.Insutype = res.Output.Setlinfo.Insutype
  28138. order.PsnType = res.Output.Setlinfo.PsnType
  28139. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28140. order.SetlTime = res.Output.Setlinfo.SetlTime
  28141. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28142. if res.Output.Setlinfo.MedType == "140101" {
  28143. order.MedType = "14"
  28144. } else {
  28145. if res.Output.Setlinfo.MedType == "110104" {
  28146. order.MedType = "11"
  28147. } else {
  28148. order.MedType = res.Output.Setlinfo.MedType
  28149. }
  28150. }
  28151. if reg_type == 1112 {
  28152. order.MedType = "1112"
  28153. }
  28154. if reg_type == 1111 {
  28155. order.MedType = "1111"
  28156. }
  28157. order.ClrType = res.Output.Setlinfo.ClrType
  28158. if adminUser.CurrentOrgId == 10480 {
  28159. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28160. order.ClrType = "11"
  28161. } else {
  28162. order.ClrType = "9903"
  28163. }
  28164. }
  28165. if adminUser.CurrentOrgId == 10721 {
  28166. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28167. order.ClrType = "11"
  28168. } else {
  28169. order.ClrType = "9903"
  28170. }
  28171. }
  28172. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28173. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28174. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28175. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28176. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28177. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28178. order.HifpPay = res.Output.Setlinfo.HifpPay
  28179. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28180. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28181. order.HifesPay = res.Output.Setlinfo.HifesPay
  28182. order.HifobPay = res.Output.Setlinfo.HifobPay
  28183. order.MafPay = res.Output.Setlinfo.MafPay
  28184. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28185. order.OthPay = res.Output.Setlinfo.OthPay
  28186. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28187. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28188. order.AcctPay = res.Output.Setlinfo.AcctPay
  28189. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28190. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28191. order.Balc = res.Output.Setlinfo.Balc
  28192. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28193. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28194. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28195. //order.ClrType = res.Output.Setlinfo.ClrType
  28196. order.ClrWay = res.Output.Setlinfo.ClrWay
  28197. order.Creator = order.Creator
  28198. order.Modify = roles.AdminUserId
  28199. order.RequestLog = src_resquest
  28200. order.FaPiaoNumber = fapiao_number
  28201. order.FaPiaoCode = fapiao_code
  28202. order.SickName = sickConfig.ClassName
  28203. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28204. //detailStr := string(setlDetail)
  28205. //order.SetlDetail = detailStr
  28206. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28207. err = service.UpDateOrder(order)
  28208. if err == nil {
  28209. //判断是否使用了押金
  28210. if dec_way == "true" {
  28211. tmpstring := strconv.FormatInt(order.ID, 10)
  28212. order.Decimal = decimal
  28213. service.UpDateOrder(order)
  28214. //扣押金
  28215. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28216. if errmsg != nil {
  28217. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28218. return
  28219. }
  28220. }
  28221. c.ServeSuccessJSON(map[string]interface{}{
  28222. "msg": "结算成功",
  28223. })
  28224. } else {
  28225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28226. return
  28227. }
  28228. }
  28229. } else {
  28230. adminUser := c.GetAdminUserInfo()
  28231. errlog := &models.HisOrderError{
  28232. UserOrgId: adminUser.CurrentOrgId,
  28233. Ctime: time.Now().Unix(),
  28234. Mtime: time.Now().Unix(),
  28235. ErrMsg: res.ErrMsg,
  28236. Status: 1,
  28237. PatientId: id,
  28238. RecordTime: recordDateTime,
  28239. Stage: 4,
  28240. }
  28241. service.CreateErrMsgLog(errlog)
  28242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28243. return
  28244. }
  28245. } else {
  28246. adminUser := c.GetAdminUserInfo()
  28247. errlog := &models.HisOrderError{
  28248. UserOrgId: adminUser.CurrentOrgId,
  28249. Ctime: time.Now().Unix(),
  28250. Mtime: time.Now().Unix(),
  28251. ErrMsg: res.ErrMsg,
  28252. Status: 1,
  28253. PatientId: id,
  28254. RecordTime: recordDateTime,
  28255. Stage: 4,
  28256. }
  28257. service.CreateErrMsgLog(errlog)
  28258. c.ServeSuccessJSON(map[string]interface{}{
  28259. "failed_code": -10,
  28260. "msg": res.ErrMsg,
  28261. })
  28262. return
  28263. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  28264. //return
  28265. }
  28266. }
  28267. }
  28268. } else if tempOrder.ID > 0 {
  28269. if tempOrder.IsPre == 1 {
  28270. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  28271. var rf []*ResultFive
  28272. json.Unmarshal([]byte(his.Iinfo), &rf)
  28273. chrg_bchno := tempOrder.Number
  28274. cert_no := his.Certno
  28275. var insutypes []string
  28276. var insutype string
  28277. var is390 int = 0
  28278. var is310 int = 0
  28279. for _, item := range rf {
  28280. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28281. insutypes = append(insutypes, item.Insutype)
  28282. }
  28283. }
  28284. if len(insutypes) == 1 {
  28285. insutype = insutypes[0]
  28286. } else {
  28287. for _, i := range insutypes {
  28288. if i == "390" {
  28289. is390 = 1
  28290. }
  28291. if i == "310" {
  28292. is310 = 1
  28293. }
  28294. }
  28295. }
  28296. if is390 == 1 {
  28297. insutype = "390"
  28298. }
  28299. if is310 == 1 {
  28300. insutype = "310"
  28301. }
  28302. if len(insutypes) == 0 {
  28303. insutype = "310"
  28304. }
  28305. if len(insutypes) == 2 {
  28306. insutype = strconv.FormatInt(his.SocialType, 10)
  28307. }
  28308. //insutype = "390"
  28309. if his.IdCardType == 1 {
  28310. // cert_no = his.MedicalInsuranceNumber
  28311. cert_no = his.Certno
  28312. } else {
  28313. cert_no = his.Certno
  28314. }
  28315. var res ResultSeven
  28316. var ahres ResultSevenAH
  28317. var resSeven10265 ResultSeven10265
  28318. var gzresSeven10265Two GZResultSeven10265Two
  28319. var src_resquest string
  28320. var result2 string
  28321. if miConfig.MdtrtareaAdmvs == "450721" {
  28322. res2 := c.GetoleInfo()
  28323. if res2.Infcode == 0 {
  28324. var result string
  28325. var request_log string
  28326. var result_log string
  28327. if res2.Output.MdtrtCertType == "02" {
  28328. 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)
  28329. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28330. } else if res2.Output.MdtrtCertType == "01" {
  28331. 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)
  28332. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28333. } else {
  28334. 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)
  28335. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28336. }
  28337. var dat map[string]interface{}
  28338. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28339. fmt.Println(dat)
  28340. } else {
  28341. fmt.Println(err)
  28342. }
  28343. userJSONBytes, _ := json.Marshal(dat)
  28344. var res5 ResultTwo
  28345. //var resTwo10265 ResultTwo10265
  28346. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  28347. utils.ErrorLog("解析失败:%v", err)
  28348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28349. return
  28350. }
  28351. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  28352. if res5.Infcode == -1 {
  28353. c.ServeSuccessJSON(map[string]interface{}{
  28354. "failed_code": -10,
  28355. "msg": res5.ErrMsg,
  28356. })
  28357. return
  28358. }
  28359. var insutypes []string
  28360. var insutype string
  28361. var is390 int = 0
  28362. var is310 int = 0
  28363. for _, item := range res5.Output.Iinfo {
  28364. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28365. insutypes = append(insutypes, item.Insutype)
  28366. }
  28367. }
  28368. if len(insutypes) == 1 {
  28369. insutype = insutypes[0]
  28370. } else {
  28371. for _, i := range insutypes {
  28372. if i == "390" {
  28373. is390 = 1
  28374. }
  28375. if i == "310" {
  28376. is310 = 1
  28377. }
  28378. }
  28379. }
  28380. if is390 == 1 {
  28381. insutype = "390"
  28382. }
  28383. if is310 == 1 {
  28384. insutype = "310"
  28385. }
  28386. if len(insutypes) == 0 {
  28387. insutype = "310"
  28388. }
  28389. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  28390. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  28391. infoStr := string(Iinfos)
  28392. idetinfoStr := string(Idetinfos)
  28393. psn := &models.HisPsn{
  28394. PsnNo: res5.Output.Baseinfo.PsnNo,
  28395. PatientId: id,
  28396. Certno: res5.Output.Baseinfo.Certno,
  28397. Gend: res5.Output.Baseinfo.Gend,
  28398. Naty: res5.Output.Baseinfo.Naty,
  28399. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28400. PsnName: res5.Output.Baseinfo.PsnName,
  28401. Idetinfo: idetinfoStr,
  28402. Insuinfo: infoStr,
  28403. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28404. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28405. VerifyNumber: res2.Output.EcToken,
  28406. }
  28407. service.CreateHisPsn(psn)
  28408. if res2.Output.MdtrtCertType == "01" {
  28409. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28410. token := res2.Output.EcToken
  28411. 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)
  28412. } else if res2.Output.MdtrtCertType == "02" {
  28413. 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)
  28414. } else {
  28415. 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)
  28416. }
  28417. var dat2 map[string]interface{}
  28418. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28419. fmt.Println(dat2)
  28420. } else {
  28421. fmt.Println(err)
  28422. }
  28423. userJSONBytes3, _ := json.Marshal(dat2)
  28424. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28425. utils.ErrorLog("解析失败:%v", err)
  28426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28427. return
  28428. }
  28429. saveLog(result2, src_resquest, "2207", "结算")
  28430. } else {
  28431. c.ServeSuccessJSON(map[string]interface{}{
  28432. "failed_code": -10,
  28433. "msg": res2.ErrMsg,
  28434. })
  28435. return
  28436. }
  28437. } else if miConfig.MdtrtareaAdmvs == "421300" {
  28438. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28439. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28440. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28441. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28442. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28443. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28444. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28445. resp, requestErr := http.Get(api)
  28446. if requestErr != nil {
  28447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28448. return
  28449. }
  28450. body, ioErr := ioutil.ReadAll(resp.Body)
  28451. if ioErr != nil {
  28452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28454. return
  28455. }
  28456. var respJSON map[string]interface{}
  28457. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28460. return
  28461. }
  28462. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28463. result, _ := json.Marshal(respJSON)
  28464. fmt.Println("log")
  28465. fmt.Println(string(result))
  28466. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28467. utils.ErrorLog("解析失败:%v", err)
  28468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28469. return
  28470. }
  28471. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28472. if reg_type == 11 && his.Insutype == "390" {
  28473. reg_type = 110104
  28474. }
  28475. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28476. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28477. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28478. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28479. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28480. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28481. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28482. resp, requestErr := http.Get(api)
  28483. if requestErr != nil {
  28484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28485. return
  28486. }
  28487. body, ioErr := ioutil.ReadAll(resp.Body)
  28488. if ioErr != nil {
  28489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28491. return
  28492. }
  28493. var respJSON map[string]interface{}
  28494. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28497. return
  28498. }
  28499. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28500. result, _ := json.Marshal(respJSON)
  28501. fmt.Println("log")
  28502. fmt.Println(string(result))
  28503. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28504. utils.ErrorLog("解析失败:%v", err)
  28505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28506. return
  28507. }
  28508. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28509. if reg_type == 11 && his.Insutype == "390" {
  28510. reg_type = 110104
  28511. }
  28512. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28513. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28514. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28515. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28516. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28517. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28518. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28519. resp, requestErr := http.Get(api)
  28520. if requestErr != nil {
  28521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28522. return
  28523. }
  28524. body, ioErr := ioutil.ReadAll(resp.Body)
  28525. if ioErr != nil {
  28526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28528. return
  28529. }
  28530. var respJSON map[string]interface{}
  28531. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28534. return
  28535. }
  28536. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28537. result, _ := json.Marshal(respJSON)
  28538. fmt.Println("log")
  28539. fmt.Println(string(result))
  28540. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28541. utils.ErrorLog("解析失败:%v", err)
  28542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28543. return
  28544. }
  28545. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28546. if reg_type == 11 && his.Insutype == "390" {
  28547. reg_type = 110104
  28548. }
  28549. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28550. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28551. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28552. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28553. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28554. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28555. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28556. resp, requestErr := http.Get(api)
  28557. if requestErr != nil {
  28558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28559. return
  28560. }
  28561. body, ioErr := ioutil.ReadAll(resp.Body)
  28562. if ioErr != nil {
  28563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28565. return
  28566. }
  28567. var respJSON map[string]interface{}
  28568. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28571. return
  28572. }
  28573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28574. result, _ := json.Marshal(respJSON)
  28575. fmt.Println("log")
  28576. fmt.Println(string(result))
  28577. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28578. utils.ErrorLog("解析失败:%v", err)
  28579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28580. return
  28581. }
  28582. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  28583. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28584. var result3101 Result3101
  28585. //utils.ErrorLog("解析失败:%v", result3101)
  28586. result3101.Infcode = "0"
  28587. if result3101.Infcode == "0" {
  28588. if len(result3101.Output.Result) > 0 {
  28589. var errMsgs []string
  28590. for _, item := range result3101.Output.Result {
  28591. errMsgs = append(errMsgs, item.VolaCont)
  28592. }
  28593. c.ServeSuccessJSON(map[string]interface{}{
  28594. "failed_code": -10,
  28595. "msg": errMsgs,
  28596. })
  28597. return
  28598. } else {
  28599. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28600. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28601. bas := strings.Split(psn_info.CardInfo, "|")
  28602. if his.IdCardType == 1 {
  28603. cert_no = bas[2]
  28604. } else if his.IdCardType == 3 {
  28605. cert_no = his.Certno
  28606. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28607. } else if his.IdCardType == 4 {
  28608. cert_no = his.Certno
  28609. psn_info.VerifyNumber = psn_info.VerifyNumber
  28610. }
  28611. //江苏地区国家医保医疗类别
  28612. //职工透析:医疗类别选特殊情况门诊9933
  28613. //居民血透门慢: 医疗类别选门诊慢病1402
  28614. //var med_type string
  28615. //if his.Insutype == "310" {
  28616. // if reg_type == 14 {
  28617. // med_type = "9933"
  28618. // } else if reg_type == 11 {
  28619. // med_type = "11"
  28620. //
  28621. // }
  28622. //} else if his.Insutype == "390" {
  28623. // if reg_type == 14 {
  28624. // med_type = "1402"
  28625. // } else if reg_type == 11 {
  28626. // med_type = "11"
  28627. // }
  28628. //}
  28629. var api string
  28630. if miConfig.MdtrtareaAdmvs == "320830" {
  28631. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28632. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28633. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28634. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28635. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28636. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28637. "&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
  28638. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28639. } else if miConfig.MdtrtareaAdmvs == "320921" {
  28640. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28641. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28642. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28643. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28644. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28645. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28646. "&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
  28647. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28648. } else {
  28649. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28650. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28651. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28652. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28653. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28654. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28655. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28656. "&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
  28657. }
  28658. resp, requestErr := http.Get(api)
  28659. if requestErr != nil {
  28660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28661. return
  28662. }
  28663. body, ioErr := ioutil.ReadAll(resp.Body)
  28664. if ioErr != nil {
  28665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28667. return
  28668. }
  28669. var respJSON map[string]interface{}
  28670. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28673. return
  28674. }
  28675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28676. result, _ := json.Marshal(respJSON)
  28677. fmt.Println("log")
  28678. fmt.Println(string(result))
  28679. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28680. utils.ErrorLog("解析失败:%v", err)
  28681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28682. return
  28683. }
  28684. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28685. res.Output = resSeven10265.Output
  28686. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28687. res.ErrMsg = resSeven10265.ErrMsg
  28688. res.Cainfo = resSeven10265.Cainfo
  28689. res.WarnMsg = resSeven10265.WarnMsg
  28690. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28691. res.Infcode = infocode
  28692. }
  28693. }
  28694. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28695. psn_info, _ := service.GetPsnByPatientId(id)
  28696. var verify_number string
  28697. if psn_info.IdCardType == 4 {
  28698. verify_number = psn_info.VerifyNumber
  28699. } else if psn_info.IdCardType == 1 {
  28700. bas := strings.Split(psn_info.CardInfo, "|")
  28701. cardNumber := bas[2]
  28702. verify_number = cardNumber
  28703. } else {
  28704. verify_number = psn_info.Certno
  28705. psn_info.IdCardType = 2
  28706. }
  28707. var api string
  28708. new_chrg_bchno := chrg_bchno
  28709. if adminUser.CurrentOrgId == 10265 {
  28710. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28711. new_chrg_bchno = "0000"
  28712. }
  28713. }
  28714. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28715. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  28716. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28717. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28718. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28719. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28720. "&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
  28721. resp, requestErr := http.Get(api)
  28722. if requestErr != nil {
  28723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28724. return
  28725. }
  28726. body, ioErr := ioutil.ReadAll(resp.Body)
  28727. if ioErr != nil {
  28728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28730. return
  28731. }
  28732. var respJSON map[string]interface{}
  28733. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28736. return
  28737. }
  28738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28739. result, _ := json.Marshal(respJSON)
  28740. fmt.Println("log")
  28741. fmt.Println(string(result))
  28742. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28743. utils.ErrorLog("解析失败:%v", err)
  28744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28745. return
  28746. }
  28747. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28748. res.Output = resSeven10265.Output
  28749. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28750. res.ErrMsg = resSeven10265.ErrMsg
  28751. res.Cainfo = resSeven10265.Cainfo
  28752. res.WarnMsg = resSeven10265.WarnMsg
  28753. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28754. res.Infcode = infocode
  28755. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28756. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28757. var cert_no string
  28758. if his.IdCardType == 1 {
  28759. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28760. } else {
  28761. cert_no = psn_info.VerifyNumber
  28762. }
  28763. 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)
  28764. var dat map[string]interface{}
  28765. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28766. fmt.Println(dat)
  28767. } else {
  28768. fmt.Println(err)
  28769. }
  28770. saveLog(result2, src_resquest, "2207", "结算")
  28771. userJSONBytes, _ := json.Marshal(dat)
  28772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28773. utils.ErrorLog("解析失败:%v", err)
  28774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28775. return
  28776. }
  28777. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28778. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28779. var cert_no string
  28780. var card_sn string
  28781. if his.IdCardType == 1 {
  28782. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28783. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28784. bas := strings.Split(psn_info.CardInfo, "|")
  28785. card_sn = bas[3]
  28786. } else if his.IdCardType == 2 {
  28787. cert_no = his.IdCardNo
  28788. } else {
  28789. cert_no = psn_info.VerifyNumber
  28790. }
  28791. var rf []*ResultFive
  28792. json.Unmarshal([]byte(his.Iinfo), &rf)
  28793. var psn_type string
  28794. for _, item := range rf {
  28795. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28796. psn_type = item.PsnType
  28797. }
  28798. }
  28799. 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)
  28800. var dat map[string]interface{}
  28801. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28802. fmt.Println(dat)
  28803. } else {
  28804. fmt.Println(err)
  28805. }
  28806. saveLog(result2, src_resquest, "2207", "结算")
  28807. userJSONBytes, _ := json.Marshal(dat)
  28808. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28809. utils.ErrorLog("解析失败:%v", err)
  28810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28811. return
  28812. }
  28813. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28814. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28815. var cert_no string
  28816. var card_sn string
  28817. if his.IdCardType == 1 {
  28818. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28819. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28820. //bas := strings.Split(psn_info.CardInfo, "|")
  28821. card_sn = ""
  28822. } else if his.IdCardType == 2 {
  28823. cert_no = his.IdCardNo
  28824. } else {
  28825. cert_no = psn_info.VerifyNumber
  28826. }
  28827. var rf []*ResultFive
  28828. json.Unmarshal([]byte(his.Iinfo), &rf)
  28829. var psn_type string
  28830. for _, item := range rf {
  28831. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28832. psn_type = item.PsnType
  28833. }
  28834. }
  28835. 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)
  28836. var dat map[string]interface{}
  28837. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28838. fmt.Println(dat)
  28839. } else {
  28840. fmt.Println(err)
  28841. }
  28842. saveLog(result2, src_resquest, "2207", "结算")
  28843. userJSONBytes, _ := json.Marshal(dat)
  28844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28845. utils.ErrorLog("解析失败:%v", err)
  28846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28847. return
  28848. }
  28849. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28850. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28851. var cert_no string
  28852. var card_sn string
  28853. if his.IdCardType == 1 {
  28854. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28855. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28856. //bas := strings.Split(psn_info.CardInfo, "|")
  28857. card_sn = ""
  28858. } else if his.IdCardType == 2 {
  28859. cert_no = his.IdCardNo
  28860. } else {
  28861. cert_no = psn_info.VerifyNumber
  28862. }
  28863. var rf []*ResultFive
  28864. json.Unmarshal([]byte(his.Iinfo), &rf)
  28865. var psn_type string
  28866. for _, item := range rf {
  28867. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28868. psn_type = item.PsnType
  28869. }
  28870. }
  28871. 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)
  28872. var dat map[string]interface{}
  28873. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28874. fmt.Println(dat)
  28875. } else {
  28876. fmt.Println(err)
  28877. }
  28878. saveLog(result2, src_resquest, "2207", "结算")
  28879. userJSONBytes, _ := json.Marshal(dat)
  28880. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28881. utils.ErrorLog("解析失败:%v", err)
  28882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28883. return
  28884. }
  28885. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28886. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28887. if his.IdCardType == 1 {
  28888. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28889. bas := strings.Split(psn_info.CardInfo, "|")
  28890. cert_no = bas[2]
  28891. } else if his.IdCardType == 3 {
  28892. cert_no = his.Certno
  28893. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28894. } else if his.IdCardType == 4 {
  28895. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28896. cert_no = psn_info.VerifyNumber
  28897. psn_info.VerifyNumber = psn_info.VerifyNumber
  28898. } else {
  28899. cert_no = his.Certno
  28900. psn_info.VerifyNumber = his.Certno
  28901. }
  28902. var api string
  28903. var med_type string
  28904. if his.Insutype == "390" {
  28905. if reg_type == 992102 {
  28906. med_type = "992102"
  28907. }
  28908. if reg_type == 1104 {
  28909. med_type = "1104"
  28910. }
  28911. if reg_type == 1104 {
  28912. med_type = "1104"
  28913. }
  28914. if reg_type == 140104 {
  28915. med_type = "140104"
  28916. }
  28917. if reg_type == 140201 {
  28918. med_type = "140201"
  28919. }
  28920. if reg_type == 14 {
  28921. med_type = "14"
  28922. }
  28923. } else if his.Insutype == "310" {
  28924. if reg_type == 1104 {
  28925. med_type = "1104"
  28926. }
  28927. if reg_type == 992102 {
  28928. med_type = "992102"
  28929. }
  28930. if reg_type == 140104 {
  28931. med_type = "140104"
  28932. }
  28933. if reg_type == 140201 {
  28934. med_type = "140201"
  28935. }
  28936. if reg_type == 14 {
  28937. med_type = "14"
  28938. }
  28939. }
  28940. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28941. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28942. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28943. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28944. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28945. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28946. "&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
  28947. resp, requestErr := http.Get(api)
  28948. if requestErr != nil {
  28949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28950. return
  28951. }
  28952. body, ioErr := ioutil.ReadAll(resp.Body)
  28953. if ioErr != nil {
  28954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28956. return
  28957. }
  28958. var respJSON map[string]interface{}
  28959. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28962. return
  28963. }
  28964. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28965. if status == "0" {
  28966. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28967. c.ServeSuccessJSON(map[string]interface{}{
  28968. "failed_code": -10,
  28969. "msg": err_msg,
  28970. })
  28971. return
  28972. }
  28973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28974. result, _ := json.Marshal(respJSON)
  28975. fmt.Println("log")
  28976. fmt.Println(string(result))
  28977. if err := json.Unmarshal(result, &ahres); err != nil {
  28978. utils.ErrorLog("解析失败:%v", err)
  28979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28980. return
  28981. }
  28982. res.InfRefmsgid = ahres.InfRefmsgid
  28983. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28984. // 创建对应的Time类型
  28985. t := time.UnixMilli(timestamp)
  28986. // 格式化成指定的日期字符串
  28987. str := t.Format("2006-01-02 15:04:05")
  28988. res.Output.Setlinfo.SetlTime = str
  28989. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28990. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28991. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28992. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28993. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28994. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28995. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28996. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28997. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28998. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28999. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29000. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29001. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29002. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29003. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29004. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29005. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29006. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29007. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29008. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29009. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29010. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29011. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29012. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29013. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29014. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29015. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29016. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29017. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29018. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29019. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29020. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29021. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29022. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29023. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29024. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29025. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29026. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29027. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29028. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29029. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29030. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29031. res.Output.Setldetail = ahres.Output.Setldetail
  29032. res.ErrMsg = ahres.ErrMsg
  29033. res.Cainfo = ahres.Cainfo
  29034. res.WarnMsg = ahres.WarnMsg
  29035. res.Infcode = ahres.Infcode
  29036. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29037. res.Output.Setlinfo.ClrType = "11"
  29038. } else {
  29039. res.Output.Setlinfo.ClrType = "9903"
  29040. }
  29041. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29042. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29043. if his.IdCardType == 1 {
  29044. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29045. bas := strings.Split(psn_info.CardInfo, "|")
  29046. cert_no = bas[2]
  29047. } else if his.IdCardType == 3 {
  29048. cert_no = his.Certno
  29049. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  29050. } else if his.IdCardType == 4 {
  29051. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29052. cert_no = his.Certno
  29053. psn_info.VerifyNumber = psn_info.VerifyNumber
  29054. } else {
  29055. cert_no = his.Certno
  29056. psn_info.VerifyNumber = his.Certno
  29057. }
  29058. var api string
  29059. var med_type string
  29060. if his.Insutype == "390" {
  29061. if reg_type == 1104 {
  29062. med_type = "1104"
  29063. }
  29064. if reg_type == 992102 {
  29065. med_type = "992102"
  29066. }
  29067. if reg_type == 140104 {
  29068. med_type = "140104"
  29069. }
  29070. if reg_type == 14 {
  29071. med_type = "14"
  29072. }
  29073. if reg_type == 140201 {
  29074. med_type = "140201"
  29075. }
  29076. } else if his.Insutype == "310" {
  29077. if reg_type == 1104 {
  29078. med_type = "1104"
  29079. }
  29080. if reg_type == 992102 {
  29081. med_type = "992102"
  29082. }
  29083. if reg_type == 14 {
  29084. med_type = "14"
  29085. }
  29086. if reg_type == 140104 {
  29087. med_type = "140104"
  29088. }
  29089. if reg_type == 140201 {
  29090. med_type = "140201"
  29091. }
  29092. }
  29093. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29094. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29095. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29096. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29097. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29098. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29099. "&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
  29100. resp, requestErr := http.Get(api)
  29101. if requestErr != nil {
  29102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29103. return
  29104. }
  29105. body, ioErr := ioutil.ReadAll(resp.Body)
  29106. if ioErr != nil {
  29107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29109. return
  29110. }
  29111. var respJSON map[string]interface{}
  29112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29115. return
  29116. }
  29117. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29118. if status == "0" {
  29119. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29120. c.ServeSuccessJSON(map[string]interface{}{
  29121. "failed_code": -10,
  29122. "msg": err_msg,
  29123. })
  29124. return
  29125. }
  29126. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29127. result, _ := json.Marshal(respJSON)
  29128. fmt.Println("log")
  29129. fmt.Println(string(result))
  29130. if err := json.Unmarshal(result, &ahres); err != nil {
  29131. utils.ErrorLog("解析失败:%v", err)
  29132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29133. return
  29134. }
  29135. res.InfRefmsgid = ahres.InfRefmsgid
  29136. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29137. // 创建对应的Time类型
  29138. t := time.UnixMilli(timestamp)
  29139. // 格式化成指定的日期字符串
  29140. str := t.Format("2006-01-02 15:04:05")
  29141. res.Output.Setlinfo.SetlTime = str
  29142. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29143. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29144. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29145. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29146. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29147. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29148. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29149. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29150. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29151. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29152. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29153. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29154. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29155. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29156. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29157. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29158. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29159. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29160. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29161. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29162. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29163. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29164. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29165. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29166. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29167. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29168. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29169. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29170. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29171. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29172. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29173. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29174. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29175. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29176. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29177. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29178. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29179. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29180. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29181. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29182. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29183. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29184. res.Output.Setldetail = ahres.Output.Setldetail
  29185. res.ErrMsg = ahres.ErrMsg
  29186. res.Cainfo = ahres.Cainfo
  29187. res.WarnMsg = ahres.WarnMsg
  29188. res.Infcode = ahres.Infcode
  29189. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  29190. res.Output.Setlinfo.ClrType = "11"
  29191. } else {
  29192. res.Output.Setlinfo.ClrType = "9903"
  29193. }
  29194. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29195. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29196. var cert_no string
  29197. if his.IdCardType == 1 {
  29198. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  29199. } else if his.IdCardType == 2 {
  29200. cert_no = his.IdCardNo
  29201. } else {
  29202. cert_no = psn_info.VerifyNumber
  29203. }
  29204. 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, "")
  29205. var dat map[string]interface{}
  29206. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29207. fmt.Println(dat)
  29208. } else {
  29209. fmt.Println(err)
  29210. }
  29211. saveLog(result2, src_resquest, "2207", "结算")
  29212. userJSONBytes, _ := json.Marshal(dat)
  29213. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29214. utils.ErrorLog("解析失败:%v", err)
  29215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29216. return
  29217. }
  29218. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29219. psn_info, _ := service.GetPsnByPatientId(id)
  29220. var verify_number string
  29221. if psn_info.IdCardType == 4 {
  29222. verify_number = psn_info.VerifyNumber
  29223. } else if psn_info.IdCardType == 1 {
  29224. bas := strings.Split(psn_info.CardInfo, "|")
  29225. cardNumber := bas[2]
  29226. verify_number = cardNumber
  29227. } else {
  29228. verify_number = psn_info.Certno
  29229. psn_info.IdCardType = 2
  29230. }
  29231. var api string
  29232. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29233. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29234. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29235. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29236. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29237. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29238. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  29239. resp, requestErr := http.Get(api)
  29240. if requestErr != nil {
  29241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29242. return
  29243. }
  29244. body, ioErr := ioutil.ReadAll(resp.Body)
  29245. if ioErr != nil {
  29246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29248. return
  29249. }
  29250. var respJSON map[string]interface{}
  29251. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29254. return
  29255. }
  29256. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29257. result, _ := json.Marshal(respJSON)
  29258. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29259. utils.ErrorLog("解析失败:%v", err)
  29260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29261. return
  29262. }
  29263. } else {
  29264. var src_resquest string
  29265. if miConfig.Code == "H15049901371" {
  29266. //赤峰地区国家医保医疗类别
  29267. //职工透析:医疗类别选特殊情况门诊990502
  29268. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29269. var med_type string
  29270. if his.Insutype == "390" {
  29271. if reg_type == 14 {
  29272. med_type = "9933"
  29273. } else if reg_type == 11 {
  29274. med_type = "11"
  29275. }
  29276. } else if his.Insutype == "310" {
  29277. if reg_type == 14 {
  29278. med_type = "990502"
  29279. } else if reg_type == 11 {
  29280. med_type = "11"
  29281. }
  29282. }
  29283. 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)
  29284. } else {
  29285. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998"{
  29286. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  29287. if result3101.Infcode == 0 {
  29288. if len(result3101.Output.Result) > 0 {
  29289. c.ServeSuccessJSON(map[string]interface{}{
  29290. "failed_code": -10,
  29291. "failed_type": 100,
  29292. "warm_type": 2,
  29293. "msg": result3101,
  29294. })
  29295. return
  29296. }
  29297. } else {
  29298. c.ServeSuccessJSON(map[string]interface{}{
  29299. "failed_code": -10,
  29300. "msg": result3101.ErrMsg,
  29301. })
  29302. return
  29303. }
  29304. }
  29305. if his.IdCardType == 4 {
  29306. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29307. token := psn_info.VerifyNumber
  29308. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  29309. } else {
  29310. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  29311. }
  29312. }
  29313. var dat map[string]interface{}
  29314. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29315. fmt.Println(dat)
  29316. } else {
  29317. fmt.Println(err)
  29318. }
  29319. saveLog(result2, src_resquest, "2207", "结算")
  29320. userJSONBytes, _ := json.Marshal(dat)
  29321. if miConfig.Code == "H15049901371" {
  29322. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29323. utils.ErrorLog("解析失败:%v", err)
  29324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29325. return
  29326. }
  29327. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29328. res.Output = resSeven10265.Output
  29329. res.ErrMsg = resSeven10265.ErrMsg
  29330. res.Cainfo = resSeven10265.Cainfo
  29331. res.WarnMsg = resSeven10265.WarnMsg
  29332. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29333. res.Infcode = infocode
  29334. } else {
  29335. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29336. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29337. utils.ErrorLog("解析失败:%v", err)
  29338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29339. return
  29340. }
  29341. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29342. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29343. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29344. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29345. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29346. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29347. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29348. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29349. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29350. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29351. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29352. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29353. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29354. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29355. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29356. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29357. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29358. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29359. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29360. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29361. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29362. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29363. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29364. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29365. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29366. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29367. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29368. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29369. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29370. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29371. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29372. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29373. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29374. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29375. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29376. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29377. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29378. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29379. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29380. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29381. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29382. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29383. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29384. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29385. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29386. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29387. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29388. res.Cainfo = gzresSeven10265Two.Cainfo
  29389. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29390. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29391. //res.Infcode = infocode
  29392. } else {
  29393. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29394. utils.ErrorLog("解析失败:%v", err)
  29395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29396. return
  29397. }
  29398. }
  29399. }
  29400. }
  29401. if res.Infcode != 0 {
  29402. errlog := &models.HisOrderError{
  29403. UserOrgId: adminUser.CurrentOrgId,
  29404. Ctime: time.Now().Unix(),
  29405. Mtime: time.Now().Unix(),
  29406. Number: chrg_bchno,
  29407. ErrMsg: res.ErrMsg,
  29408. Status: 1,
  29409. PatientId: id,
  29410. RecordTime: recordDateTime,
  29411. Stage: 6,
  29412. }
  29413. service.CreateErrMsgLog(errlog)
  29414. c.ServeSuccessJSON(map[string]interface{}{
  29415. "failed_code": -10,
  29416. "msg": res.ErrMsg,
  29417. })
  29418. return
  29419. } else {
  29420. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29421. order.OrderStatus = 2
  29422. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29423. order.SetlId = res.Output.Setlinfo.SetlID
  29424. order.PsnNo = res.Output.Setlinfo.PsnNo
  29425. order.PsnName = res.Output.Setlinfo.PsnName
  29426. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29427. order.Certno = res.Output.Setlinfo.Certno
  29428. order.Gend = res.Output.Setlinfo.Gend
  29429. order.Naty = res.Output.Setlinfo.Naty
  29430. order.Age = res.Output.Setlinfo.Age
  29431. order.Insutype = res.Output.Setlinfo.Insutype
  29432. order.PsnType = res.Output.Setlinfo.PsnType
  29433. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29434. order.SetlTime = res.Output.Setlinfo.SetlTime
  29435. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29436. order.PayWays = pay_ways
  29437. order.AcctUsedFlag = acct_used_flag
  29438. order.WechatPay = wechat_pay
  29439. order.AliPay = ali_pay
  29440. order.JifenPay = jifen_pay
  29441. order.BandCardPay = band_card_pay
  29442. order.CashPay = cash_pay
  29443. order.OthDesc = oth_desc
  29444. //order.MedType = res.Output.Setlinfo.MedType
  29445. if reg_type == 1112 {
  29446. order.MedType = "1112"
  29447. }
  29448. if reg_type == 1111 {
  29449. order.MedType = "1111"
  29450. }
  29451. order.ClrType = res.Output.Setlinfo.ClrType
  29452. if adminUser.CurrentOrgId == 10480 {
  29453. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29454. order.ClrType = "11"
  29455. } else {
  29456. order.ClrType = "9903"
  29457. }
  29458. }
  29459. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29460. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29461. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29462. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29463. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29464. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29465. order.HifpPay = res.Output.Setlinfo.HifpPay
  29466. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29467. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29468. order.HifesPay = res.Output.Setlinfo.HifesPay
  29469. order.HifobPay = res.Output.Setlinfo.HifobPay
  29470. order.MafPay = res.Output.Setlinfo.MafPay
  29471. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29472. order.OthPay = res.Output.Setlinfo.OthPay
  29473. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29474. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29475. order.AcctPay = res.Output.Setlinfo.AcctPay
  29476. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29477. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29478. order.Balc = res.Output.Setlinfo.Balc
  29479. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29480. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29481. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29482. order.ClrWay = res.Output.Setlinfo.ClrWay
  29483. order.Creator = order.Creator
  29484. order.Modify = roles.AdminUserId
  29485. order.RequestLog = src_resquest
  29486. order.Diagnosis = diagnosis_id
  29487. order.FaPiaoNumber = fapiao_number
  29488. order.FaPiaoCode = fapiao_code
  29489. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29490. detailStr := string(setlDetail)
  29491. order.SetlDetail = detailStr
  29492. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29493. err = service.UpDateOrder(order)
  29494. if err == nil {
  29495. //判断是否使用了押金
  29496. if dec_way == "true" {
  29497. tmpstring := strconv.FormatInt(order.ID, 10)
  29498. //扣押金
  29499. order.Decimal = decimal
  29500. service.UpDateOrder(order)
  29501. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  29502. if errmsg != nil {
  29503. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  29504. return
  29505. }
  29506. }
  29507. c.ServeSuccessJSON(map[string]interface{}{
  29508. "msg": "结算成功",
  29509. })
  29510. } else {
  29511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29512. return
  29513. }
  29514. }
  29515. }
  29516. }
  29517. }
  29518. // 上传明细-预结算-
  29519. func (c *HisApiController) GetPreUploadInfo() {
  29520. id, _ := c.GetInt64("id")
  29521. record_time := c.GetString("record_time")
  29522. his_patient_id, _ := c.GetInt64("his_patient_id")
  29523. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  29524. admin_user_id, _ := c.GetInt64("admin_user_id")
  29525. diagnosis_id := c.GetString("diagnosis")
  29526. sick_type, _ := c.GetInt64("sick_type")
  29527. reg_type, _ := c.GetInt64("p_type")
  29528. begin_time := c.GetString("begin_time")
  29529. acct_used_flag := c.GetString("acct_used_flag")
  29530. id_str := c.GetString("ids")
  29531. ids_arr := strings.Split(id_str, ",")
  29532. timeLayout := "2006-01-02"
  29533. loc, _ := time.LoadLocation("Local")
  29534. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29535. if err != nil {
  29536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29537. return
  29538. }
  29539. recordDateTime := theTime.Unix()
  29540. adminUser := c.GetAdminUserInfo()
  29541. diagnosis_ids := strings.Split(diagnosis_id, ",")
  29542. var config []*models.HisXtDiagnoseConfig
  29543. for _, item := range diagnosis_ids {
  29544. id, _ := strconv.ParseInt(item, 10, 64)
  29545. if id > 0 {
  29546. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29547. config = append(config, &diagnosisConfig)
  29548. }
  29549. }
  29550. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  29551. sickConfig, _ := service.FindSickById(sick_type)
  29552. var prescriptions []*models.HisPrescription
  29553. var start_time int64
  29554. var end_time int64
  29555. var isSuccess bool = true
  29556. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29557. fmt.Println(his_patient_id)
  29558. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29559. timestamp := time.Now().Unix()
  29560. tempTime := time.Unix(timestamp, 0)
  29561. timeFormat := tempTime.Format("20060102150405")
  29562. chrgBchno := rand.Intn(100000) + 10000
  29563. new_chrg_bchno := ""
  29564. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  29565. new_chrg_bchno = chrg_bchno
  29566. if adminUser.CurrentOrgId == 10265 {
  29567. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29568. new_chrg_bchno = "0000"
  29569. }
  29570. }
  29571. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29572. var patientPrescription models.HisPrescriptionInfo
  29573. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29574. if patientPrescription.ID == 0 {
  29575. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  29576. }
  29577. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29578. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29579. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29580. strconv.FormatInt(his.PatientId, 10)
  29581. var res2406 Result2406
  29582. //安徽单病种处理
  29583. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  29584. data := make(map[string]interface{})
  29585. client := &http.Client{}
  29586. data["psn_no"] = his.PsnNo
  29587. data["mdtrt_id"] = his.Number
  29588. data["operator"] = roles.UserName
  29589. data["cert_no"] = his.IdCardNo
  29590. data["org_name"] = miConfig.OrgName
  29591. data["psn_name"] = his.Name
  29592. data["ipt_otp_no"] = his.IptOtpNo
  29593. data["ipt_psn_sp_flag_type"] = "0901"
  29594. data["ipt_psn_sp_flag"] = "1"
  29595. data["fixmedins_code"] = miConfig.Code
  29596. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29597. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29598. data["url"] = miConfig.Url
  29599. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29600. bytesData, _ := json.Marshal(data)
  29601. var req *http.Request
  29602. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29603. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29604. resp, _ := client.Do(req)
  29605. defer resp.Body.Close()
  29606. body, ioErr := ioutil.ReadAll(resp.Body)
  29607. if ioErr != nil {
  29608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29610. return
  29611. }
  29612. var respJSON map[string]interface{}
  29613. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29616. return
  29617. }
  29618. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29619. if status == "0" {
  29620. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29621. c.ServeSuccessJSON(map[string]interface{}{
  29622. "failed_code": -10,
  29623. "msg": err_msg,
  29624. })
  29625. return
  29626. }
  29627. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29628. userJSONBytes, _ := json.Marshal(respJSON)
  29629. fmt.Println("log")
  29630. fmt.Println(string(userJSONBytes))
  29631. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29632. utils.ErrorLog("解析失败:%v", err)
  29633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29634. return
  29635. }
  29636. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  29637. data := make(map[string]interface{})
  29638. client := &http.Client{}
  29639. data["psn_no"] = his.PsnNo
  29640. data["mdtrt_id"] = his.Number
  29641. data["operator"] = roles.UserName
  29642. data["cert_no"] = his.IdCardNo
  29643. data["org_name"] = miConfig.OrgName
  29644. data["psn_name"] = his.Name
  29645. data["ipt_otp_no"] = his.IptOtpNo
  29646. data["ipt_psn_sp_flag_type"] = "0901"
  29647. data["ipt_psn_sp_flag"] = "1"
  29648. data["fixmedins_code"] = miConfig.Code
  29649. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29650. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29651. data["url"] = miConfig.Url
  29652. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29653. bytesData, _ := json.Marshal(data)
  29654. var req *http.Request
  29655. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29656. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29657. resp, _ := client.Do(req)
  29658. defer resp.Body.Close()
  29659. body, ioErr := ioutil.ReadAll(resp.Body)
  29660. if ioErr != nil {
  29661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29663. return
  29664. }
  29665. var respJSON map[string]interface{}
  29666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29669. return
  29670. }
  29671. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29672. if status == "0" {
  29673. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29674. c.ServeSuccessJSON(map[string]interface{}{
  29675. "failed_code": -10,
  29676. "msg": err_msg,
  29677. })
  29678. return
  29679. }
  29680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29681. userJSONBytes, _ := json.Marshal(respJSON)
  29682. fmt.Println("log")
  29683. fmt.Println(string(userJSONBytes))
  29684. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29685. utils.ErrorLog("解析失败:%v", err)
  29686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29687. return
  29688. }
  29689. }
  29690. if res2406.Infcode != 0 {
  29691. adminUser := c.GetAdminUserInfo()
  29692. errlog := &models.HisOrderError{
  29693. UserOrgId: adminUser.CurrentOrgId,
  29694. Ctime: time.Now().Unix(),
  29695. Mtime: time.Now().Unix(),
  29696. ErrMsg: res2406.ErrMsg,
  29697. Status: 1,
  29698. PatientId: id,
  29699. RecordTime: recordDateTime,
  29700. Stage: 3,
  29701. }
  29702. service.CreateErrMsgLog(errlog)
  29703. c.ServeSuccessJSON(map[string]interface{}{
  29704. "failed_code": -10,
  29705. "msg": res2406.ErrMsg,
  29706. })
  29707. return
  29708. }
  29709. var res2 ResultSix
  29710. var res3 GZResultSix
  29711. var resSix10265 ResultSix10265
  29712. //var time_stamp string
  29713. if miConfig.MdtrtareaAdmvs == "421300" {
  29714. data := make(map[string]interface{})
  29715. client := &http.Client{}
  29716. data["psn_no"] = his.PsnNo
  29717. data["mdtrt_id"] = his.Number
  29718. data["department"] = department.Name
  29719. data["org_name"] = miConfig.OrgName
  29720. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29721. data["doctor_id"] = doctor_info.DoctorNumber
  29722. data["doctor_name"] = roles.UserName
  29723. data["fixmedins_code"] = miConfig.Code
  29724. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29725. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29726. data["secret_key"] = miConfig.SecretKey
  29727. data["sick_code"] = sickConfig.CountryCode
  29728. data["sick_name"] = sickConfig.ClassName
  29729. data["begin_time"] = begin_time
  29730. data["dept"] = strconv.FormatInt(department.ID, 10)
  29731. data["config"] = config
  29732. data["opter"] = roles.UserName
  29733. fmt.Println(data)
  29734. bytesData, _ := json.Marshal(data)
  29735. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29736. resp, _ := client.Do(req)
  29737. defer resp.Body.Close()
  29738. body, ioErr := ioutil.ReadAll(resp.Body)
  29739. if ioErr != nil {
  29740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29742. return
  29743. }
  29744. var respJSON map[string]interface{}
  29745. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29748. return
  29749. }
  29750. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29751. userJSONBytes, _ := json.Marshal(respJSON)
  29752. fmt.Println("log")
  29753. fmt.Println(string(userJSONBytes))
  29754. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29755. utils.ErrorLog("解析失败:%v", err)
  29756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29757. return
  29758. }
  29759. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29760. data := make(map[string]interface{})
  29761. client := &http.Client{}
  29762. data["psn_no"] = his.PsnNo
  29763. data["mdtrt_id"] = his.Number
  29764. data["department"] = department.Name
  29765. data["org_name"] = miConfig.OrgName
  29766. if reg_type == 11 && his.Insutype == "390" {
  29767. data["med_type"] = "110104"
  29768. } else {
  29769. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29770. }
  29771. data["doctor_id"] = doctor_info.DoctorNumber
  29772. data["doctor_name"] = roles.UserName
  29773. data["fixmedins_code"] = miConfig.Code
  29774. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29775. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29776. data["secret_key"] = miConfig.SecretKey
  29777. data["sick_code"] = sickConfig.CountryCode
  29778. data["sick_name"] = sickConfig.ClassName
  29779. data["begin_time"] = begin_time
  29780. data["dept"] = strconv.FormatInt(department.ID, 10)
  29781. data["config"] = config
  29782. data["opter"] = roles.UserName
  29783. fmt.Println(data)
  29784. bytesData, _ := json.Marshal(data)
  29785. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29786. resp, _ := client.Do(req)
  29787. defer resp.Body.Close()
  29788. body, ioErr := ioutil.ReadAll(resp.Body)
  29789. if ioErr != nil {
  29790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29792. return
  29793. }
  29794. var respJSON map[string]interface{}
  29795. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29798. return
  29799. }
  29800. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29801. userJSONBytes, _ := json.Marshal(respJSON)
  29802. fmt.Println("log")
  29803. fmt.Println(string(userJSONBytes))
  29804. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29805. utils.ErrorLog("解析失败:%v", err)
  29806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29807. return
  29808. }
  29809. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29810. data := make(map[string]interface{})
  29811. client := &http.Client{}
  29812. data["psn_no"] = his.PsnNo
  29813. data["mdtrt_id"] = his.Number
  29814. data["department"] = department.Name
  29815. data["org_name"] = miConfig.OrgName
  29816. if reg_type == 11 && his.Insutype == "390" {
  29817. data["med_type"] = "110104"
  29818. } else {
  29819. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29820. }
  29821. data["doctor_id"] = doctor_info.DoctorNumber
  29822. data["doctor_name"] = roles.UserName
  29823. data["fixmedins_code"] = miConfig.Code
  29824. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29825. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29826. data["secret_key"] = miConfig.SecretKey
  29827. data["sick_code"] = sickConfig.CountryCode
  29828. data["sick_name"] = sickConfig.ClassName
  29829. data["begin_time"] = begin_time
  29830. data["dept"] = strconv.FormatInt(department.ID, 10)
  29831. data["config"] = config
  29832. data["opter"] = roles.UserName
  29833. fmt.Println(data)
  29834. bytesData, _ := json.Marshal(data)
  29835. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29836. resp, _ := client.Do(req)
  29837. defer resp.Body.Close()
  29838. body, ioErr := ioutil.ReadAll(resp.Body)
  29839. if ioErr != nil {
  29840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29842. return
  29843. }
  29844. var respJSON map[string]interface{}
  29845. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29848. return
  29849. }
  29850. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29851. userJSONBytes, _ := json.Marshal(respJSON)
  29852. fmt.Println("log")
  29853. fmt.Println(string(userJSONBytes))
  29854. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29855. utils.ErrorLog("解析失败:%v", err)
  29856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29857. return
  29858. }
  29859. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29860. data := make(map[string]interface{})
  29861. client := &http.Client{}
  29862. data["psn_no"] = his.PsnNo
  29863. data["mdtrt_id"] = his.Number
  29864. data["department"] = department.Name
  29865. data["org_name"] = miConfig.OrgName
  29866. if reg_type == 11 && his.Insutype == "390" {
  29867. data["med_type"] = "110104"
  29868. } else {
  29869. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29870. }
  29871. data["doctor_id"] = doctor_info.DoctorNumber
  29872. data["doctor_name"] = roles.UserName
  29873. data["fixmedins_code"] = miConfig.Code
  29874. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29875. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29876. data["secret_key"] = miConfig.SecretKey
  29877. data["sick_code"] = sickConfig.CountryCode
  29878. data["sick_name"] = sickConfig.ClassName
  29879. data["begin_time"] = begin_time
  29880. data["dept"] = strconv.FormatInt(department.ID, 10)
  29881. data["config"] = config
  29882. data["opter"] = roles.UserName
  29883. fmt.Println(data)
  29884. bytesData, _ := json.Marshal(data)
  29885. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29886. resp, _ := client.Do(req)
  29887. defer resp.Body.Close()
  29888. body, ioErr := ioutil.ReadAll(resp.Body)
  29889. if ioErr != nil {
  29890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29892. return
  29893. }
  29894. var respJSON map[string]interface{}
  29895. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29898. return
  29899. }
  29900. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29901. userJSONBytes, _ := json.Marshal(respJSON)
  29902. fmt.Println("log")
  29903. fmt.Println(string(userJSONBytes))
  29904. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29905. utils.ErrorLog("解析失败:%v", err)
  29906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29907. return
  29908. }
  29909. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  29910. utils.ErrorLog("解析失败:%v", doctor_info)
  29911. data := make(map[string]interface{})
  29912. client := &http.Client{}
  29913. data["psn_no"] = his.PsnNo
  29914. data["mdtrt_id"] = his.Number
  29915. data["doctor"] = roles.UserName
  29916. data["department"] = department.Name
  29917. data["org_name"] = miConfig.OrgName
  29918. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29919. data["doctor_id"] = doctor_info.DoctorNumber
  29920. data["new_doctor_name"] = doctor_info.UserName
  29921. data["fixmedins_code"] = miConfig.Code
  29922. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29923. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29924. data["secret_key"] = miConfig.SecretKey
  29925. data["sick_code"] = sickConfig.CountryCode
  29926. data["sick_name"] = sickConfig.ClassName
  29927. data["url"] = miConfig.Url
  29928. data["ak"] = miConfig.AccessKey
  29929. data["begin_time"] = begin_time
  29930. data["cainfo"] = miConfig.Cainfo
  29931. data["dept"] = strconv.FormatInt(department.ID, 10)
  29932. data["config"] = config
  29933. bytesData, _ := json.Marshal(data)
  29934. var req *http.Request
  29935. if miConfig.MdtrtareaAdmvs == "320830" {
  29936. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  29937. } else if miConfig.MdtrtareaAdmvs == "320921" {
  29938. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29939. } else {
  29940. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29941. }
  29942. resp, _ := client.Do(req)
  29943. defer resp.Body.Close()
  29944. body, ioErr := ioutil.ReadAll(resp.Body)
  29945. if ioErr != nil {
  29946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29948. return
  29949. }
  29950. var respJSON map[string]interface{}
  29951. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29954. return
  29955. }
  29956. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29957. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29958. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29959. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29960. userJSONBytes, _ := json.Marshal(respJSON)
  29961. fmt.Println("log")
  29962. fmt.Println(string(userJSONBytes))
  29963. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29964. utils.ErrorLog("解析失败:%v", err)
  29965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29966. return
  29967. }
  29968. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29969. res2.Output = resSix10265.Output
  29970. res2.ErrMsg = resSix10265.ErrMsg
  29971. res2.Cainfo = resSix10265.Cainfo
  29972. res2.WarnMsg = resSix10265.WarnMsg
  29973. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29974. res2.Infcode = infocode
  29975. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29976. data := make(map[string]interface{})
  29977. client := &http.Client{}
  29978. data["psn_no"] = his.PsnNo
  29979. data["mdtrt_id"] = his.Number
  29980. data["doctor"] = roles.UserName
  29981. data["department"] = department.Name
  29982. data["org_name"] = miConfig.OrgName
  29983. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29984. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  29985. data["fixmedins_code"] = miConfig.Code
  29986. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29987. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29988. data["secret_key"] = miConfig.SecretKey
  29989. data["sick_code"] = sickConfig.CountryCode
  29990. data["sick_name"] = sickConfig.ClassName
  29991. data["begin_time"] = begin_time
  29992. data["dept"] = strconv.FormatInt(department.ID, 10)
  29993. data["config"] = config
  29994. //data["url"] = miConfig.Url
  29995. //data["ak"] = miConfig.AccessKey
  29996. data["cainfo"] = miConfig.Cainfo
  29997. fmt.Println(data)
  29998. bytesData, _ := json.Marshal(data)
  29999. var req *http.Request
  30000. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  30001. resp, _ := client.Do(req)
  30002. defer resp.Body.Close()
  30003. body, ioErr := ioutil.ReadAll(resp.Body)
  30004. if ioErr != nil {
  30005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30007. return
  30008. }
  30009. var respJSON map[string]interface{}
  30010. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30013. return
  30014. }
  30015. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  30016. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  30017. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  30018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30019. userJSONBytes, _ := json.Marshal(respJSON)
  30020. fmt.Println("log")
  30021. fmt.Println(string(userJSONBytes))
  30022. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  30023. utils.ErrorLog("解析失败:%v", err)
  30024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30025. return
  30026. }
  30027. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30028. res2.Output = resSix10265.Output
  30029. res2.ErrMsg = resSix10265.ErrMsg
  30030. res2.Cainfo = resSix10265.Cainfo
  30031. res2.WarnMsg = resSix10265.WarnMsg
  30032. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30033. res2.Infcode = infocode
  30034. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30035. 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)
  30036. saveLog(result, requestLog, "2203", "上传就诊信息")
  30037. var respJSON2 map[string]interface{}
  30038. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30041. return
  30042. }
  30043. userJSONBytes2, _ := json.Marshal(respJSON2)
  30044. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30045. utils.ErrorLog("解析失败:%v", err)
  30046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30047. return
  30048. }
  30049. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30050. var result string
  30051. var requestLog string
  30052. 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, "")
  30053. saveLog(result, requestLog, "2203", "上传就诊信息")
  30054. var respJSON2 map[string]interface{}
  30055. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30058. return
  30059. }
  30060. userJSONBytes2, _ := json.Marshal(respJSON2)
  30061. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30062. utils.ErrorLog("解析失败:%v", err)
  30063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30064. return
  30065. }
  30066. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30067. var result string
  30068. var requestLog string
  30069. 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, "")
  30070. saveLog(result, requestLog, "2203", "上传就诊信息")
  30071. var respJSON2 map[string]interface{}
  30072. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30075. return
  30076. }
  30077. userJSONBytes2, _ := json.Marshal(respJSON2)
  30078. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30079. utils.ErrorLog("解析失败:%v", err)
  30080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30081. return
  30082. }
  30083. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30084. var result string
  30085. var requestLog string
  30086. 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, "")
  30087. saveLog(result, requestLog, "2203", "上传就诊信息")
  30088. var respJSON2 map[string]interface{}
  30089. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30092. return
  30093. }
  30094. userJSONBytes2, _ := json.Marshal(respJSON2)
  30095. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30096. utils.ErrorLog("解析失败:%v", err)
  30097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30098. return
  30099. }
  30100. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30101. data := make(map[string]interface{})
  30102. client := &http.Client{}
  30103. data["psn_no"] = his.PsnNo
  30104. data["mdtrt_id"] = his.Number
  30105. data["operator"] = roles.UserName
  30106. data["department"] = department.Name
  30107. data["org_name"] = miConfig.OrgName
  30108. var med_type string
  30109. if his.Insutype == "390" {
  30110. if reg_type == 992102 {
  30111. med_type = "992102"
  30112. data["sick_code"] = "ZDZ940"
  30113. data["sick_name"] = "慢性肾衰竭"
  30114. }
  30115. if reg_type == 140104 {
  30116. med_type = "140104"
  30117. data["sick_code"] = sickConfig.CountryCode
  30118. data["sick_name"] = sickConfig.ClassName
  30119. }
  30120. if reg_type == 14 {
  30121. med_type = "140104"
  30122. data["sick_code"] = sickConfig.CountryCode
  30123. data["sick_name"] = sickConfig.ClassName
  30124. }
  30125. if reg_type == 1104 {
  30126. med_type = "1104"
  30127. data["sick_code"] = sickConfig.CountryCode
  30128. data["sick_name"] = sickConfig.ClassName
  30129. }
  30130. } else if his.Insutype == "310" {
  30131. if reg_type == 992102 {
  30132. med_type = "992102"
  30133. data["sick_code"] = "ZDZ940"
  30134. data["sick_name"] = "慢性肾衰竭"
  30135. }
  30136. if reg_type == 140104 {
  30137. med_type = "140104"
  30138. data["sick_code"] = sickConfig.CountryCode
  30139. data["sick_name"] = sickConfig.ClassName
  30140. }
  30141. if reg_type == 14 {
  30142. med_type = "14"
  30143. data["sick_code"] = sickConfig.CountryCode
  30144. data["sick_name"] = sickConfig.ClassName
  30145. }
  30146. if reg_type == 1104 {
  30147. med_type = "1104"
  30148. data["sick_code"] = sickConfig.CountryCode
  30149. data["sick_name"] = sickConfig.ClassName
  30150. }
  30151. }
  30152. data["med_type"] = med_type
  30153. data["doctor_number"] = doctor_info.DoctorNumber
  30154. data["doctor_name"] = doctor_info.UserName
  30155. data["fixmedins_code"] = miConfig.Code
  30156. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30157. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30158. data["secret_key"] = miConfig.SecretKey
  30159. data["begin_time"] = begin_time
  30160. data["dept"] = strconv.FormatInt(department.ID, 10)
  30161. data["config"] = config
  30162. data["url"] = miConfig.Url
  30163. data["ak"] = miConfig.AccessKey
  30164. data["cainfo"] = miConfig.Cainfo
  30165. bytesData, _ := json.Marshal(data)
  30166. var req *http.Request
  30167. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30168. resp, _ := client.Do(req)
  30169. defer resp.Body.Close()
  30170. body, ioErr := ioutil.ReadAll(resp.Body)
  30171. if ioErr != nil {
  30172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30174. return
  30175. }
  30176. var respJSON map[string]interface{}
  30177. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30180. return
  30181. }
  30182. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30183. if status == "0" {
  30184. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30185. c.ServeSuccessJSON(map[string]interface{}{
  30186. "failed_code": -10,
  30187. "msg": err_msg,
  30188. })
  30189. return
  30190. }
  30191. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30192. userJSONBytes, _ := json.Marshal(respJSON)
  30193. fmt.Println("log")
  30194. fmt.Println(string(userJSONBytes))
  30195. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30196. utils.ErrorLog("解析失败:%v", err)
  30197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30198. return
  30199. }
  30200. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30201. data := make(map[string]interface{})
  30202. client := &http.Client{}
  30203. data["psn_no"] = his.PsnNo
  30204. data["mdtrt_id"] = his.Number
  30205. data["operator"] = roles.UserName
  30206. data["department"] = department.Name
  30207. data["org_name"] = miConfig.OrgName
  30208. var med_type string
  30209. if his.Insutype == "390" {
  30210. if reg_type == 992102 {
  30211. med_type = "992102"
  30212. data["sick_code"] = sickConfig.CountryCode
  30213. data["sick_name"] = sickConfig.ClassName
  30214. }
  30215. if reg_type == 140104 {
  30216. med_type = "140104"
  30217. data["sick_code"] = sickConfig.CountryCode
  30218. data["sick_name"] = sickConfig.ClassName
  30219. }
  30220. if reg_type == 140201 {
  30221. med_type = "140201"
  30222. data["sick_code"] = sickConfig.CountryCode
  30223. data["sick_name"] = sickConfig.ClassName
  30224. }
  30225. if reg_type == 14 {
  30226. med_type = "14"
  30227. data["sick_code"] = sickConfig.CountryCode
  30228. data["sick_name"] = sickConfig.ClassName
  30229. }
  30230. if reg_type == 11 {
  30231. med_type = "11"
  30232. data["sick_code"] = sickConfig.CountryCode
  30233. data["sick_name"] = sickConfig.ClassName
  30234. }
  30235. } else if his.Insutype == "310" {
  30236. if reg_type == 992102 {
  30237. med_type = "992102"
  30238. data["sick_code"] = sickConfig.CountryCode
  30239. data["sick_name"] = sickConfig.ClassName
  30240. }
  30241. if reg_type == 140104 {
  30242. med_type = "140104"
  30243. data["sick_code"] = sickConfig.CountryCode
  30244. data["sick_name"] = sickConfig.ClassName
  30245. }
  30246. if reg_type == 140201 {
  30247. med_type = "140201"
  30248. data["sick_code"] = sickConfig.CountryCode
  30249. data["sick_name"] = sickConfig.ClassName
  30250. }
  30251. if reg_type == 14 {
  30252. med_type = "14"
  30253. data["sick_code"] = sickConfig.CountryCode
  30254. data["sick_name"] = sickConfig.ClassName
  30255. }
  30256. if reg_type == 11 {
  30257. med_type = "11"
  30258. data["sick_code"] = sickConfig.CountryCode
  30259. data["sick_name"] = sickConfig.ClassName
  30260. }
  30261. }
  30262. data["med_type"] = med_type
  30263. data["doctor_number"] = doctor_info.DoctorNumber
  30264. data["doctor_name"] = doctor_info.UserName
  30265. data["fixmedins_code"] = miConfig.Code
  30266. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30267. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30268. data["secret_key"] = miConfig.SecretKey
  30269. data["begin_time"] = begin_time
  30270. data["dept"] = strconv.FormatInt(department.ID, 10)
  30271. data["config"] = config
  30272. data["url"] = miConfig.Url
  30273. data["ak"] = miConfig.AccessKey
  30274. data["cainfo"] = miConfig.Cainfo
  30275. bytesData, _ := json.Marshal(data)
  30276. var req *http.Request
  30277. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30278. resp, _ := client.Do(req)
  30279. defer resp.Body.Close()
  30280. body, ioErr := ioutil.ReadAll(resp.Body)
  30281. if ioErr != nil {
  30282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30284. return
  30285. }
  30286. var respJSON map[string]interface{}
  30287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30290. return
  30291. }
  30292. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30293. if status == "0" {
  30294. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30295. c.ServeSuccessJSON(map[string]interface{}{
  30296. "failed_code": -10,
  30297. "msg": err_msg,
  30298. })
  30299. return
  30300. }
  30301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30302. userJSONBytes, _ := json.Marshal(respJSON)
  30303. fmt.Println("log")
  30304. fmt.Println(string(userJSONBytes))
  30305. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30306. utils.ErrorLog("解析失败:%v", err)
  30307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30308. return
  30309. }
  30310. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30311. var result string
  30312. var requestLog string
  30313. 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, "", begin_time)
  30314. saveLog(result, requestLog, "2203", "上传就诊信息")
  30315. var respJSON2 map[string]interface{}
  30316. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30319. return
  30320. }
  30321. userJSONBytes2, _ := json.Marshal(respJSON2)
  30322. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30323. utils.ErrorLog("解析失败:%v", err)
  30324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30325. return
  30326. }
  30327. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30328. data := make(map[string]interface{})
  30329. client := &http.Client{}
  30330. data["psn_no"] = his.PsnNo
  30331. data["mdtrt_id"] = his.Number
  30332. data["doctor"] = roles.UserName
  30333. data["department"] = department.Name
  30334. data["org_name"] = miConfig.OrgName
  30335. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30336. data["doctor_id"] = doctor_info.DoctorNumber
  30337. data["fixmedins_code"] = miConfig.Code
  30338. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30339. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30340. data["secret_key"] = miConfig.SecretKey
  30341. data["sick_code"] = sickConfig.CountryCode
  30342. data["sick_name"] = sickConfig.ClassName
  30343. data["begin_time"] = begin_time
  30344. data["new_doctor_name"] = doctor_info.UserName
  30345. data["dept"] = strconv.FormatInt(department.ID, 10)
  30346. data["config"] = config
  30347. bytesData, _ := json.Marshal(data)
  30348. var req *http.Request
  30349. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  30350. resp, _ := client.Do(req)
  30351. defer resp.Body.Close()
  30352. body, ioErr := ioutil.ReadAll(resp.Body)
  30353. if ioErr != nil {
  30354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30356. return
  30357. }
  30358. var respJSON map[string]interface{}
  30359. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30362. return
  30363. }
  30364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30365. userJSONBytes, _ := json.Marshal(respJSON)
  30366. fmt.Println("log")
  30367. fmt.Println(string(userJSONBytes))
  30368. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30369. utils.ErrorLog("解析失败:%v", err)
  30370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30371. return
  30372. }
  30373. } else {
  30374. var result string
  30375. var requestLog string
  30376. if miConfig.MdtrtareaAdmvs == "440781" { //
  30377. 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)
  30378. } else {
  30379. if miConfig.Code == "H15049901371" {
  30380. //赤峰地区国家医保医疗类别
  30381. //职工透析:医疗类别选特殊情况门诊990502
  30382. //居民定额血透门慢: 医疗类别选门诊慢病140104
  30383. var med_type string
  30384. if his.Insutype == "390" {
  30385. if reg_type == 14 {
  30386. med_type = "9933"
  30387. } else if reg_type == 11 {
  30388. med_type = "11"
  30389. }
  30390. } else if his.Insutype == "310" {
  30391. if reg_type == 14 {
  30392. med_type = "990502"
  30393. } else if reg_type == 11 {
  30394. med_type = "11"
  30395. }
  30396. }
  30397. 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)
  30398. } else {
  30399. 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)
  30400. }
  30401. saveLog(result, requestLog, "2203", "上传就诊信息")
  30402. var respJSON2 map[string]interface{}
  30403. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30406. return
  30407. }
  30408. userJSONBytes2, _ := json.Marshal(respJSON2)
  30409. if miConfig.Code == "H15049901371" {
  30410. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  30411. utils.ErrorLog("解析失败:%v", err)
  30412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30413. return
  30414. }
  30415. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30416. res2.Output = resSix10265.Output
  30417. res2.ErrMsg = resSix10265.ErrMsg
  30418. res2.Cainfo = resSix10265.Cainfo
  30419. res2.WarnMsg = resSix10265.WarnMsg
  30420. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30421. res2.Infcode = infocode
  30422. } else {
  30423. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30424. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  30425. utils.ErrorLog("解析失败:%v", err)
  30426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30427. return
  30428. }
  30429. res2.Infcode = res3.Infcode
  30430. } else {
  30431. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30432. utils.ErrorLog("解析失败:%v", err)
  30433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30434. return
  30435. }
  30436. }
  30437. }
  30438. }
  30439. }
  30440. if res2.Infcode == -1 {
  30441. adminUser := c.GetAdminUserInfo()
  30442. errlog := &models.HisOrderError{
  30443. UserOrgId: adminUser.CurrentOrgId,
  30444. Ctime: time.Now().Unix(),
  30445. Mtime: time.Now().Unix(),
  30446. ErrMsg: res2.ErrMsg,
  30447. Status: 1,
  30448. PatientId: id,
  30449. RecordTime: recordDateTime,
  30450. Stage: 3,
  30451. }
  30452. service.CreateErrMsgLog(errlog)
  30453. c.ServeSuccessJSON(map[string]interface{}{
  30454. "failed_code": -10,
  30455. "msg": res2.ErrMsg,
  30456. })
  30457. return
  30458. }
  30459. if res2.Infcode != 0 {
  30460. adminUser := c.GetAdminUserInfo()
  30461. errlog := &models.HisOrderError{
  30462. UserOrgId: adminUser.CurrentOrgId,
  30463. Ctime: time.Now().Unix(),
  30464. Mtime: time.Now().Unix(),
  30465. ErrMsg: res2.ErrMsg,
  30466. Status: 1,
  30467. PatientId: id,
  30468. RecordTime: recordDateTime,
  30469. Stage: 3,
  30470. }
  30471. service.CreateErrMsgLog(errlog)
  30472. c.ServeSuccessJSON(map[string]interface{}{
  30473. "failed_code": -10,
  30474. "msg": res2.ErrMsg,
  30475. })
  30476. return
  30477. } else {
  30478. his.Diagnosis = diagnosis_id
  30479. his.SickType = sickConfig.ID
  30480. his.PType = fmt.Sprintf("%d", reg_type)
  30481. service.UpdateHisPatientThree(&his)
  30482. data := make(map[string]interface{})
  30483. if settle_accounts_type == 1 { //日结
  30484. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  30485. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  30486. } else {
  30487. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  30488. }
  30489. data["pre"] = prescriptions
  30490. } else { //月结
  30491. start_time_str := c.GetString("start_time")
  30492. end_time_str := c.GetString("end_time")
  30493. timeLayout := "2006-01-02"
  30494. loc, _ := time.LoadLocation("Local")
  30495. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  30496. if err != nil {
  30497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30498. return
  30499. }
  30500. recordStartTime := theStartTime.Unix()
  30501. start_time = recordStartTime
  30502. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  30503. if err != nil {
  30504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30505. return
  30506. }
  30507. recordEndTime := theEndTime.Unix()
  30508. end_time = recordEndTime
  30509. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  30510. data["pre"] = prescriptions
  30511. }
  30512. client := &http.Client{}
  30513. data["psn_no"] = his.PsnNo
  30514. data["mdtrt_id"] = his.Number
  30515. data["chrg_bchno"] = new_chrg_bchno
  30516. data["org_name"] = miConfig.OrgName
  30517. data["doctor"] = doctor_info.UserName
  30518. data["doctor_id"] = doctor_info.DoctorNumber
  30519. data["dept"] = department.Name
  30520. data["fixmedins_code"] = miConfig.Code
  30521. data["opter"] = roles.UserName
  30522. data["dept_code"] = department.Number
  30523. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30524. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30525. data["secret_key"] = miConfig.SecretKey
  30526. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  30527. data["url"] = miConfig.Url
  30528. data["ak"] = miConfig.AccessKey
  30529. data["new_doctor_name"] = patientPrescription.Doctor
  30530. if his.Insutype == "390" {
  30531. if reg_type == 992102 {
  30532. data["diag_code"] = "ZDZ940"
  30533. }
  30534. if reg_type == 140104 {
  30535. data["diag_code"] = sickConfig.CountryCode
  30536. }
  30537. if reg_type == 140201 {
  30538. data["diag_code"] = sickConfig.CountryCode
  30539. }
  30540. if reg_type == 14 {
  30541. data["diag_code"] = sickConfig.CountryCode
  30542. }
  30543. if reg_type == 1104 {
  30544. data["diag_code"] = sickConfig.CountryCode
  30545. }
  30546. } else if his.Insutype == "310" {
  30547. if miConfig.MdtrtareaAdmvs == "341203" {
  30548. if reg_type == 992102 {
  30549. data["diag_code"] = "ZDZ940"
  30550. }
  30551. if reg_type != 992102 {
  30552. data["diag_code"] = sickConfig.CountryCode
  30553. }
  30554. } else {
  30555. data["diag_code"] = sickConfig.CountryCode
  30556. }
  30557. }
  30558. data["cainfo"] = miConfig.Cainfo
  30559. data["opter"] = roles.UserName
  30560. var ids []int64
  30561. for _, item := range prescriptions {
  30562. ids = append(ids, item.ID)
  30563. }
  30564. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30565. if config.IsOpen == 1 { //对接了医保,走医保流程
  30566. var res ResultFour
  30567. var resFour10265 ResultFour10265
  30568. if miConfig.MdtrtareaAdmvs == "421300" {
  30569. bytesData, _ := json.Marshal(data)
  30570. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30571. resp, _ := client.Do(req)
  30572. defer resp.Body.Close()
  30573. body, ioErr := ioutil.ReadAll(resp.Body)
  30574. if ioErr != nil {
  30575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30577. return
  30578. }
  30579. var respJSON map[string]interface{}
  30580. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30583. return
  30584. }
  30585. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30586. userJSONBytes, _ := json.Marshal(respJSON)
  30587. fmt.Println("log")
  30588. fmt.Println(string(userJSONBytes))
  30589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30590. utils.ErrorLog("解析失败:%v", err)
  30591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30592. return
  30593. }
  30594. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30595. bytesData, _ := json.Marshal(data)
  30596. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30597. resp, _ := client.Do(req)
  30598. defer resp.Body.Close()
  30599. body, ioErr := ioutil.ReadAll(resp.Body)
  30600. if ioErr != nil {
  30601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30603. return
  30604. }
  30605. var respJSON map[string]interface{}
  30606. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30609. return
  30610. }
  30611. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30612. userJSONBytes, _ := json.Marshal(respJSON)
  30613. fmt.Println("log")
  30614. fmt.Println(string(userJSONBytes))
  30615. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30616. utils.ErrorLog("解析失败:%v", err)
  30617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30618. return
  30619. }
  30620. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30621. bytesData, _ := json.Marshal(data)
  30622. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30623. resp, _ := client.Do(req)
  30624. defer resp.Body.Close()
  30625. body, ioErr := ioutil.ReadAll(resp.Body)
  30626. if ioErr != nil {
  30627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30629. return
  30630. }
  30631. var respJSON map[string]interface{}
  30632. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30635. return
  30636. }
  30637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30638. userJSONBytes, _ := json.Marshal(respJSON)
  30639. fmt.Println("log")
  30640. fmt.Println(string(userJSONBytes))
  30641. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30642. utils.ErrorLog("解析失败:%v", err)
  30643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30644. return
  30645. }
  30646. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30647. bytesData, _ := json.Marshal(data)
  30648. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30649. resp, _ := client.Do(req)
  30650. defer resp.Body.Close()
  30651. body, ioErr := ioutil.ReadAll(resp.Body)
  30652. if ioErr != nil {
  30653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30655. return
  30656. }
  30657. var respJSON map[string]interface{}
  30658. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30661. return
  30662. }
  30663. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30664. userJSONBytes, _ := json.Marshal(respJSON)
  30665. fmt.Println("log")
  30666. fmt.Println(string(userJSONBytes))
  30667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30668. utils.ErrorLog("解析失败:%v", err)
  30669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30670. return
  30671. }
  30672. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  30673. var result3101 Result3101
  30674. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30675. result3101.Infcode = "0"
  30676. if result3101.Infcode == "0" {
  30677. if len(result3101.Output.Result) > 0 {
  30678. var errMsgs []string
  30679. for _, item := range result3101.Output.Result {
  30680. errMsgs = append(errMsgs, item.VolaCont)
  30681. }
  30682. c.ServeSuccessJSON(map[string]interface{}{
  30683. "failed_code": -10,
  30684. "msg": errMsgs,
  30685. })
  30686. return
  30687. } else {
  30688. if miConfig.MdtrtareaAdmvs == "320921" {
  30689. data["doctor_id"] = doctor_info.DoctorNumber
  30690. } else {
  30691. data["doctor_id"] = doctor_info.DoctorNumber
  30692. }
  30693. bytesData, _ := json.Marshal(data)
  30694. var req *http.Request
  30695. if miConfig.MdtrtareaAdmvs == "320830" {
  30696. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  30697. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30698. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30699. } else {
  30700. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30701. }
  30702. resp, _ := client.Do(req)
  30703. defer resp.Body.Close()
  30704. body, ioErr := ioutil.ReadAll(resp.Body)
  30705. if ioErr != nil {
  30706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30708. return
  30709. }
  30710. var respJSON map[string]interface{}
  30711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30714. return
  30715. }
  30716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30717. userJSONBytes, _ := json.Marshal(respJSON)
  30718. fmt.Println("log")
  30719. fmt.Println(string(userJSONBytes))
  30720. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30721. utils.ErrorLog("解析失败:%v", err)
  30722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30723. return
  30724. }
  30725. res.InfRefmsgid = resFour10265.InfRefmsgid
  30726. res.Output = resFour10265.Output
  30727. res.ErrMsg = resFour10265.ErrMsg
  30728. res.Cainfo = resFour10265.Cainfo
  30729. res.WarnMsg = resFour10265.WarnMsg
  30730. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30731. res.Infcode = infocode
  30732. }
  30733. }
  30734. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30735. var pagesize int = 5
  30736. var start int = 1
  30737. var stop int
  30738. var pagecount int
  30739. var curpage int
  30740. data["doctor_id"] = doctor_info.DoctorNumber
  30741. var res2 ResultFour
  30742. //var result res.
  30743. //总页数,向上取整,注意除之前要先转换类型为float64
  30744. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  30745. for curpage = 1; curpage <= pagecount; curpage++ {
  30746. if curpage == 1 {
  30747. start = 1
  30748. } else {
  30749. start = (curpage-1)*pagesize + 1
  30750. }
  30751. stop = curpage * pagesize
  30752. if stop > len(prescriptions) {
  30753. stop = len(prescriptions)
  30754. }
  30755. //var requestLog string
  30756. data["pre"] = prescriptions[start-1 : stop]
  30757. fmt.Println(data["pre"])
  30758. bytesData, _ := json.Marshal(data)
  30759. var req *http.Request
  30760. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  30761. resp, _ := client.Do(req)
  30762. defer resp.Body.Close()
  30763. body, ioErr := ioutil.ReadAll(resp.Body)
  30764. if ioErr != nil {
  30765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30767. return
  30768. }
  30769. var respJSON map[string]interface{}
  30770. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30773. return
  30774. }
  30775. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30776. userJSONBytes, _ := json.Marshal(respJSON)
  30777. fmt.Println("log")
  30778. fmt.Println(string(userJSONBytes))
  30779. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30780. utils.ErrorLog("解析失败:%v", err)
  30781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30782. return
  30783. }
  30784. res.InfRefmsgid = resFour10265.InfRefmsgid
  30785. res.Output = resFour10265.Output
  30786. res.ErrMsg = resFour10265.ErrMsg
  30787. res.Cainfo = resFour10265.Cainfo
  30788. res.WarnMsg = resFour10265.WarnMsg
  30789. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30790. res.Infcode = infocode
  30791. if infocode == 0 {
  30792. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  30793. } else {
  30794. isSuccess = false
  30795. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  30796. res.Infcode = -1
  30797. res.ErrMsg = resFour10265.ErrMsg
  30798. errlog := &models.HisOrderError{
  30799. UserOrgId: adminUser.CurrentOrgId,
  30800. Ctime: time.Now().Unix(),
  30801. Mtime: time.Now().Unix(),
  30802. Number: chrg_bchno,
  30803. ErrMsg: "",
  30804. Status: 1,
  30805. PatientId: id,
  30806. RecordTime: recordDateTime,
  30807. Stage: 4,
  30808. }
  30809. service.CreateErrMsgLog(errlog)
  30810. }
  30811. }
  30812. if isSuccess {
  30813. res.Infcode = 0
  30814. res.Output.Result = res2.Output.Result
  30815. } else {
  30816. order := &models.HisOrder{
  30817. UserOrgId: adminUser.CurrentOrgId,
  30818. HisPatientId: his.ID,
  30819. PatientId: his.PatientId,
  30820. SettleAccountsDate: recordDateTime,
  30821. Ctime: time.Now().Unix(),
  30822. Mtime: time.Now().Unix(),
  30823. MdtrtId: his.Number,
  30824. PsnNo: his.PsnNo,
  30825. MedType: strconv.FormatInt(reg_type, 10),
  30826. Status: 1,
  30827. Number: chrg_bchno,
  30828. Infcode: res.Infcode,
  30829. WarnMsg: res.WarnMsg,
  30830. Cainfo: res.Cainfo,
  30831. ErrMsg: res.ErrMsg,
  30832. RespondTime: res.RefmsgTime,
  30833. InfRefmsgid: res.InfRefmsgid,
  30834. OrderStatus: 1,
  30835. IsMedicineInsurance: 1,
  30836. SettleType: settle_accounts_type,
  30837. SettleStartTime: start_time,
  30838. SettleEndTime: end_time,
  30839. Creator: roles.AdminUserId,
  30840. Modify: roles.AdminUserId,
  30841. PType: 2,
  30842. Diagnosis: diagnosis_id,
  30843. }
  30844. err = service.CreateOrder(order)
  30845. if err != nil {
  30846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30847. return
  30848. }
  30849. c.ServeSuccessJSON(map[string]interface{}{
  30850. "failed_code": -10,
  30851. "msg": res2.ErrMsg,
  30852. })
  30853. return
  30854. }
  30855. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30856. 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)
  30857. var dat map[string]interface{}
  30858. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30859. fmt.Println(dat)
  30860. } else {
  30861. fmt.Println(err)
  30862. }
  30863. saveLog(result, request_log, "2204", "上传费用明细")
  30864. userJSONBytes, _ := json.Marshal(dat)
  30865. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30866. utils.ErrorLog("解析失败:%v", err)
  30867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30868. return
  30869. }
  30870. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30871. 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, "", "")
  30872. var dat map[string]interface{}
  30873. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30874. fmt.Println(dat)
  30875. } else {
  30876. fmt.Println(err)
  30877. }
  30878. saveLog(result, request_log, "2204", "上传费用明细")
  30879. userJSONBytes, _ := json.Marshal(dat)
  30880. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30881. utils.ErrorLog("解析失败:%v", err)
  30882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30883. return
  30884. }
  30885. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30886. 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, "", "")
  30887. var dat map[string]interface{}
  30888. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30889. fmt.Println(dat)
  30890. } else {
  30891. fmt.Println(err)
  30892. }
  30893. saveLog(result, request_log, "2204", "上传费用明细")
  30894. userJSONBytes, _ := json.Marshal(dat)
  30895. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30896. utils.ErrorLog("解析失败:%v", err)
  30897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30898. return
  30899. }
  30900. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30901. 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, "", "")
  30902. var dat map[string]interface{}
  30903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30904. fmt.Println(dat)
  30905. } else {
  30906. fmt.Println(err)
  30907. }
  30908. saveLog(result, request_log, "2204", "上传费用明细")
  30909. userJSONBytes, _ := json.Marshal(dat)
  30910. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30911. utils.ErrorLog("解析失败:%v", err)
  30912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30913. return
  30914. }
  30915. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30916. bytesData, _ := json.Marshal(data)
  30917. var req *http.Request
  30918. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30919. resp, _ := client.Do(req)
  30920. defer resp.Body.Close()
  30921. body, ioErr := ioutil.ReadAll(resp.Body)
  30922. if ioErr != nil {
  30923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30925. return
  30926. }
  30927. var respJSON map[string]interface{}
  30928. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30931. return
  30932. }
  30933. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30934. if status == "0" {
  30935. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30936. c.ServeSuccessJSON(map[string]interface{}{
  30937. "failed_code": -10,
  30938. "msg": err_msg,
  30939. })
  30940. return
  30941. }
  30942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30943. userJSONBytes, _ := json.Marshal(respJSON)
  30944. fmt.Println("log")
  30945. fmt.Println(string(userJSONBytes))
  30946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30947. utils.ErrorLog("解析失败:%v", err)
  30948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30949. return
  30950. }
  30951. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30952. bytesData, _ := json.Marshal(data)
  30953. var req *http.Request
  30954. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30955. resp, _ := client.Do(req)
  30956. defer resp.Body.Close()
  30957. body, ioErr := ioutil.ReadAll(resp.Body)
  30958. if ioErr != nil {
  30959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30961. return
  30962. }
  30963. var respJSON map[string]interface{}
  30964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30967. return
  30968. }
  30969. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30970. if status == "0" {
  30971. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30972. c.ServeSuccessJSON(map[string]interface{}{
  30973. "failed_code": -10,
  30974. "msg": err_msg,
  30975. })
  30976. return
  30977. }
  30978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30979. userJSONBytes, _ := json.Marshal(respJSON)
  30980. fmt.Println("log")
  30981. fmt.Println(string(userJSONBytes))
  30982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30983. utils.ErrorLog("解析失败:%v", err)
  30984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30985. return
  30986. }
  30987. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30988. 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, "", "")
  30989. var dat map[string]interface{}
  30990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30991. fmt.Println(dat)
  30992. } else {
  30993. fmt.Println(err)
  30994. }
  30995. saveLog(result, request_log, "2204", "上传费用明细")
  30996. userJSONBytes, _ := json.Marshal(dat)
  30997. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30998. utils.ErrorLog("解析失败:%v", err)
  30999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31000. return
  31001. }
  31002. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31003. bytesData, _ := json.Marshal(data)
  31004. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  31005. resp, _ := client.Do(req)
  31006. defer resp.Body.Close()
  31007. body, ioErr := ioutil.ReadAll(resp.Body)
  31008. if ioErr != nil {
  31009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31011. return
  31012. }
  31013. var respJSON map[string]interface{}
  31014. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31017. return
  31018. }
  31019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31020. userJSONBytes, _ := json.Marshal(respJSON)
  31021. fmt.Println("log")
  31022. fmt.Println(string(userJSONBytes))
  31023. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31024. utils.ErrorLog("解析失败:%v", err)
  31025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31026. return
  31027. }
  31028. } else {
  31029. if miConfig.MdtrtareaAdmvs == "441202" {
  31030. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31031. if result3101.Infcode == 0 {
  31032. if len(result3101.Output.Result) > 0 {
  31033. var errMsgs []string
  31034. for _, item := range result3101.Output.Result {
  31035. errMsgs = append(errMsgs, item.VolaCont)
  31036. }
  31037. c.ServeSuccessJSON(map[string]interface{}{
  31038. "failed_code": -10,
  31039. "msg": errMsgs,
  31040. })
  31041. return
  31042. } else {
  31043. 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)
  31044. var dat map[string]interface{}
  31045. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31046. fmt.Println(dat)
  31047. } else {
  31048. fmt.Println(err)
  31049. }
  31050. saveLog(result, request_log, "2204", "上传费用明细")
  31051. userJSONBytes, _ := json.Marshal(dat)
  31052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31053. utils.ErrorLog("解析失败:%v", err)
  31054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31055. return
  31056. }
  31057. }
  31058. } else {
  31059. c.ServeSuccessJSON(map[string]interface{}{
  31060. "failed_code": -10,
  31061. "msg": result3101.ErrMsg,
  31062. })
  31063. return
  31064. }
  31065. } else if miConfig.MdtrtareaAdmvs == "440205" {
  31066. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31067. if result3101.Infcode == 0 {
  31068. if len(result3101.Output.Result) > 0 {
  31069. var errMsgs []string
  31070. for _, item := range result3101.Output.Result {
  31071. errMsgs = append(errMsgs, item.VolaCont)
  31072. }
  31073. c.ServeSuccessJSON(map[string]interface{}{
  31074. "failed_code": -10,
  31075. "msg": errMsgs,
  31076. })
  31077. return
  31078. } else {
  31079. 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)
  31080. var dat map[string]interface{}
  31081. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31082. fmt.Println(dat)
  31083. } else {
  31084. fmt.Println(err)
  31085. }
  31086. saveLog(result, request_log, "2204", "上传费用明细")
  31087. userJSONBytes, _ := json.Marshal(dat)
  31088. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31089. utils.ErrorLog("解析失败:%v", err)
  31090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31091. return
  31092. }
  31093. }
  31094. } else {
  31095. c.ServeSuccessJSON(map[string]interface{}{
  31096. "failed_code": -10,
  31097. "msg": result3101.ErrMsg,
  31098. })
  31099. return
  31100. }
  31101. } else {
  31102. if miConfig.Code == "H15049901371" {
  31103. 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)
  31104. var dat map[string]interface{}
  31105. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31106. fmt.Println(dat)
  31107. } else {
  31108. fmt.Println(err)
  31109. }
  31110. saveLog(result, request_log, "2204", "上传费用明细")
  31111. userJSONBytes, _ := json.Marshal(dat)
  31112. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  31113. utils.ErrorLog("解析失败:%v", err)
  31114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31115. return
  31116. }
  31117. res.InfRefmsgid = resFour10265.InfRefmsgid
  31118. res.Output = resFour10265.Output
  31119. res.ErrMsg = resFour10265.ErrMsg
  31120. res.Cainfo = resFour10265.Cainfo
  31121. res.WarnMsg = resFour10265.WarnMsg
  31122. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  31123. res.Infcode = infocode
  31124. } else {
  31125. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  31126. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31127. if result3101.Infcode == 0 {
  31128. if len(result3101.Output.Result) > 0 {
  31129. c.ServeSuccessJSON(map[string]interface{}{
  31130. "failed_code": -10,
  31131. "failed_type": 100,
  31132. "warm_type": 1,
  31133. "msg": result3101,
  31134. })
  31135. return
  31136. } else {
  31137. 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)
  31138. var dat map[string]interface{}
  31139. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31140. fmt.Println(dat)
  31141. } else {
  31142. fmt.Println(err)
  31143. }
  31144. saveLog(result, request_log, "2204", "上传费用明细")
  31145. userJSONBytes, _ := json.Marshal(dat)
  31146. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31147. utils.ErrorLog("解析失败:%v", err)
  31148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31149. return
  31150. }
  31151. }
  31152. } else {
  31153. c.ServeSuccessJSON(map[string]interface{}{
  31154. "failed_code": -10,
  31155. "msg": result3101.ErrMsg,
  31156. })
  31157. return
  31158. }
  31159. } else {
  31160. 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)
  31161. var dat map[string]interface{}
  31162. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31163. fmt.Println(dat)
  31164. } else {
  31165. fmt.Println(err)
  31166. }
  31167. saveLog(result, request_log, "2204", "上传费用明细")
  31168. userJSONBytes, _ := json.Marshal(dat)
  31169. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31170. utils.ErrorLog("解析失败:%v", err)
  31171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31172. return
  31173. }
  31174. }
  31175. }
  31176. }
  31177. }
  31178. var total_two float64
  31179. if res.Infcode == -1 {
  31180. errlog := &models.HisOrderError{
  31181. UserOrgId: adminUser.CurrentOrgId,
  31182. Ctime: time.Now().Unix(),
  31183. Mtime: time.Now().Unix(),
  31184. Number: chrg_bchno,
  31185. ErrMsg: res.ErrMsg,
  31186. Status: 1,
  31187. PatientId: id,
  31188. RecordTime: recordDateTime,
  31189. Stage: 4,
  31190. }
  31191. service.CreateErrMsgLog(errlog)
  31192. c.ServeSuccessJSON(map[string]interface{}{
  31193. "failed_code": -10,
  31194. "msg": res.ErrMsg,
  31195. })
  31196. return
  31197. }
  31198. if res.Infcode == 0 {
  31199. order := &models.HisOrder{
  31200. UserOrgId: adminUser.CurrentOrgId,
  31201. HisPatientId: his.ID,
  31202. PatientId: his.PatientId,
  31203. SettleAccountsDate: recordDateTime,
  31204. Ctime: time.Now().Unix(),
  31205. Mtime: time.Now().Unix(),
  31206. MdtrtId: his.Number,
  31207. PsnNo: his.PsnNo,
  31208. MedType: strconv.FormatInt(reg_type, 10),
  31209. Status: 1,
  31210. Number: chrg_bchno,
  31211. Infcode: res.Infcode,
  31212. WarnMsg: res.WarnMsg,
  31213. Cainfo: res.Cainfo,
  31214. ErrMsg: res.ErrMsg,
  31215. RespondTime: res.RefmsgTime,
  31216. InfRefmsgid: res.InfRefmsgid,
  31217. OrderStatus: 1,
  31218. IsMedicineInsurance: 1,
  31219. SettleType: settle_accounts_type,
  31220. SettleStartTime: start_time,
  31221. SettleEndTime: end_time,
  31222. Creator: roles.AdminUserId,
  31223. Modify: roles.AdminUserId,
  31224. PType: 2,
  31225. Diagnosis: diagnosis_id,
  31226. }
  31227. err = service.CreateOrder(order)
  31228. if err != nil {
  31229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31230. return
  31231. }
  31232. for _, item := range res.Output.Result {
  31233. temp := strings.Split(item.FeedetlSn, "-")
  31234. var advice_id int64 = 0
  31235. var project_id int64 = 0
  31236. var types int64 = 0
  31237. id, _ := strconv.ParseInt(temp[2], 10, 64)
  31238. types, _ = strconv.ParseInt(temp[1], 10, 64)
  31239. if temp[1] == "1" {
  31240. advice_id = id
  31241. project_id = 0
  31242. } else if temp[1] == "2" {
  31243. advice_id = 0
  31244. project_id = id
  31245. }
  31246. total_two = total_two + item.DetItemFeeSumamt
  31247. info := &models.HisOrderInfo{
  31248. OrderNumber: order.Number,
  31249. FeedetlSn: item.FeedetlSn,
  31250. UploadDate: time.Now().Unix(),
  31251. AdviceId: advice_id,
  31252. DetItemFeeSumamt: item.DetItemFeeSumamt,
  31253. Cnt: item.Cnt,
  31254. Pric: float64(item.Pric),
  31255. PatientId: his.PatientId,
  31256. PricUplmtAmt: item.PricUplmtAmt,
  31257. SelfpayProp: item.SelfpayProp,
  31258. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  31259. OverlmtAmt: item.OverlmtAmt,
  31260. PreselfpayAmt: item.PreselfpayAmt,
  31261. BasMednFlag: item.BasMednFlag,
  31262. MedChrgitmType: item.MedChrgitmType,
  31263. HiNegoDrugFlag: item.HiNegoDrugFlag,
  31264. Status: 1,
  31265. Memo: item.Memo,
  31266. Mtime: time.Now().Unix(),
  31267. InscpScpAmt: item.InscpScpAmt,
  31268. DrtReimFlag: item.DrtReimFlag,
  31269. Ctime: time.Now().Unix(),
  31270. ListSpItemFlag: item.ListSpItemFlag,
  31271. ChldMedcFlag: item.ChldMedcFlag,
  31272. LmtUsedFlag: item.LmtUsedFlag,
  31273. ChrgitmLv: item.ChrgitmLv,
  31274. UserOrgId: adminUser.CurrentOrgId,
  31275. HisPatientId: his.ID,
  31276. OrderId: order.ID,
  31277. ProjectId: project_id,
  31278. Type: types,
  31279. }
  31280. service.CreateOrderInfo(info)
  31281. }
  31282. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  31283. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  31284. var total float64
  31285. for _, item := range prescriptions {
  31286. if item.Type == 1 { //药品
  31287. for _, subItem := range item.HisDoctorAdviceInfo {
  31288. price, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", subItem.Price), 64)
  31289. total_one := price * subItem.PrescribingNumber
  31290. fmt.Println("subItem")
  31291. fmt.Println(subItem.Price)
  31292. fmt.Println("price")
  31293. fmt.Println(price)
  31294. fmt.Println("total_one")
  31295. fmt.Println(total_one)
  31296. total = total + total_one
  31297. fmt.Println(total)
  31298. }
  31299. }
  31300. if item.Type == 2 { //项目
  31301. for _, subItem := range item.HisPrescriptionProject {
  31302. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  31303. price, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", subItem.Price), 64)
  31304. total_one := price * cnt
  31305. total = total + total_one
  31306. }
  31307. }
  31308. }
  31309. allTotal := fmt.Sprintf("%.2f", total)
  31310. if res.Infcode == 0 {
  31311. var rf []*ResultFive
  31312. json.Unmarshal([]byte(his.Iinfo), &rf)
  31313. chrg_bchno := chrg_bchno
  31314. cert_no := his.Certno
  31315. var insutypes []string
  31316. var insutype string
  31317. var is390 int = 0
  31318. var is310 int = 0
  31319. for _, item := range rf {
  31320. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  31321. insutypes = append(insutypes, item.Insutype)
  31322. }
  31323. }
  31324. if len(insutypes) == 1 {
  31325. insutype = insutypes[0]
  31326. } else {
  31327. for _, i := range insutypes {
  31328. if i == "390" {
  31329. is390 = 1
  31330. }
  31331. if i == "310" {
  31332. is310 = 1
  31333. }
  31334. }
  31335. }
  31336. if is390 == 1 {
  31337. insutype = "390"
  31338. }
  31339. if is310 == 1 {
  31340. insutype = "310"
  31341. }
  31342. if len(insutypes) == 0 {
  31343. insutype = "390"
  31344. }
  31345. if len(insutypes) == 2 {
  31346. insutype = strconv.FormatInt(his.SocialType, 10)
  31347. }
  31348. //insutype = "390"
  31349. if his.IdCardType == 1 {
  31350. cert_no = his.MedicalInsuranceNumber
  31351. } else {
  31352. cert_no = his.Certno
  31353. }
  31354. var res ResultSeven
  31355. var ahres ResultSevenAH
  31356. var resSeven10265 ResultSeven10265
  31357. var resSeven10265Two ResultSeven10265Two
  31358. var resSeven10633Three ResultSeven10633Three
  31359. var gzresSeven10265Two GZResultSeven10265Two
  31360. if miConfig.MdtrtareaAdmvs == "421300" {
  31361. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  31362. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31363. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31364. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31365. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31366. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31367. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31368. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31369. resp, requestErr := http.Get(api)
  31370. if requestErr != nil {
  31371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31372. return
  31373. }
  31374. body, ioErr := ioutil.ReadAll(resp.Body)
  31375. if ioErr != nil {
  31376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31378. return
  31379. }
  31380. var respJSON map[string]interface{}
  31381. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31384. return
  31385. }
  31386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31387. result, _ := json.Marshal(respJSON)
  31388. fmt.Println("log")
  31389. fmt.Println(string(result))
  31390. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31391. utils.ErrorLog("解析失败:%v", err)
  31392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31393. return
  31394. }
  31395. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31396. if reg_type == 11 && his.Insutype == "390" {
  31397. reg_type = 110104
  31398. }
  31399. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31400. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31401. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31402. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31403. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31404. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31405. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31406. resp, requestErr := http.Get(api)
  31407. if requestErr != nil {
  31408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31409. return
  31410. }
  31411. body, ioErr := ioutil.ReadAll(resp.Body)
  31412. if ioErr != nil {
  31413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31415. return
  31416. }
  31417. var respJSON map[string]interface{}
  31418. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31421. return
  31422. }
  31423. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31424. result, _ := json.Marshal(respJSON)
  31425. fmt.Println("log")
  31426. fmt.Println(string(result))
  31427. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31428. utils.ErrorLog("解析失败:%v", err)
  31429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31430. return
  31431. }
  31432. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31433. if reg_type == 11 && his.Insutype == "390" {
  31434. reg_type = 110104
  31435. }
  31436. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31437. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31438. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31439. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31440. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31441. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31442. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31443. resp, requestErr := http.Get(api)
  31444. if requestErr != nil {
  31445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31446. return
  31447. }
  31448. body, ioErr := ioutil.ReadAll(resp.Body)
  31449. if ioErr != nil {
  31450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31452. return
  31453. }
  31454. var respJSON map[string]interface{}
  31455. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31458. return
  31459. }
  31460. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31461. result, _ := json.Marshal(respJSON)
  31462. fmt.Println("log")
  31463. fmt.Println(string(result))
  31464. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31465. utils.ErrorLog("解析失败:%v", err)
  31466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31467. return
  31468. }
  31469. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31470. if reg_type == 11 && his.Insutype == "390" {
  31471. reg_type = 110104
  31472. }
  31473. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31474. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31475. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31476. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31477. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31478. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31479. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31480. resp, requestErr := http.Get(api)
  31481. if requestErr != nil {
  31482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31483. return
  31484. }
  31485. body, ioErr := ioutil.ReadAll(resp.Body)
  31486. if ioErr != nil {
  31487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31489. return
  31490. }
  31491. var respJSON map[string]interface{}
  31492. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31495. return
  31496. }
  31497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31498. result, _ := json.Marshal(respJSON)
  31499. fmt.Println("log")
  31500. fmt.Println(string(result))
  31501. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31502. utils.ErrorLog("解析失败:%v", err)
  31503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31504. return
  31505. }
  31506. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  31507. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31508. var result3101 Result3101
  31509. //utils.ErrorLog("解析失败:%v", result3101)
  31510. result3101.Infcode = "0"
  31511. if result3101.Infcode == "0" {
  31512. if len(result3101.Output.Result) > 0 {
  31513. var errMsgs []string
  31514. for _, item := range result3101.Output.Result {
  31515. errMsgs = append(errMsgs, item.VolaCont)
  31516. }
  31517. c.ServeSuccessJSON(map[string]interface{}{
  31518. "failed_code": -10,
  31519. "msg": errMsgs,
  31520. })
  31521. return
  31522. } else {
  31523. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31524. if his.IdCardType != 4 {
  31525. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31526. bas := strings.Split(psn_info.CardInfo, "|")
  31527. if his.IdCardType == 1 {
  31528. cert_no = bas[2]
  31529. } else {
  31530. cert_no = bas[1]
  31531. }
  31532. } else {
  31533. cert_no = his.Certno
  31534. }
  31535. //江苏地区国家医保医疗类别
  31536. //职工透析:医疗类别选特殊情况门诊9933
  31537. //居民血透门慢: 医疗类别选门诊慢病1402
  31538. //var med_type string
  31539. //if his.Insutype == "310" {
  31540. // if reg_type == 14 {
  31541. // med_type = "9933"
  31542. // } else if reg_type == 11 {
  31543. // med_type = "11"
  31544. //
  31545. // }
  31546. //} else if his.Insutype == "390" {
  31547. // if reg_type == 14 {
  31548. // med_type = "1402"
  31549. // } else if reg_type == 11 {
  31550. // med_type = "11"
  31551. // }
  31552. //}
  31553. var api string
  31554. if miConfig.MdtrtareaAdmvs == "320830" {
  31555. api = miConfig.AppSecret + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31556. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31557. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31558. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31559. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31560. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31561. "&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
  31562. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31563. } else if miConfig.MdtrtareaAdmvs == "320921" {
  31564. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31565. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31566. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31567. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31568. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31569. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31570. "&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
  31571. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31572. } else {
  31573. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31574. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31575. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31576. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31577. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31578. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31579. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31580. "&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
  31581. }
  31582. resp, requestErr := http.Get(api)
  31583. if requestErr != nil {
  31584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31585. return
  31586. }
  31587. body, ioErr := ioutil.ReadAll(resp.Body)
  31588. if ioErr != nil {
  31589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31591. return
  31592. }
  31593. var respJSON map[string]interface{}
  31594. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31597. return
  31598. }
  31599. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31600. result, _ := json.Marshal(respJSON)
  31601. fmt.Println("log")
  31602. fmt.Println(string(result))
  31603. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  31604. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31605. utils.ErrorLog("解析失败:%v", err)
  31606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31607. return
  31608. }
  31609. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31610. res.Output = resSeven10265.Output
  31611. res.ErrMsg = resSeven10265.ErrMsg
  31612. res.Cainfo = resSeven10265.Cainfo
  31613. res.WarnMsg = resSeven10265.WarnMsg
  31614. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31615. res.Infcode = infocode
  31616. } else {
  31617. if miConfig.MdtrtareaAdmvs == "320830" {
  31618. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3208") {
  31619. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31620. utils.ErrorLog("解析失败:%v", err)
  31621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31622. return
  31623. }
  31624. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31625. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31626. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31627. res.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31628. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31629. res.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31630. res.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31631. res.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31632. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31633. res.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31634. res.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31635. res.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31636. res.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31637. res.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31638. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31639. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31640. res.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31641. res.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31642. res.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31643. res.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31644. res.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31645. HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31646. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31647. res.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31648. res.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31649. res.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31650. res.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31651. res.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31652. res.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31653. res.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31654. res.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31655. res.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31656. res.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31657. res.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31658. res.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31659. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31660. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31661. res.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31662. res.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31663. res.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31664. res.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31665. res.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31666. res.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31667. res.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31668. res.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31669. res.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31670. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31671. res.ErrMsg = resSeven10633Three.ErrMsg
  31672. res.Cainfo = resSeven10633Three.Cainfo
  31673. res.WarnMsg = resSeven10633Three.WarnMsg
  31674. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31675. res.Infcode = infocode
  31676. } else {
  31677. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31678. utils.ErrorLog("解析失败:%v", err)
  31679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31680. return
  31681. }
  31682. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31683. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31684. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31685. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31686. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31687. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31688. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31689. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31690. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31691. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31692. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31693. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31694. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31695. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31696. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31697. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31698. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31699. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31700. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31701. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31702. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31703. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31704. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31705. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31706. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31707. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31708. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31709. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31710. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31711. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31712. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31713. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31714. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31715. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31716. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31717. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31718. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31719. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31720. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31721. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31722. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31723. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31724. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31725. res.ErrMsg = resSeven10265Two.ErrMsg
  31726. res.Cainfo = resSeven10265Two.Cainfo
  31727. res.WarnMsg = resSeven10265Two.WarnMsg
  31728. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31729. res.Infcode = infocode
  31730. }
  31731. } else {
  31732. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3209") {
  31733. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31734. utils.ErrorLog("解析失败:%v", err)
  31735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31736. return
  31737. }
  31738. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31739. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31740. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31741. res.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31742. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31743. res.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31744. res.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31745. res.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31746. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31747. res.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31748. res.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31749. res.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31750. res.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31751. res.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31752. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31753. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31754. res.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31755. res.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31756. res.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31757. res.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31758. res.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31759. HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31760. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31761. res.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31762. res.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31763. res.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31764. res.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31765. res.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31766. res.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31767. res.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31768. res.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31769. res.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31770. res.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31771. res.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31772. res.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31773. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31774. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31775. res.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31776. res.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31777. res.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31778. res.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31779. res.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31780. res.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31781. res.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31782. res.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31783. res.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31784. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31785. res.ErrMsg = resSeven10633Three.ErrMsg
  31786. res.Cainfo = resSeven10633Three.Cainfo
  31787. res.WarnMsg = resSeven10633Three.WarnMsg
  31788. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31789. res.Infcode = infocode
  31790. } else {
  31791. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31792. utils.ErrorLog("解析失败:%v", err)
  31793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31794. return
  31795. }
  31796. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31797. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31798. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31799. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31800. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31801. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31802. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31803. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31804. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31805. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31806. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31807. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31808. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31809. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31810. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31811. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31812. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31813. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31814. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31815. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31816. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31817. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31818. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31819. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31820. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31821. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31822. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31823. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31824. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31825. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31826. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31827. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31828. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31829. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31830. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31831. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31832. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31833. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31834. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31835. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31836. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31837. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31838. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31839. res.ErrMsg = resSeven10265Two.ErrMsg
  31840. res.Cainfo = resSeven10265Two.Cainfo
  31841. res.WarnMsg = resSeven10265Two.WarnMsg
  31842. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31843. res.Infcode = infocode
  31844. }
  31845. }
  31846. }
  31847. }
  31848. }
  31849. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31850. psn_info, _ := service.GetPsnByPatientId(id)
  31851. var verify_number string
  31852. if psn_info.IdCardType == 4 {
  31853. verify_number = psn_info.VerifyNumber
  31854. } else if psn_info.IdCardType == 1 {
  31855. bas := strings.Split(psn_info.CardInfo, "|")
  31856. cardNumber := bas[2]
  31857. verify_number = cardNumber
  31858. } else {
  31859. psn_info.IdCardType = 2
  31860. verify_number = psn_info.Certno
  31861. }
  31862. var api string
  31863. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31864. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  31865. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31866. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31867. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  31868. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31869. "&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
  31870. resp, requestErr := http.Get(api)
  31871. if requestErr != nil {
  31872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31873. return
  31874. }
  31875. body, ioErr := ioutil.ReadAll(resp.Body)
  31876. if ioErr != nil {
  31877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31879. return
  31880. }
  31881. var respJSON map[string]interface{}
  31882. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31885. return
  31886. }
  31887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31888. result, _ := json.Marshal(respJSON)
  31889. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31890. utils.ErrorLog("解析失败:%v", err)
  31891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31892. return
  31893. }
  31894. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31895. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  31896. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  31897. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31898. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  31899. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  31900. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  31901. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  31902. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  31903. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  31904. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  31905. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  31906. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  31907. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31908. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  31909. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  31910. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  31911. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  31912. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  31913. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  31914. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31915. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  31916. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  31917. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  31918. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  31919. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  31920. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  31921. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  31922. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  31923. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  31924. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  31925. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  31926. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  31927. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  31928. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31929. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  31930. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  31931. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  31932. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  31933. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  31934. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  31935. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  31936. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  31937. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  31938. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  31939. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  31940. res.ErrMsg = resSeven10265.ErrMsg
  31941. res.Cainfo = resSeven10265.Cainfo
  31942. res.WarnMsg = resSeven10265.WarnMsg
  31943. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31944. res.Infcode = infocode
  31945. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31946. acct_used_flag := "1"
  31947. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  31948. var result string
  31949. var request_log string
  31950. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  31951. 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)
  31952. } else {
  31953. 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)
  31954. }
  31955. var dat map[string]interface{}
  31956. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31957. fmt.Println(dat)
  31958. } else {
  31959. fmt.Println(err)
  31960. }
  31961. saveLog(result, request_log, "2206", "预结算")
  31962. userJSONBytes, _ := json.Marshal(dat)
  31963. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31964. utils.ErrorLog("解析失败:%v", err)
  31965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31966. return
  31967. }
  31968. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31969. var result string
  31970. var request_log string
  31971. if his.IdCardType == 2 {
  31972. insutype = strconv.FormatInt(his.SocialType, 10)
  31973. 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, "")
  31974. } else if his.IdCardType == 1 {
  31975. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31976. bas := strings.Split(psn_info.CardInfo, "|")
  31977. basNumber := bas[2]
  31978. card_sn := bas[3]
  31979. var rf []*ResultFive
  31980. json.Unmarshal([]byte(his.Iinfo), &rf)
  31981. var psn_type string
  31982. for _, item := range rf {
  31983. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31984. psn_type = item.PsnType
  31985. }
  31986. }
  31987. insutype = strconv.FormatInt(his.SocialType, 10)
  31988. 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)
  31989. } else {
  31990. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31991. //bas := strings.Split(psn_info.CardInfo, "|")
  31992. //basNumber := bas[2]
  31993. //card_sn := bas[3]
  31994. var rf []*ResultFive
  31995. json.Unmarshal([]byte(his.Iinfo), &rf)
  31996. var psn_type string
  31997. for _, item := range rf {
  31998. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31999. psn_type = item.PsnType
  32000. }
  32001. }
  32002. insutype = strconv.FormatInt(his.SocialType, 10)
  32003. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32004. 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, psn_info.VerifyNumber, "", "", his.PsnCertType, his.Certno, psn_type, his.PsnName)
  32005. }
  32006. var dat map[string]interface{}
  32007. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32008. fmt.Println(dat)
  32009. } else {
  32010. fmt.Println(err)
  32011. }
  32012. saveLog(result, request_log, "2206", "预结算")
  32013. userJSONBytes, _ := json.Marshal(dat)
  32014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32015. utils.ErrorLog("解析失败:%v", err)
  32016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32017. return
  32018. }
  32019. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32020. var result string
  32021. var request_log string
  32022. if his.IdCardType == 2 {
  32023. insutype = strconv.FormatInt(his.SocialType, 10)
  32024. 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, "")
  32025. } else if his.IdCardType == 1 {
  32026. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32027. bas := strings.Split(psn_info.CardInfo, "|")
  32028. basNumber := bas[0]
  32029. card_sn := ""
  32030. var rf []*ResultFive
  32031. json.Unmarshal([]byte(his.Iinfo), &rf)
  32032. var psn_type string
  32033. for _, item := range rf {
  32034. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32035. psn_type = item.PsnType
  32036. }
  32037. }
  32038. insutype = strconv.FormatInt(his.SocialType, 10)
  32039. 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)
  32040. } else {
  32041. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32042. //bas := strings.Split(psn_info.CardInfo, "|")
  32043. //basNumber := bas[2]
  32044. //card_sn := bas[3]
  32045. var rf []*ResultFive
  32046. json.Unmarshal([]byte(his.Iinfo), &rf)
  32047. var psn_type string
  32048. for _, item := range rf {
  32049. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32050. psn_type = item.PsnType
  32051. }
  32052. }
  32053. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32054. 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, psn_info.VerifyNumber, "", "", his.PsnCertType, his.Certno, psn_type, his.PsnName)
  32055. }
  32056. var dat map[string]interface{}
  32057. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32058. fmt.Println(dat)
  32059. } else {
  32060. fmt.Println(err)
  32061. }
  32062. saveLog(result, request_log, "2206", "预结算")
  32063. userJSONBytes, _ := json.Marshal(dat)
  32064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32065. utils.ErrorLog("解析失败:%v", err)
  32066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32067. return
  32068. }
  32069. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32070. var result string
  32071. var request_log string
  32072. if his.IdCardType == 2 {
  32073. insutype = strconv.FormatInt(his.SocialType, 10)
  32074. 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, "")
  32075. } else if his.IdCardType == 1 {
  32076. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32077. bas := strings.Split(psn_info.CardInfo, "|")
  32078. basNumber := bas[0]
  32079. card_sn := ""
  32080. var rf []*ResultFive
  32081. json.Unmarshal([]byte(his.Iinfo), &rf)
  32082. var psn_type string
  32083. for _, item := range rf {
  32084. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32085. psn_type = item.PsnType
  32086. }
  32087. }
  32088. insutype = strconv.FormatInt(his.SocialType, 10)
  32089. 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)
  32090. } else {
  32091. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32092. //bas := strings.Split(psn_info.CardInfo, "|")
  32093. //basNumber := bas[2]
  32094. //card_sn := bas[3]
  32095. var rf []*ResultFive
  32096. json.Unmarshal([]byte(his.Iinfo), &rf)
  32097. var psn_type string
  32098. for _, item := range rf {
  32099. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32100. psn_type = item.PsnType
  32101. }
  32102. }
  32103. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32104. 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, psn_info.VerifyNumber, "", "", his.PsnCertType, his.Certno, psn_type, his.PsnName)
  32105. }
  32106. var dat map[string]interface{}
  32107. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32108. fmt.Println(dat)
  32109. } else {
  32110. fmt.Println(err)
  32111. }
  32112. saveLog(result, request_log, "2206", "预结算")
  32113. userJSONBytes, _ := json.Marshal(dat)
  32114. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32115. utils.ErrorLog("解析失败:%v", err)
  32116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32117. return
  32118. }
  32119. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32120. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32121. if his.IdCardType == 4 {
  32122. psn_info.VerifyNumber = psn_info.VerifyNumber
  32123. cert_no = psn_info.VerifyNumber
  32124. } else if his.IdCardType == 2 {
  32125. cert_no = psn_info.Certno
  32126. psn_info.VerifyNumber = psn_info.Certno
  32127. } else {
  32128. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32129. bas := strings.Split(psn_info.CardInfo, "|")
  32130. if his.IdCardType == 1 {
  32131. cert_no = bas[2]
  32132. } else {
  32133. cert_no = bas[1]
  32134. }
  32135. }
  32136. var api string
  32137. var med_type string
  32138. if his.Insutype == "390" {
  32139. if reg_type == 992102 {
  32140. med_type = "992102"
  32141. }
  32142. if reg_type == 140104 {
  32143. med_type = "140104"
  32144. }
  32145. if reg_type == 140201 {
  32146. med_type = "140201"
  32147. }
  32148. if reg_type == 14 {
  32149. med_type = "140104"
  32150. }
  32151. if reg_type == 1104 {
  32152. med_type = "1104"
  32153. }
  32154. } else if his.Insutype == "310" {
  32155. if reg_type == 1104 {
  32156. med_type = "1104"
  32157. }
  32158. if reg_type == 992102 {
  32159. med_type = "992102"
  32160. }
  32161. if reg_type == 140104 {
  32162. med_type = "140104"
  32163. }
  32164. if reg_type == 140201 {
  32165. med_type = "140201"
  32166. }
  32167. if reg_type == 14 {
  32168. med_type = "140104"
  32169. }
  32170. }
  32171. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32172. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32173. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32174. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32175. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32176. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32177. "&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
  32178. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32179. resp, requestErr := http.Get(api)
  32180. if requestErr != nil {
  32181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32182. return
  32183. }
  32184. body, ioErr := ioutil.ReadAll(resp.Body)
  32185. if ioErr != nil {
  32186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32188. return
  32189. }
  32190. var respJSON map[string]interface{}
  32191. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32194. return
  32195. }
  32196. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32197. if status == "0" {
  32198. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32199. c.ServeSuccessJSON(map[string]interface{}{
  32200. "failed_code": -10,
  32201. "msg": err_msg,
  32202. })
  32203. return
  32204. }
  32205. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32206. result, _ := json.Marshal(respJSON)
  32207. fmt.Println("log")
  32208. fmt.Println(string(result))
  32209. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32210. utils.ErrorLog("解析失败:%v", err)
  32211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32212. return
  32213. }
  32214. res.InfRefmsgid = ahres.InfRefmsgid
  32215. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32216. // 创建对应的Time类型
  32217. t := time.UnixMilli(timestamp)
  32218. // 格式化成指定的日期字符串
  32219. str := t.Format("2006-01-02 15:04:05")
  32220. res.Output.Setlinfo.SetlTime = str
  32221. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32222. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32223. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32224. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32225. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32226. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32227. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32228. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32229. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32230. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32231. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32232. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32233. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32234. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32235. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32236. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32237. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32238. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32239. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32240. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32241. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32242. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32243. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32244. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32245. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32246. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32247. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32248. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32249. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32250. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32251. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32252. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32253. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32254. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32255. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32256. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32257. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32258. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32259. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32260. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32261. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32262. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32263. //res.Output.Setldetail = ahres.Output.Setldetail
  32264. res.ErrMsg = ahres.ErrMsg
  32265. res.Cainfo = ahres.Cainfo
  32266. res.WarnMsg = ahres.WarnMsg
  32267. res.Infcode = ahres.Infcode
  32268. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32269. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32270. if his.IdCardType == 4 {
  32271. psn_info.VerifyNumber = psn_info.VerifyNumber
  32272. cert_no = psn_info.Certno
  32273. } else if his.IdCardType == 2 {
  32274. cert_no = psn_info.Certno
  32275. psn_info.VerifyNumber = psn_info.Certno
  32276. } else {
  32277. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32278. bas := strings.Split(psn_info.CardInfo, "|")
  32279. if his.IdCardType == 1 {
  32280. cert_no = bas[2]
  32281. } else {
  32282. cert_no = bas[1]
  32283. }
  32284. }
  32285. var api string
  32286. var med_type string
  32287. if his.Insutype == "390" {
  32288. if reg_type == 992102 {
  32289. med_type = "992102"
  32290. }
  32291. if reg_type == 140104 {
  32292. med_type = "140104"
  32293. }
  32294. if reg_type == 140201 {
  32295. med_type = "140201"
  32296. }
  32297. if reg_type == 14 {
  32298. med_type = "14"
  32299. }
  32300. } else if his.Insutype == "310" {
  32301. if reg_type == 992102 {
  32302. med_type = "992102"
  32303. }
  32304. if reg_type == 140104 {
  32305. med_type = "140104"
  32306. }
  32307. if reg_type == 140201 {
  32308. med_type = "140201"
  32309. }
  32310. if reg_type == 14 {
  32311. med_type = "14"
  32312. }
  32313. }
  32314. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32315. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32316. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32317. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32318. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32319. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32320. "&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
  32321. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32322. resp, requestErr := http.Get(api)
  32323. if requestErr != nil {
  32324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32325. return
  32326. }
  32327. body, ioErr := ioutil.ReadAll(resp.Body)
  32328. if ioErr != nil {
  32329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32331. return
  32332. }
  32333. var respJSON map[string]interface{}
  32334. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32337. return
  32338. }
  32339. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32340. if status == "0" {
  32341. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32342. c.ServeSuccessJSON(map[string]interface{}{
  32343. "failed_code": -10,
  32344. "msg": err_msg,
  32345. })
  32346. return
  32347. }
  32348. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32349. result, _ := json.Marshal(respJSON)
  32350. fmt.Println("log")
  32351. fmt.Println(string(result))
  32352. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32353. utils.ErrorLog("解析失败:%v", err)
  32354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32355. return
  32356. }
  32357. res.InfRefmsgid = ahres.InfRefmsgid
  32358. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32359. // 创建对应的Time类型
  32360. t := time.UnixMilli(timestamp)
  32361. // 格式化成指定的日期字符串
  32362. str := t.Format("2006-01-02 15:04:05")
  32363. res.Output.Setlinfo.SetlTime = str
  32364. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32365. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32366. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32367. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32368. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32369. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32370. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32371. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32372. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32373. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32374. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32375. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32376. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32377. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32378. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32379. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32380. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32381. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32382. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32383. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32384. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32385. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32386. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32387. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32388. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32389. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32390. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32391. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32392. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32393. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32394. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32395. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32396. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32397. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32398. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32399. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32400. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32401. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32402. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32403. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32404. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32405. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32406. //res.Output.Setldetail = ahres.Output.Setldetail
  32407. res.ErrMsg = ahres.ErrMsg
  32408. res.Cainfo = ahres.Cainfo
  32409. res.WarnMsg = ahres.WarnMsg
  32410. res.Infcode = ahres.Infcode
  32411. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32412. var result string
  32413. var request_log string
  32414. if his.IdCardType == 2 {
  32415. 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")
  32416. } else if his.IdCardType == 1 {
  32417. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32418. bas := strings.Split(psn_info.CardInfo, "|")
  32419. basNumber := bas[2]
  32420. card_sn := bas[3]
  32421. 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")
  32422. } else {
  32423. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32424. 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")
  32425. }
  32426. var dat map[string]interface{}
  32427. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32428. fmt.Println(dat)
  32429. } else {
  32430. fmt.Println(err)
  32431. }
  32432. saveLog(result, request_log, "2206", "预结算")
  32433. userJSONBytes, _ := json.Marshal(dat)
  32434. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32435. utils.ErrorLog("解析失败:%v", err)
  32436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32437. return
  32438. }
  32439. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32440. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32441. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32442. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32443. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32444. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32445. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32446. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  32447. resp, requestErr := http.Get(api)
  32448. if requestErr != nil {
  32449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32450. return
  32451. }
  32452. body, ioErr := ioutil.ReadAll(resp.Body)
  32453. if ioErr != nil {
  32454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32456. return
  32457. }
  32458. var respJSON map[string]interface{}
  32459. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32462. return
  32463. }
  32464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32465. result, _ := json.Marshal(respJSON)
  32466. fmt.Println("log")
  32467. fmt.Println(string(result))
  32468. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32469. utils.ErrorLog("解析失败:%v", err)
  32470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32471. return
  32472. }
  32473. } else {
  32474. if miConfig.MdtrtareaAdmvs == "441202" {
  32475. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32476. if result3101.Infcode == 0 {
  32477. if len(result3101.Output.Result) > 0 {
  32478. c.ServeSuccessJSON(map[string]interface{}{
  32479. "failed_code": -10,
  32480. "failed_type": 100,
  32481. "msg": result3101.Output.Result,
  32482. })
  32483. return
  32484. } else {
  32485. var result string
  32486. var request_log string
  32487. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32488. allTotal = fmt.Sprintf("%.2f", total_two)
  32489. if his.IdCardType == 4 {
  32490. 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)
  32491. } else {
  32492. 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)
  32493. }
  32494. var dat map[string]interface{}
  32495. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32496. fmt.Println(dat)
  32497. } else {
  32498. fmt.Println(err)
  32499. }
  32500. saveLog(result, request_log, "2206", "预结算")
  32501. //userJSONBytes, _ := json.Marshal(dat)
  32502. //
  32503. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32504. // utils.ErrorLog("解析失败:%v", err)
  32505. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32506. // return
  32507. //}
  32508. userJSONBytes, _ := json.Marshal(dat)
  32509. if miConfig.Code == "H15049901371" {
  32510. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32511. utils.ErrorLog("解析失败:%v", err)
  32512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32513. return
  32514. }
  32515. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32516. res.Output = resSeven10265.Output
  32517. res.ErrMsg = resSeven10265.ErrMsg
  32518. res.Cainfo = resSeven10265.Cainfo
  32519. res.WarnMsg = resSeven10265.WarnMsg
  32520. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32521. res.Infcode = infocode
  32522. } else {
  32523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32524. utils.ErrorLog("解析失败:%v", err)
  32525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32526. return
  32527. }
  32528. }
  32529. }
  32530. } else {
  32531. c.ServeSuccessJSON(map[string]interface{}{
  32532. "failed_code": -10,
  32533. "msg": result3101.ErrMsg,
  32534. })
  32535. return
  32536. }
  32537. } else if miConfig.MdtrtareaAdmvs == "440205" {
  32538. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32539. if result3101.Infcode == 0 {
  32540. if len(result3101.Output.Result) > 0 {
  32541. var errMsgs []string
  32542. for _, item := range result3101.Output.Result {
  32543. errMsgs = append(errMsgs, item.VolaCont)
  32544. }
  32545. c.ServeSuccessJSON(map[string]interface{}{
  32546. "failed_code": -10,
  32547. "msg": errMsgs,
  32548. })
  32549. return
  32550. } else {
  32551. var result string
  32552. var request_log string
  32553. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32554. allTotal = fmt.Sprintf("%.2f", total_two)
  32555. if his.IdCardType == 4 {
  32556. 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)
  32557. } else {
  32558. 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)
  32559. }
  32560. var dat map[string]interface{}
  32561. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32562. fmt.Println(dat)
  32563. } else {
  32564. fmt.Println(err)
  32565. }
  32566. saveLog(result, request_log, "2206", "预结算")
  32567. //userJSONBytes, _ := json.Marshal(dat)
  32568. //
  32569. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32570. // utils.ErrorLog("解析失败:%v", err)
  32571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32572. // return
  32573. //}
  32574. userJSONBytes, _ := json.Marshal(dat)
  32575. if miConfig.Code == "H15049901371" {
  32576. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32577. utils.ErrorLog("解析失败:%v", err)
  32578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32579. return
  32580. }
  32581. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32582. res.Output = resSeven10265.Output
  32583. res.ErrMsg = resSeven10265.ErrMsg
  32584. res.Cainfo = resSeven10265.Cainfo
  32585. res.WarnMsg = resSeven10265.WarnMsg
  32586. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32587. res.Infcode = infocode
  32588. } else {
  32589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32590. utils.ErrorLog("解析失败:%v", err)
  32591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32592. return
  32593. }
  32594. }
  32595. }
  32596. } else {
  32597. c.ServeSuccessJSON(map[string]interface{}{
  32598. "failed_code": -10,
  32599. "msg": result3101.ErrMsg,
  32600. })
  32601. return
  32602. }
  32603. } else {
  32604. var result string
  32605. var request_log string
  32606. var dat map[string]interface{}
  32607. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32608. allTotal = fmt.Sprintf("%.2f", total_two)
  32609. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  32610. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32611. if result3101.Infcode == 0 {
  32612. if len(result3101.Output.Result) > 0 {
  32613. c.ServeSuccessJSON(map[string]interface{}{
  32614. "failed_code": -10,
  32615. "failed_type": 100,
  32616. "warm_type": 2,
  32617. "msg": result3101,
  32618. })
  32619. return
  32620. } else {
  32621. var result string
  32622. var request_log string
  32623. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32624. allTotal = fmt.Sprintf("%.2f", total_two)
  32625. if his.IdCardType == 4 {
  32626. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, his.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)
  32627. } else {
  32628. if his.IdCardType == 2 {
  32629. cert_no = psn_info.Certno
  32630. psn_info.VerifyNumber = psn_info.Certno
  32631. } else {
  32632. bas := strings.Split(psn_info.CardInfo, "|")
  32633. cert_no = bas[2]
  32634. }
  32635. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  32636. }
  32637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32638. fmt.Println(dat)
  32639. } else {
  32640. fmt.Println(err)
  32641. }
  32642. saveLog(result, request_log, "2206", "预结算")
  32643. }
  32644. } else {
  32645. c.ServeSuccessJSON(map[string]interface{}{
  32646. "failed_code": -10,
  32647. "msg": result3101.ErrMsg,
  32648. })
  32649. return
  32650. }
  32651. } else {
  32652. if his.IdCardType == 4 {
  32653. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, his.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)
  32654. } else {
  32655. if his.IdCardType == 2 {
  32656. cert_no = psn_info.Certno
  32657. psn_info.VerifyNumber = psn_info.Certno
  32658. } else {
  32659. bas := strings.Split(psn_info.CardInfo, "|")
  32660. cert_no = bas[2]
  32661. }
  32662. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  32663. }
  32664. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32665. fmt.Println(dat)
  32666. } else {
  32667. fmt.Println(err)
  32668. }
  32669. saveLog(result, request_log, "2206", "预结算")
  32670. }
  32671. //userJSONBytes, _ := json.Marshal(dat)
  32672. //
  32673. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32674. // utils.ErrorLog("解析失败:%v", err)
  32675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32676. // return
  32677. //}
  32678. userJSONBytes, _ := json.Marshal(dat)
  32679. if miConfig.Code == "H15049901371" {
  32680. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32681. utils.ErrorLog("解析失败:%v", err)
  32682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32683. return
  32684. }
  32685. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32686. res.Output = resSeven10265.Output
  32687. res.ErrMsg = resSeven10265.ErrMsg
  32688. res.Cainfo = resSeven10265.Cainfo
  32689. res.WarnMsg = resSeven10265.WarnMsg
  32690. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32691. res.Infcode = infocode
  32692. } else {
  32693. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32694. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  32695. utils.ErrorLog("解析失败:%v", err)
  32696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32697. return
  32698. }
  32699. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  32700. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  32701. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  32702. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32703. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  32704. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  32705. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  32706. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32707. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  32708. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32709. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32710. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32711. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32712. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32713. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  32714. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  32715. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  32716. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  32717. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  32718. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  32719. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32720. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  32721. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  32722. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  32723. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  32724. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  32725. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  32726. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  32727. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  32728. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  32729. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  32730. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  32731. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  32732. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  32733. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32734. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  32735. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  32736. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  32737. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32738. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  32739. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  32740. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  32741. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  32742. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  32743. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  32744. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  32745. res.ErrMsg = gzresSeven10265Two.ErrMsg
  32746. res.Cainfo = gzresSeven10265Two.Cainfo
  32747. res.WarnMsg = gzresSeven10265Two.WarnMsg
  32748. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  32749. //res.Infcode = infocode
  32750. } else {
  32751. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32752. utils.ErrorLog("解析失败:%v", err)
  32753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32754. return
  32755. }
  32756. }
  32757. }
  32758. }
  32759. }
  32760. utils.ErrorLog("解析失败:%v", res.Infcode)
  32761. if res.Infcode == -1 {
  32762. errlog := &models.HisOrderError{
  32763. UserOrgId: adminUser.CurrentOrgId,
  32764. Ctime: time.Now().Unix(),
  32765. Mtime: time.Now().Unix(),
  32766. Number: chrg_bchno,
  32767. ErrMsg: res.ErrMsg,
  32768. Status: 1,
  32769. PatientId: id,
  32770. RecordTime: recordDateTime,
  32771. Stage: 20,
  32772. }
  32773. service.CreateErrMsgLog(errlog)
  32774. c.ServeSuccessJSON(map[string]interface{}{
  32775. "failed_code": -10,
  32776. "msg": res.ErrMsg,
  32777. })
  32778. return
  32779. }
  32780. if res.Infcode != 0 {
  32781. errlog := &models.HisOrderError{
  32782. UserOrgId: adminUser.CurrentOrgId,
  32783. Ctime: time.Now().Unix(),
  32784. Mtime: time.Now().Unix(),
  32785. Number: chrg_bchno,
  32786. ErrMsg: res.ErrMsg,
  32787. Status: 1,
  32788. PatientId: id,
  32789. RecordTime: recordDateTime,
  32790. Stage: 20,
  32791. }
  32792. service.CreateErrMsgLog(errlog)
  32793. c.ServeSuccessJSON(map[string]interface{}{
  32794. "failed_code": -10,
  32795. "msg": res.ErrMsg,
  32796. })
  32797. return
  32798. } else {
  32799. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32800. order.OrderStatus = 1
  32801. order.IsPre = 1
  32802. order.Status = 1
  32803. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  32804. order.SetlId = res.Output.Setlinfo.SetlID
  32805. order.PsnNo = res.Output.Setlinfo.PsnNo
  32806. order.PsnName = res.Output.Setlinfo.PsnName
  32807. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  32808. order.Certno = res.Output.Setlinfo.Certno
  32809. order.Gend = res.Output.Setlinfo.Gend
  32810. order.Naty = res.Output.Setlinfo.Naty
  32811. order.Age = res.Output.Setlinfo.Age
  32812. order.Insutype = res.Output.Setlinfo.Insutype
  32813. order.PsnType = res.Output.Setlinfo.PsnType
  32814. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  32815. order.SetlTime = res.Output.Setlinfo.SetlTime
  32816. order.AcctUsedFlag = acct_used_flag
  32817. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  32818. if res.Output.Setlinfo.MedType == "140101" {
  32819. order.MedType = "14"
  32820. } else {
  32821. if res.Output.Setlinfo.MedType == "110104" {
  32822. order.MedType = "11"
  32823. } else {
  32824. order.MedType = res.Output.Setlinfo.MedType
  32825. }
  32826. }
  32827. if res.Output.Setlinfo.MedType == "992102" {
  32828. order.MedType = "992102"
  32829. }
  32830. if res.Output.Setlinfo.MedType == "140104" {
  32831. order.MedType = "140104"
  32832. }
  32833. if res.Output.Setlinfo.MedType == "1104" {
  32834. order.MedType = "1104"
  32835. }
  32836. if res.Output.Setlinfo.MedType == "140201" {
  32837. order.MedType = "140201"
  32838. }
  32839. if res.Output.Setlinfo.MedType == "14" {
  32840. order.MedType = "14"
  32841. }
  32842. if reg_type == 1112 {
  32843. order.MedType = "1112"
  32844. }
  32845. if reg_type == 1111 {
  32846. order.MedType = "1111"
  32847. }
  32848. order.ClrType = res.Output.Setlinfo.ClrType
  32849. if adminUser.CurrentOrgId == 10480 {
  32850. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32851. order.ClrType = "11"
  32852. } else {
  32853. order.ClrType = "9903"
  32854. }
  32855. }
  32856. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  32857. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  32858. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  32859. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  32860. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  32861. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  32862. order.HifpPay = res.Output.Setlinfo.HifpPay
  32863. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  32864. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  32865. order.HifesPay = res.Output.Setlinfo.HifesPay
  32866. order.HifobPay = res.Output.Setlinfo.HifobPay
  32867. order.MafPay = res.Output.Setlinfo.MafPay
  32868. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  32869. order.OthPay = res.Output.Setlinfo.OthPay
  32870. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  32871. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  32872. order.AcctPay = res.Output.Setlinfo.AcctPay
  32873. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  32874. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  32875. order.Balc = res.Output.Setlinfo.Balc
  32876. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  32877. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  32878. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  32879. order.ClrWay = res.Output.Setlinfo.ClrWay
  32880. order.Creator = order.Creator
  32881. order.Modify = roles.AdminUserId
  32882. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32883. //detailStr := string(setlDetail)
  32884. //order.SetlDetail = detailStr
  32885. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32886. err = service.UpDateOrder(order)
  32887. if err == nil {
  32888. c.ServeSuccessJSON(map[string]interface{}{
  32889. "msg": "预结算成功",
  32890. })
  32891. } else {
  32892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32893. return
  32894. }
  32895. }
  32896. } else {
  32897. adminUser := c.GetAdminUserInfo()
  32898. errlog := &models.HisOrderError{
  32899. UserOrgId: adminUser.CurrentOrgId,
  32900. Ctime: time.Now().Unix(),
  32901. Mtime: time.Now().Unix(),
  32902. ErrMsg: res.ErrMsg,
  32903. Status: 1,
  32904. PatientId: id,
  32905. RecordTime: recordDateTime,
  32906. Stage: 4,
  32907. }
  32908. service.CreateErrMsgLog(errlog)
  32909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  32910. return
  32911. }
  32912. } else {
  32913. if miConfig.MdtrtareaAdmvs == "150499" {
  32914. order := &models.HisOrder{
  32915. UserOrgId: adminUser.CurrentOrgId,
  32916. HisPatientId: his.ID,
  32917. PatientId: his.PatientId,
  32918. SettleAccountsDate: recordDateTime,
  32919. Ctime: time.Now().Unix(),
  32920. Mtime: time.Now().Unix(),
  32921. MdtrtId: his.Number,
  32922. PsnNo: his.PsnNo,
  32923. MedType: strconv.FormatInt(reg_type, 10),
  32924. Status: 1,
  32925. Number: chrg_bchno,
  32926. Infcode: res.Infcode,
  32927. WarnMsg: res.WarnMsg,
  32928. Cainfo: res.Cainfo,
  32929. ErrMsg: res.ErrMsg,
  32930. RespondTime: res.RefmsgTime,
  32931. InfRefmsgid: res.InfRefmsgid,
  32932. OrderStatus: 1,
  32933. IsMedicineInsurance: 1,
  32934. SettleType: settle_accounts_type,
  32935. SettleStartTime: start_time,
  32936. SettleEndTime: end_time,
  32937. Creator: roles.AdminUserId,
  32938. Modify: roles.AdminUserId,
  32939. PType: 2,
  32940. Diagnosis: diagnosis_id,
  32941. }
  32942. err = service.CreateOrder(order)
  32943. if err != nil {
  32944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  32945. return
  32946. }
  32947. }
  32948. adminUser := c.GetAdminUserInfo()
  32949. errlog := &models.HisOrderError{
  32950. UserOrgId: adminUser.CurrentOrgId,
  32951. Ctime: time.Now().Unix(),
  32952. Mtime: time.Now().Unix(),
  32953. ErrMsg: res.ErrMsg,
  32954. Status: 1,
  32955. PatientId: id,
  32956. RecordTime: recordDateTime,
  32957. Stage: 4,
  32958. }
  32959. service.CreateErrMsgLog(errlog)
  32960. c.ServeSuccessJSON(map[string]interface{}{
  32961. "failed_code": -10,
  32962. "msg": res.ErrMsg,
  32963. })
  32964. return
  32965. }
  32966. }
  32967. }
  32968. }
  32969. // 退款
  32970. func (c *HisApiController) Refund() {
  32971. order_id, _ := c.GetInt64("order_id")
  32972. admin_user_id, _ := c.GetInt64("admin_user_id")
  32973. adminUser := c.GetAdminUserInfo()
  32974. var order models.HisOrder
  32975. order, _ = service.GetHisOrderByID(order_id)
  32976. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  32977. if fapiao.ID > 0 {
  32978. c.ServeSuccessJSON(map[string]interface{}{
  32979. "failed_code": -10,
  32980. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  32981. })
  32982. return
  32983. }
  32984. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32985. if order.ID == 0 {
  32986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32987. return
  32988. }
  32989. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32990. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32991. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32992. if config.IsOpen == 1 { //对接了医保,走医保流程
  32993. var res ResultSixteen
  32994. var ahres ResultSevenAH
  32995. var resSixteen10265 ResultSixteen10265
  32996. var resSixteen10265Two ResultSixteen10265Two
  32997. var gz ResultgzSixteen10265Two
  32998. var src_resquest string
  32999. var result string
  33000. if miConfig.MdtrtareaAdmvs == "421300" {
  33001. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  33002. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33003. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33004. resp3, requestErr3 := http.Get(api3)
  33005. if requestErr3 != nil {
  33006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33007. return
  33008. }
  33009. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33010. if ioErr3 != nil {
  33011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33013. return
  33014. }
  33015. var respJSON3 map[string]interface{}
  33016. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33019. return
  33020. }
  33021. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33022. userJSONBytes3, _ := json.Marshal(respJSON3)
  33023. fmt.Println("log")
  33024. fmt.Println(string(userJSONBytes3))
  33025. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33026. utils.ErrorLog("解析失败:%v", err)
  33027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33028. return
  33029. }
  33030. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33031. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  33032. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33033. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33034. resp3, requestErr3 := http.Get(api3)
  33035. if requestErr3 != nil {
  33036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33037. return
  33038. }
  33039. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33040. if ioErr3 != nil {
  33041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33043. return
  33044. }
  33045. var respJSON3 map[string]interface{}
  33046. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33049. return
  33050. }
  33051. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33052. userJSONBytes3, _ := json.Marshal(respJSON3)
  33053. fmt.Println("log")
  33054. fmt.Println(string(userJSONBytes3))
  33055. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33056. utils.ErrorLog("解析失败:%v", err)
  33057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33058. return
  33059. }
  33060. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33061. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  33062. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33063. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33064. resp3, requestErr3 := http.Get(api3)
  33065. if requestErr3 != nil {
  33066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33067. return
  33068. }
  33069. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33070. if ioErr3 != nil {
  33071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33073. return
  33074. }
  33075. var respJSON3 map[string]interface{}
  33076. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33079. return
  33080. }
  33081. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33082. userJSONBytes3, _ := json.Marshal(respJSON3)
  33083. fmt.Println("log")
  33084. fmt.Println(string(userJSONBytes3))
  33085. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33086. utils.ErrorLog("解析失败:%v", err)
  33087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33088. return
  33089. }
  33090. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33091. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  33092. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33093. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33094. resp3, requestErr3 := http.Get(api3)
  33095. if requestErr3 != nil {
  33096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33097. return
  33098. }
  33099. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33100. if ioErr3 != nil {
  33101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33103. return
  33104. }
  33105. var respJSON3 map[string]interface{}
  33106. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33109. return
  33110. }
  33111. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33112. userJSONBytes3, _ := json.Marshal(respJSON3)
  33113. fmt.Println("log")
  33114. fmt.Println(string(userJSONBytes3))
  33115. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33116. utils.ErrorLog("解析失败:%v", err)
  33117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33118. return
  33119. }
  33120. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33121. var api3 string
  33122. if miConfig.MdtrtareaAdmvs == "320830" {
  33123. api3 = miConfig.AppSecret + "jsyb/2208?psn_no=" + order.PsnNo +
  33124. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33125. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33126. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33127. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33128. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  33129. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33130. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33131. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33132. } else {
  33133. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33134. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  33135. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33136. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33137. }
  33138. resp3, requestErr3 := http.Get(api3)
  33139. if requestErr3 != nil {
  33140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33141. return
  33142. }
  33143. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33144. if ioErr3 != nil {
  33145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33147. return
  33148. }
  33149. var respJSON3 map[string]interface{}
  33150. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33153. return
  33154. }
  33155. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33156. userJSONBytes3, _ := json.Marshal(respJSON3)
  33157. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33158. utils.ErrorLog("解析失败:%v", err)
  33159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33160. return
  33161. }
  33162. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33163. res.Output = resSixteen10265.Output
  33164. res.ErrMsg = resSixteen10265.ErrMsg
  33165. res.Cainfo = resSixteen10265.Cainfo
  33166. res.WarnMsg = resSixteen10265.WarnMsg
  33167. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33168. res.Infcode = infocode
  33169. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33170. var api3 string
  33171. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  33172. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33173. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33174. resp3, requestErr3 := http.Get(api3)
  33175. if requestErr3 != nil {
  33176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33177. return
  33178. }
  33179. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33180. if ioErr3 != nil {
  33181. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33183. return
  33184. }
  33185. var respJSON3 map[string]interface{}
  33186. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33189. return
  33190. }
  33191. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33192. userJSONBytes3, _ := json.Marshal(respJSON3)
  33193. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33194. utils.ErrorLog("解析失败:%v", err)
  33195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33196. return
  33197. }
  33198. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33199. res.Output = resSixteen10265.Output
  33200. res.ErrMsg = resSixteen10265.ErrMsg
  33201. res.Cainfo = resSixteen10265.Cainfo
  33202. res.WarnMsg = resSixteen10265.WarnMsg
  33203. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33204. res.Infcode = infocode
  33205. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33206. 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)
  33207. var dat map[string]interface{}
  33208. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33209. fmt.Println(dat)
  33210. } else {
  33211. fmt.Println(err)
  33212. }
  33213. saveLog(result, src_resquest, "2208", "退费")
  33214. userJSONBytes, _ := json.Marshal(dat)
  33215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33216. utils.ErrorLog("解析失败:%v", err)
  33217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33218. return
  33219. }
  33220. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33221. 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, "")
  33222. var dat map[string]interface{}
  33223. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33224. fmt.Println(dat)
  33225. } else {
  33226. fmt.Println(err)
  33227. }
  33228. saveLog(result, src_resquest, "2208", "退费")
  33229. userJSONBytes, _ := json.Marshal(dat)
  33230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33231. utils.ErrorLog("解析失败:%v", err)
  33232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33233. return
  33234. }
  33235. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33236. 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, "")
  33237. var dat map[string]interface{}
  33238. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33239. fmt.Println(dat)
  33240. } else {
  33241. fmt.Println(err)
  33242. }
  33243. saveLog(result, src_resquest, "2208", "退费")
  33244. userJSONBytes, _ := json.Marshal(dat)
  33245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33246. utils.ErrorLog("解析失败:%v", err)
  33247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33248. return
  33249. }
  33250. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33251. 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, "")
  33252. var dat map[string]interface{}
  33253. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33254. fmt.Println(dat)
  33255. } else {
  33256. fmt.Println(err)
  33257. }
  33258. saveLog(result, src_resquest, "2208", "退费")
  33259. userJSONBytes, _ := json.Marshal(dat)
  33260. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33261. utils.ErrorLog("解析失败:%v", err)
  33262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33263. return
  33264. }
  33265. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33266. var api3 string
  33267. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33268. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33269. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33270. resp3, requestErr3 := http.Get(api3)
  33271. if requestErr3 != nil {
  33272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33273. return
  33274. }
  33275. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33276. if ioErr3 != nil {
  33277. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33279. return
  33280. }
  33281. var respJSON3 map[string]interface{}
  33282. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33285. return
  33286. }
  33287. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33288. if status == "0" {
  33289. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33290. c.ServeSuccessJSON(map[string]interface{}{
  33291. "failed_code": -10,
  33292. "msg": err_msg,
  33293. })
  33294. return
  33295. }
  33296. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33297. userJSONBytes3, _ := json.Marshal(respJSON3)
  33298. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33299. // utils.ErrorLog("解析失败:%v", err)
  33300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33301. // return
  33302. //}
  33303. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33304. utils.ErrorLog("解析失败:%v", err)
  33305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33306. return
  33307. }
  33308. res.InfRefmsgid = ahres.InfRefmsgid
  33309. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33310. // 创建对应的Time类型
  33311. t := time.UnixMilli(timestamp)
  33312. // 格式化成指定的日期字符串
  33313. str := t.Format("2006-01-02 15:04:05")
  33314. res.Output.Setlinfo.SetlTime = str
  33315. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33316. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33317. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33318. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33319. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33320. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33321. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33322. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33323. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33324. //
  33325. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33326. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33327. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33328. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33329. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33330. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33331. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33332. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33333. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33334. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33335. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33336. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33337. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33338. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33339. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33340. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33341. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33342. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33343. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33344. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33345. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33346. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33347. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33348. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33349. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33350. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33351. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33352. //res.Output.Setldetail = ahres.Output.Setldetail
  33353. res.ErrMsg = ahres.ErrMsg
  33354. res.Cainfo = ahres.Cainfo
  33355. res.WarnMsg = ahres.WarnMsg
  33356. res.Infcode = ahres.Infcode
  33357. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33358. var api3 string
  33359. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33360. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33361. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33362. resp3, requestErr3 := http.Get(api3)
  33363. if requestErr3 != nil {
  33364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33365. return
  33366. }
  33367. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33368. if ioErr3 != nil {
  33369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33371. return
  33372. }
  33373. var respJSON3 map[string]interface{}
  33374. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33377. return
  33378. }
  33379. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33380. if status == "0" {
  33381. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33382. c.ServeSuccessJSON(map[string]interface{}{
  33383. "failed_code": -10,
  33384. "msg": err_msg,
  33385. })
  33386. return
  33387. }
  33388. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33389. userJSONBytes3, _ := json.Marshal(respJSON3)
  33390. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33391. // utils.ErrorLog("解析失败:%v", err)
  33392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33393. // return
  33394. //}
  33395. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33396. utils.ErrorLog("解析失败:%v", err)
  33397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33398. return
  33399. }
  33400. res.InfRefmsgid = ahres.InfRefmsgid
  33401. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33402. // 创建对应的Time类型
  33403. t := time.UnixMilli(timestamp)
  33404. // 格式化成指定的日期字符串
  33405. str := t.Format("2006-01-02 15:04:05")
  33406. res.Output.Setlinfo.SetlTime = str
  33407. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33408. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33409. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33410. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33411. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33412. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33413. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33414. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33415. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33416. //
  33417. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33418. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33419. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33420. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33421. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33422. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33423. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33424. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33425. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33426. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33427. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33428. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33429. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33430. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33431. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33432. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33433. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33434. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33435. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33436. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33437. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33438. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33439. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33440. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33441. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33442. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33443. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33444. //res.Output.Setldetail = ahres.Output.Setldetail
  33445. res.ErrMsg = ahres.ErrMsg
  33446. res.Cainfo = ahres.Cainfo
  33447. res.WarnMsg = ahres.WarnMsg
  33448. res.Infcode = ahres.Infcode
  33449. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33450. 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, "")
  33451. var dat map[string]interface{}
  33452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33453. fmt.Println(dat)
  33454. } else {
  33455. fmt.Println(err)
  33456. }
  33457. saveLog(result, src_resquest, "2208", "退费")
  33458. userJSONBytes, _ := json.Marshal(dat)
  33459. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33460. utils.ErrorLog("解析失败:%v", err)
  33461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33462. return
  33463. }
  33464. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33465. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  33466. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33467. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33468. resp3, requestErr3 := http.Get(api3)
  33469. if requestErr3 != nil {
  33470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33471. return
  33472. }
  33473. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33474. if ioErr3 != nil {
  33475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33477. return
  33478. }
  33479. var respJSON3 map[string]interface{}
  33480. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33483. return
  33484. }
  33485. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33486. userJSONBytes3, _ := json.Marshal(respJSON3)
  33487. fmt.Println("log")
  33488. fmt.Println(string(userJSONBytes3))
  33489. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33490. utils.ErrorLog("解析失败:%v", err)
  33491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33492. return
  33493. }
  33494. } else {
  33495. if miConfig.Code == "H15049901371" {
  33496. 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)
  33497. var dat map[string]interface{}
  33498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33499. fmt.Println(dat)
  33500. } else {
  33501. fmt.Println(err)
  33502. }
  33503. saveLog(result, src_resquest, "2208", "退费")
  33504. if strings.Contains(result, "Post") {
  33505. res.Infcode = -1
  33506. res.ErrMsg = result
  33507. }
  33508. userJSONBytes, _ := json.Marshal(dat)
  33509. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  33510. utils.ErrorLog("解析失败:%v", err)
  33511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33512. return
  33513. }
  33514. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33515. res.Output = resSixteen10265.Output
  33516. res.ErrMsg = resSixteen10265.ErrMsg
  33517. res.Cainfo = resSixteen10265.Cainfo
  33518. res.WarnMsg = resSixteen10265.WarnMsg
  33519. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33520. res.Infcode = infocode
  33521. } else {
  33522. 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)
  33523. var dat map[string]interface{}
  33524. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33525. fmt.Println(dat)
  33526. } else {
  33527. fmt.Println(err)
  33528. }
  33529. saveLog(result, src_resquest, "2208", "退费")
  33530. userJSONBytes, _ := json.Marshal(dat)
  33531. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33532. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  33533. utils.ErrorLog("解析失败:%v", err)
  33534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33535. return
  33536. }
  33537. res.Infcode = gz.Infcode
  33538. } else {
  33539. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33540. utils.ErrorLog("解析失败:%v", err)
  33541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33542. return
  33543. }
  33544. }
  33545. if strings.Contains(result, "Post") {
  33546. res.Infcode = -1
  33547. res.ErrMsg = result
  33548. }
  33549. }
  33550. }
  33551. if res.Infcode == -1 {
  33552. c.ServeSuccessJSON(map[string]interface{}{
  33553. "failed_code": -10,
  33554. "msg": res.ErrMsg,
  33555. })
  33556. return
  33557. }
  33558. if res.Infcode != -1 {
  33559. var res2 ResultSix
  33560. var resSix10265 ResultSix10265
  33561. if miConfig.MdtrtareaAdmvs == "421300" {
  33562. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33563. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33564. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33565. resp3, requestErr3 := http.Get(api3)
  33566. if requestErr3 != nil {
  33567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33568. return
  33569. }
  33570. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33571. if ioErr3 != nil {
  33572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33574. return
  33575. }
  33576. var respJSON3 map[string]interface{}
  33577. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33580. return
  33581. }
  33582. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33583. userJSONBytes3, _ := json.Marshal(respJSON3)
  33584. fmt.Println("log")
  33585. fmt.Println(string(userJSONBytes3))
  33586. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33587. utils.ErrorLog("解析失败:%v", err)
  33588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33589. return
  33590. }
  33591. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33592. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33593. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33594. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33595. resp3, requestErr3 := http.Get(api3)
  33596. if requestErr3 != nil {
  33597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33598. return
  33599. }
  33600. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33601. if ioErr3 != nil {
  33602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33604. return
  33605. }
  33606. var respJSON3 map[string]interface{}
  33607. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33610. return
  33611. }
  33612. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33613. userJSONBytes3, _ := json.Marshal(respJSON3)
  33614. fmt.Println("log")
  33615. fmt.Println(string(userJSONBytes3))
  33616. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33617. utils.ErrorLog("解析失败:%v", err)
  33618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33619. return
  33620. }
  33621. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33622. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33623. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33624. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33625. resp3, requestErr3 := http.Get(api3)
  33626. if requestErr3 != nil {
  33627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33628. return
  33629. }
  33630. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33631. if ioErr3 != nil {
  33632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33634. return
  33635. }
  33636. var respJSON3 map[string]interface{}
  33637. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33640. return
  33641. }
  33642. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33643. userJSONBytes3, _ := json.Marshal(respJSON3)
  33644. fmt.Println("log")
  33645. fmt.Println(string(userJSONBytes3))
  33646. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33647. utils.ErrorLog("解析失败:%v", err)
  33648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33649. return
  33650. }
  33651. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33652. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33653. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33654. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33655. resp3, requestErr3 := http.Get(api3)
  33656. if requestErr3 != nil {
  33657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33658. return
  33659. }
  33660. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33661. if ioErr3 != nil {
  33662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33664. return
  33665. }
  33666. var respJSON3 map[string]interface{}
  33667. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33670. return
  33671. }
  33672. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33673. userJSONBytes3, _ := json.Marshal(respJSON3)
  33674. fmt.Println("log")
  33675. fmt.Println(string(userJSONBytes3))
  33676. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33677. utils.ErrorLog("解析失败:%v", err)
  33678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33679. return
  33680. }
  33681. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33682. var api3 string
  33683. if miConfig.MdtrtareaAdmvs == "320830" {
  33684. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  33685. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33686. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33687. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33688. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33689. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33690. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33691. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33692. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33693. } else {
  33694. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33695. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33696. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33697. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33698. }
  33699. resp3, requestErr3 := http.Get(api3)
  33700. if requestErr3 != nil {
  33701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33702. return
  33703. }
  33704. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33705. if ioErr3 != nil {
  33706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33708. return
  33709. }
  33710. var respJSON3 map[string]interface{}
  33711. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33714. return
  33715. }
  33716. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33717. userJSONBytes3, _ := json.Marshal(respJSON3)
  33718. fmt.Println("log")
  33719. fmt.Println(string(userJSONBytes3))
  33720. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33721. utils.ErrorLog("解析失败:%v", err)
  33722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33723. return
  33724. }
  33725. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33726. res2.Output = resSix10265.Output
  33727. res2.ErrMsg = resSix10265.ErrMsg
  33728. res2.Cainfo = resSix10265.Cainfo
  33729. res2.WarnMsg = resSix10265.WarnMsg
  33730. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33731. res2.Infcode = infocode
  33732. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33733. var api3 string
  33734. new_chrg_bchno := order.Number
  33735. if adminUser.CurrentOrgId == 10265 {
  33736. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33737. new_chrg_bchno = "0000"
  33738. }
  33739. }
  33740. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33741. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33742. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33743. resp3, requestErr3 := http.Get(api3)
  33744. if requestErr3 != nil {
  33745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33746. return
  33747. }
  33748. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33749. if ioErr3 != nil {
  33750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33752. return
  33753. }
  33754. var respJSON3 map[string]interface{}
  33755. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33758. return
  33759. }
  33760. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33761. userJSONBytes3, _ := json.Marshal(respJSON3)
  33762. fmt.Println("log")
  33763. fmt.Println(string(userJSONBytes3))
  33764. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33765. utils.ErrorLog("解析失败:%v", err)
  33766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33767. return
  33768. }
  33769. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33770. res2.Output = resSix10265.Output
  33771. res2.ErrMsg = resSix10265.ErrMsg
  33772. res2.Cainfo = resSix10265.Cainfo
  33773. res2.WarnMsg = resSix10265.WarnMsg
  33774. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33775. res2.Infcode = infocode
  33776. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33777. 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)
  33778. var dat map[string]interface{}
  33779. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33780. fmt.Println(dat)
  33781. } else {
  33782. fmt.Println(err)
  33783. }
  33784. saveLog(result2, src_request, "2205", "撤销明细")
  33785. userJSONBytes, _ := json.Marshal(dat)
  33786. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33787. utils.ErrorLog("解析失败:%v", err)
  33788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33789. return
  33790. }
  33791. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33792. 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, "")
  33793. var dat map[string]interface{}
  33794. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33795. fmt.Println(dat)
  33796. } else {
  33797. fmt.Println(err)
  33798. }
  33799. saveLog(result2, src_request, "2205", "撤销明细")
  33800. userJSONBytes, _ := json.Marshal(dat)
  33801. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33802. utils.ErrorLog("解析失败:%v", err)
  33803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33804. return
  33805. }
  33806. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33807. 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, "")
  33808. var dat map[string]interface{}
  33809. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33810. fmt.Println(dat)
  33811. } else {
  33812. fmt.Println(err)
  33813. }
  33814. saveLog(result2, src_request, "2205", "撤销明细")
  33815. userJSONBytes, _ := json.Marshal(dat)
  33816. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33817. utils.ErrorLog("解析失败:%v", err)
  33818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33819. return
  33820. }
  33821. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33822. 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, "")
  33823. var dat map[string]interface{}
  33824. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33825. fmt.Println(dat)
  33826. } else {
  33827. fmt.Println(err)
  33828. }
  33829. saveLog(result2, src_request, "2205", "撤销明细")
  33830. userJSONBytes, _ := json.Marshal(dat)
  33831. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33832. utils.ErrorLog("解析失败:%v", err)
  33833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33834. return
  33835. }
  33836. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33837. var api3 string
  33838. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33839. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33840. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33841. resp3, requestErr3 := http.Get(api3)
  33842. if requestErr3 != nil {
  33843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33844. return
  33845. }
  33846. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33847. if ioErr3 != nil {
  33848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33850. return
  33851. }
  33852. var respJSON3 map[string]interface{}
  33853. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33856. return
  33857. }
  33858. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33859. if status == "0" {
  33860. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33861. c.ServeSuccessJSON(map[string]interface{}{
  33862. "failed_code": -10,
  33863. "msg": err_msg,
  33864. })
  33865. return
  33866. }
  33867. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33868. userJSONBytes3, _ := json.Marshal(respJSON3)
  33869. fmt.Println("log")
  33870. fmt.Println(string(userJSONBytes3))
  33871. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33872. utils.ErrorLog("解析失败:%v", err)
  33873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33874. return
  33875. }
  33876. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33877. 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, "")
  33878. var dat map[string]interface{}
  33879. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33880. fmt.Println(dat)
  33881. } else {
  33882. fmt.Println(err)
  33883. }
  33884. saveLog(result2, src_request, "2205", "撤销明细")
  33885. userJSONBytes, _ := json.Marshal(dat)
  33886. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33887. utils.ErrorLog("解析失败:%v", err)
  33888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33889. return
  33890. }
  33891. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33892. 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, "")
  33893. var dat map[string]interface{}
  33894. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33895. fmt.Println(dat)
  33896. } else {
  33897. fmt.Println(err)
  33898. }
  33899. saveLog(result2, src_request, "2205", "撤销明细")
  33900. userJSONBytes, _ := json.Marshal(dat)
  33901. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33902. utils.ErrorLog("解析失败:%v", err)
  33903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33904. return
  33905. }
  33906. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33907. 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, "")
  33908. var dat map[string]interface{}
  33909. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33910. fmt.Println(dat)
  33911. } else {
  33912. fmt.Println(err)
  33913. }
  33914. saveLog(result2, src_request, "2205", "撤销明细")
  33915. userJSONBytes, _ := json.Marshal(dat)
  33916. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33917. utils.ErrorLog("解析失败:%v", err)
  33918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33919. return
  33920. }
  33921. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33922. var api3 string
  33923. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33924. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33925. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33926. resp3, requestErr3 := http.Get(api3)
  33927. if requestErr3 != nil {
  33928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33929. return
  33930. }
  33931. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33932. if ioErr3 != nil {
  33933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33935. return
  33936. }
  33937. var respJSON3 map[string]interface{}
  33938. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33941. return
  33942. }
  33943. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33944. if status == "0" {
  33945. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33946. c.ServeSuccessJSON(map[string]interface{}{
  33947. "failed_code": -10,
  33948. "msg": err_msg,
  33949. })
  33950. return
  33951. }
  33952. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33953. userJSONBytes3, _ := json.Marshal(respJSON3)
  33954. fmt.Println("log")
  33955. fmt.Println(string(userJSONBytes3))
  33956. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33957. utils.ErrorLog("解析失败:%v", err)
  33958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33959. return
  33960. }
  33961. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33962. 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, "")
  33963. var dat map[string]interface{}
  33964. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33965. fmt.Println(dat)
  33966. } else {
  33967. fmt.Println(err)
  33968. }
  33969. saveLog(result2, src_request, "2205", "撤销明细")
  33970. userJSONBytes, _ := json.Marshal(dat)
  33971. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33972. utils.ErrorLog("解析失败:%v", err)
  33973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33974. return
  33975. }
  33976. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33977. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  33978. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33979. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33980. resp3, requestErr3 := http.Get(api3)
  33981. if requestErr3 != nil {
  33982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33983. return
  33984. }
  33985. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33986. if ioErr3 != nil {
  33987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33989. return
  33990. }
  33991. var respJSON3 map[string]interface{}
  33992. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33995. return
  33996. }
  33997. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33998. userJSONBytes3, _ := json.Marshal(respJSON3)
  33999. fmt.Println("log")
  34000. fmt.Println(string(userJSONBytes3))
  34001. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34002. utils.ErrorLog("解析失败:%v", err)
  34003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34004. return
  34005. }
  34006. } else {
  34007. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34008. res2.Infcode = 0
  34009. } else {
  34010. 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)
  34011. var dat map[string]interface{}
  34012. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34013. fmt.Println(dat)
  34014. } else {
  34015. fmt.Println(err)
  34016. }
  34017. saveLog(result2, src_request, "2205", "撤销明细")
  34018. userJSONBytes, _ := json.Marshal(dat)
  34019. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34020. utils.ErrorLog("解析失败:%v", err)
  34021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34022. return
  34023. }
  34024. }
  34025. }
  34026. if res2.Infcode == -1 {
  34027. c.ServeSuccessJSON(map[string]interface{}{
  34028. "failed_code": -10,
  34029. "msg": res2.ErrMsg,
  34030. })
  34031. return
  34032. }
  34033. if res2.Infcode == 0 {
  34034. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  34035. if err == nil {
  34036. //当押金不为零时产生退费记录
  34037. if order.Decimal != 0 {
  34038. tmp := strconv.FormatInt(order.ID, 10)
  34039. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  34040. if err != nil {
  34041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34042. return
  34043. }
  34044. }
  34045. c.ServeSuccessJSON(map[string]interface{}{
  34046. "msg": "退费成功",
  34047. })
  34048. } else {
  34049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34050. return
  34051. }
  34052. } else {
  34053. c.ServeSuccessJSON(map[string]interface{}{
  34054. "failed_code": -10,
  34055. "msg": res2.ErrMsg,
  34056. })
  34057. }
  34058. } else {
  34059. c.ServeSuccessJSON(map[string]interface{}{
  34060. "failed_code": -10,
  34061. "msg": res.ErrMsg,
  34062. })
  34063. }
  34064. }
  34065. }
  34066. func (c *HisApiController) RefundNumber() {
  34067. record_time := c.GetString("record_time")
  34068. //patient_id, _ := c.GetInt64("patient_id")
  34069. admin_user_id, _ := c.GetInt64("admin_user_id")
  34070. his_patient_id, _ := c.GetInt64("id")
  34071. timeLayout := "2006-01-02"
  34072. loc, _ := time.LoadLocation("Local")
  34073. adminUser := c.GetAdminUserInfo()
  34074. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34075. fmt.Println(err)
  34076. if err != nil {
  34077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34078. return
  34079. }
  34080. recordDateTime := theTime.Unix()
  34081. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34082. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  34083. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34084. //order, _ := service.GetHisOrderByID(order_id)
  34085. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34086. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34087. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34088. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  34089. if count > 0 {
  34090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  34091. return
  34092. }
  34093. if config.IsOpen == 1 { //对接了医保,走医保流程
  34094. var res2 ResultSix
  34095. var res3 GZResultSix
  34096. var resSix10265 ResultSix10265
  34097. if miConfig.MdtrtareaAdmvs == "421300" {
  34098. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  34099. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34100. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34101. resp3, requestErr3 := http.Get(api3)
  34102. if requestErr3 != nil {
  34103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34104. return
  34105. }
  34106. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34107. if ioErr3 != nil {
  34108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34110. return
  34111. }
  34112. var respJSON3 map[string]interface{}
  34113. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34116. return
  34117. }
  34118. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34119. userJSONBytes3, _ := json.Marshal(respJSON3)
  34120. fmt.Println("log")
  34121. fmt.Println(string(userJSONBytes3))
  34122. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34123. utils.ErrorLog("解析失败:%v", err)
  34124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34125. return
  34126. }
  34127. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34128. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  34129. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34130. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34131. resp3, requestErr3 := http.Get(api3)
  34132. if requestErr3 != nil {
  34133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34134. return
  34135. }
  34136. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34137. if ioErr3 != nil {
  34138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34140. return
  34141. }
  34142. var respJSON3 map[string]interface{}
  34143. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34146. return
  34147. }
  34148. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34149. userJSONBytes3, _ := json.Marshal(respJSON3)
  34150. fmt.Println("log")
  34151. fmt.Println(string(userJSONBytes3))
  34152. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34153. utils.ErrorLog("解析失败:%v", err)
  34154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34155. return
  34156. }
  34157. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34158. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34159. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34160. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34161. resp3, requestErr3 := http.Get(api3)
  34162. if requestErr3 != nil {
  34163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34164. return
  34165. }
  34166. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34167. if ioErr3 != nil {
  34168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34170. return
  34171. }
  34172. var respJSON3 map[string]interface{}
  34173. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34176. return
  34177. }
  34178. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34179. userJSONBytes3, _ := json.Marshal(respJSON3)
  34180. fmt.Println("log")
  34181. fmt.Println(string(userJSONBytes3))
  34182. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34183. utils.ErrorLog("解析失败:%v", err)
  34184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34185. return
  34186. }
  34187. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34188. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34189. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34190. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34191. resp3, requestErr3 := http.Get(api3)
  34192. if requestErr3 != nil {
  34193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34194. return
  34195. }
  34196. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34197. if ioErr3 != nil {
  34198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34200. return
  34201. }
  34202. var respJSON3 map[string]interface{}
  34203. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34206. return
  34207. }
  34208. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34209. userJSONBytes3, _ := json.Marshal(respJSON3)
  34210. fmt.Println("log")
  34211. fmt.Println(string(userJSONBytes3))
  34212. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34213. utils.ErrorLog("解析失败:%v", err)
  34214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34215. return
  34216. }
  34217. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34218. var api3 string
  34219. if miConfig.MdtrtareaAdmvs == "320830" {
  34220. api3 = miConfig.AppSecret + "jsyb/2202?psn_no=" + his.PsnNo +
  34221. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34222. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34223. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34224. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34225. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34226. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34227. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34228. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34229. } else {
  34230. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34231. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34232. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34233. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34234. }
  34235. resp3, requestErr3 := http.Get(api3)
  34236. if requestErr3 != nil {
  34237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34238. return
  34239. }
  34240. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34241. if ioErr3 != nil {
  34242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34244. return
  34245. }
  34246. var respJSON3 map[string]interface{}
  34247. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34250. return
  34251. }
  34252. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34253. userJSONBytes3, _ := json.Marshal(respJSON3)
  34254. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34255. utils.ErrorLog("解析失败:%v", err)
  34256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34257. return
  34258. }
  34259. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34260. res2.Output = resSix10265.Output
  34261. res2.ErrMsg = resSix10265.ErrMsg
  34262. res2.Cainfo = resSix10265.Cainfo
  34263. res2.WarnMsg = resSix10265.WarnMsg
  34264. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34265. res2.Infcode = infocode
  34266. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34267. var api3 string
  34268. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  34269. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34270. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34271. resp3, requestErr3 := http.Get(api3)
  34272. if requestErr3 != nil {
  34273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34274. return
  34275. }
  34276. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34277. if ioErr3 != nil {
  34278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34280. return
  34281. }
  34282. var respJSON3 map[string]interface{}
  34283. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34286. return
  34287. }
  34288. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34289. userJSONBytes3, _ := json.Marshal(respJSON3)
  34290. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34291. utils.ErrorLog("解析失败:%v", err)
  34292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34293. return
  34294. }
  34295. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34296. res2.Output = resSix10265.Output
  34297. res2.ErrMsg = resSix10265.ErrMsg
  34298. res2.Cainfo = resSix10265.Cainfo
  34299. res2.WarnMsg = resSix10265.WarnMsg
  34300. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34301. res2.Infcode = infocode
  34302. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34303. 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)
  34304. var dat map[string]interface{}
  34305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34306. fmt.Println(dat)
  34307. } else {
  34308. fmt.Println(err)
  34309. }
  34310. saveLog(result, request, "2202", "退号")
  34311. userJSONBytes, _ := json.Marshal(dat)
  34312. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34313. utils.ErrorLog("解析失败:%v", err)
  34314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34315. return
  34316. }
  34317. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34318. 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, "")
  34319. var dat map[string]interface{}
  34320. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34321. fmt.Println(dat)
  34322. } else {
  34323. fmt.Println(err)
  34324. }
  34325. saveLog(result, request, "2202", "退号")
  34326. userJSONBytes, _ := json.Marshal(dat)
  34327. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34328. utils.ErrorLog("解析失败:%v", err)
  34329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34330. return
  34331. }
  34332. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34333. 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, "")
  34334. var dat map[string]interface{}
  34335. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34336. fmt.Println(dat)
  34337. } else {
  34338. fmt.Println(err)
  34339. }
  34340. saveLog(result, request, "2202", "退号")
  34341. userJSONBytes, _ := json.Marshal(dat)
  34342. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34343. utils.ErrorLog("解析失败:%v", err)
  34344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34345. return
  34346. }
  34347. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34348. 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, "")
  34349. var dat map[string]interface{}
  34350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34351. fmt.Println(dat)
  34352. } else {
  34353. fmt.Println(err)
  34354. }
  34355. saveLog(result, request, "2202", "退号")
  34356. userJSONBytes, _ := json.Marshal(dat)
  34357. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34358. utils.ErrorLog("解析失败:%v", err)
  34359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34360. return
  34361. }
  34362. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34363. var api3 string
  34364. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34365. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34366. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34367. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34368. resp3, requestErr3 := http.Get(api3)
  34369. if requestErr3 != nil {
  34370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34371. return
  34372. }
  34373. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34374. if ioErr3 != nil {
  34375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34377. return
  34378. }
  34379. var respJSON3 map[string]interface{}
  34380. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34383. return
  34384. }
  34385. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34386. if status == "0" {
  34387. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34388. c.ServeSuccessJSON(map[string]interface{}{
  34389. "failed_code": -10,
  34390. "msg": err_msg,
  34391. })
  34392. return
  34393. }
  34394. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34395. userJSONBytes3, _ := json.Marshal(respJSON3)
  34396. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34397. utils.ErrorLog("解析失败:%v", err)
  34398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34399. return
  34400. }
  34401. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34402. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34403. var api3 string
  34404. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34405. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34406. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34407. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34408. resp3, requestErr3 := http.Get(api3)
  34409. if requestErr3 != nil {
  34410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34411. return
  34412. }
  34413. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34414. if ioErr3 != nil {
  34415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34417. return
  34418. }
  34419. var respJSON3 map[string]interface{}
  34420. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34423. return
  34424. }
  34425. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34426. if status == "0" {
  34427. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34428. c.ServeSuccessJSON(map[string]interface{}{
  34429. "failed_code": -10,
  34430. "msg": err_msg,
  34431. })
  34432. return
  34433. }
  34434. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34435. userJSONBytes3, _ := json.Marshal(respJSON3)
  34436. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34437. utils.ErrorLog("解析失败:%v", err)
  34438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34439. return
  34440. }
  34441. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34442. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34443. 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, "")
  34444. var dat map[string]interface{}
  34445. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34446. fmt.Println(dat)
  34447. } else {
  34448. fmt.Println(err)
  34449. }
  34450. saveLog(result, request, "2202", "退号")
  34451. userJSONBytes, _ := json.Marshal(dat)
  34452. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34453. utils.ErrorLog("解析失败:%v", err)
  34454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34455. return
  34456. }
  34457. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34458. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  34459. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34460. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34461. resp3, requestErr3 := http.Get(api3)
  34462. if requestErr3 != nil {
  34463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34464. return
  34465. }
  34466. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34467. if ioErr3 != nil {
  34468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34470. return
  34471. }
  34472. var respJSON3 map[string]interface{}
  34473. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34476. return
  34477. }
  34478. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34479. userJSONBytes3, _ := json.Marshal(respJSON3)
  34480. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34481. utils.ErrorLog("解析失败:%v", err)
  34482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34483. return
  34484. }
  34485. } else {
  34486. var api3 string
  34487. if miConfig.Code == "H15049901371" {
  34488. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  34489. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34490. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34491. } else {
  34492. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  34493. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34495. }
  34496. resp3, requestErr3 := http.Get(api3)
  34497. if requestErr3 != nil {
  34498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34499. return
  34500. }
  34501. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34502. if ioErr3 != nil {
  34503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34505. return
  34506. }
  34507. var respJSON3 map[string]interface{}
  34508. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34511. return
  34512. }
  34513. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34514. userJSONBytes3, _ := json.Marshal(respJSON3)
  34515. if miConfig.Code == "H15049901371" {
  34516. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34517. utils.ErrorLog("解析失败:%v", err)
  34518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34519. return
  34520. }
  34521. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34522. res2.Output = resSix10265.Output
  34523. res2.ErrMsg = resSix10265.ErrMsg
  34524. res2.Cainfo = resSix10265.Cainfo
  34525. res2.WarnMsg = resSix10265.WarnMsg
  34526. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34527. res2.Infcode = infocode
  34528. } else {
  34529. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34530. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  34531. utils.ErrorLog("解析失败:%v", err)
  34532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34533. return
  34534. }
  34535. res2.Infcode = res3.Infcode
  34536. } else {
  34537. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34538. utils.ErrorLog("解析失败:%v", err)
  34539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34540. return
  34541. }
  34542. }
  34543. }
  34544. }
  34545. if res2.Infcode == -1 {
  34546. c.ServeSuccessJSON(map[string]interface{}{
  34547. "failed_code": -10,
  34548. "msg": res2.ErrMsg,
  34549. })
  34550. return
  34551. }
  34552. if res2.Infcode == 0 {
  34553. if err == nil {
  34554. c.ServeSuccessJSON(map[string]interface{}{
  34555. "msg": "退号成功",
  34556. })
  34557. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  34558. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  34559. } else {
  34560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34561. return
  34562. }
  34563. }
  34564. } else {
  34565. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  34566. //if err == nil {
  34567. // c.ServeSuccessJSON(map[string]interface{}{
  34568. // "msg": "退费成功",
  34569. // })
  34570. //} else {
  34571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34572. // return
  34573. //}
  34574. }
  34575. }
  34576. func (c *HisApiController) RefundDetail() {
  34577. order_id, _ := c.GetInt64("order_id")
  34578. admin_user_id, _ := c.GetInt64("admin_user_id")
  34579. //his_patient_id, _ := c.GetInt64("his_patient_id")
  34580. number := c.GetString("number")
  34581. record_time := c.GetString("record_time")
  34582. patient_id, _ := c.GetInt64("patient_id")
  34583. //med_type, _ := c.GetInt64("med_type")
  34584. timeLayout := "2006-01-02"
  34585. loc, _ := time.LoadLocation("Local")
  34586. adminUser := c.GetAdminUserInfo()
  34587. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34588. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34589. fmt.Println(err)
  34590. if err != nil {
  34591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34592. return
  34593. }
  34594. recordDateTime := theTime.Unix()
  34595. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  34596. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34597. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34598. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34599. var order models.HisOrder
  34600. order, _ = service.GetHisOrderByID(order_id)
  34601. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34602. if config.IsOpen == 1 { //对接了医保,走医保流程
  34603. var res2 ResultSix
  34604. if miConfig.MdtrtareaAdmvs == "421300" {
  34605. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34606. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34607. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34608. resp3, requestErr3 := http.Get(api3)
  34609. if requestErr3 != nil {
  34610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34611. return
  34612. }
  34613. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34614. if ioErr3 != nil {
  34615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34617. return
  34618. }
  34619. var respJSON3 map[string]interface{}
  34620. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34623. return
  34624. }
  34625. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34626. userJSONBytes3, _ := json.Marshal(respJSON3)
  34627. fmt.Println("log")
  34628. fmt.Println(string(userJSONBytes3))
  34629. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34630. utils.ErrorLog("解析失败:%v", err)
  34631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34632. return
  34633. }
  34634. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34635. if err == nil {
  34636. c.ServeSuccessJSON(map[string]interface{}{
  34637. "msg": "撤销明细成功",
  34638. })
  34639. return
  34640. } else {
  34641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34642. return
  34643. }
  34644. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34645. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34646. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34647. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34648. resp3, requestErr3 := http.Get(api3)
  34649. if requestErr3 != nil {
  34650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34651. return
  34652. }
  34653. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34654. if ioErr3 != nil {
  34655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34657. return
  34658. }
  34659. var respJSON3 map[string]interface{}
  34660. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34663. return
  34664. }
  34665. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34666. userJSONBytes3, _ := json.Marshal(respJSON3)
  34667. fmt.Println("log")
  34668. fmt.Println(string(userJSONBytes3))
  34669. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34670. utils.ErrorLog("解析失败:%v", err)
  34671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34672. return
  34673. }
  34674. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34675. if err == nil {
  34676. c.ServeSuccessJSON(map[string]interface{}{
  34677. "msg": "撤销明细成功",
  34678. })
  34679. return
  34680. } else {
  34681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34682. return
  34683. }
  34684. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34685. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34686. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34687. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34688. resp3, requestErr3 := http.Get(api3)
  34689. if requestErr3 != nil {
  34690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34691. return
  34692. }
  34693. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34694. if ioErr3 != nil {
  34695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34697. return
  34698. }
  34699. var respJSON3 map[string]interface{}
  34700. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34703. return
  34704. }
  34705. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34706. userJSONBytes3, _ := json.Marshal(respJSON3)
  34707. fmt.Println("log")
  34708. fmt.Println(string(userJSONBytes3))
  34709. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34710. utils.ErrorLog("解析失败:%v", err)
  34711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34712. return
  34713. }
  34714. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34715. if err == nil {
  34716. c.ServeSuccessJSON(map[string]interface{}{
  34717. "msg": "撤销明细成功",
  34718. })
  34719. return
  34720. } else {
  34721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34722. return
  34723. }
  34724. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34725. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34726. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34727. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34728. resp3, requestErr3 := http.Get(api3)
  34729. if requestErr3 != nil {
  34730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34731. return
  34732. }
  34733. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34734. if ioErr3 != nil {
  34735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34737. return
  34738. }
  34739. var respJSON3 map[string]interface{}
  34740. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34743. return
  34744. }
  34745. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34746. userJSONBytes3, _ := json.Marshal(respJSON3)
  34747. fmt.Println("log")
  34748. fmt.Println(string(userJSONBytes3))
  34749. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34750. utils.ErrorLog("解析失败:%v", err)
  34751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34752. return
  34753. }
  34754. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34755. if err == nil {
  34756. c.ServeSuccessJSON(map[string]interface{}{
  34757. "msg": "撤销明细成功",
  34758. })
  34759. return
  34760. } else {
  34761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34762. return
  34763. }
  34764. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34765. var resSix10265 ResultSix10265
  34766. var api3 string
  34767. if miConfig.MdtrtareaAdmvs == "320830" {
  34768. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  34769. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34770. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34771. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34772. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34773. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34774. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34775. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34776. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34777. } else {
  34778. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34779. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34780. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34781. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34782. }
  34783. resp3, requestErr3 := http.Get(api3)
  34784. utils.ErrorLog("接口: %v", requestErr3)
  34785. if requestErr3 != nil {
  34786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34787. return
  34788. }
  34789. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34790. if ioErr3 != nil {
  34791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34793. return
  34794. }
  34795. var respJSON3 map[string]interface{}
  34796. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34799. return
  34800. }
  34801. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34802. userJSONBytes3, _ := json.Marshal(respJSON3)
  34803. fmt.Println("log")
  34804. fmt.Println(string(userJSONBytes3))
  34805. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34806. utils.ErrorLog("解析失败:%v", err)
  34807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34808. return
  34809. }
  34810. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34811. res2.Output = resSix10265.Output
  34812. res2.ErrMsg = resSix10265.ErrMsg
  34813. res2.Cainfo = resSix10265.Cainfo
  34814. res2.WarnMsg = resSix10265.WarnMsg
  34815. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34816. res2.Infcode = infocode
  34817. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34818. if err == nil {
  34819. c.ServeSuccessJSON(map[string]interface{}{
  34820. "msg": "撤销明细成功",
  34821. })
  34822. return
  34823. } else {
  34824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34825. return
  34826. }
  34827. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34828. var api3 string
  34829. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34830. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34831. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34832. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34833. resp3, requestErr3 := http.Get(api3)
  34834. utils.ErrorLog("接口: %v", requestErr3)
  34835. if requestErr3 != nil {
  34836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34837. return
  34838. }
  34839. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34840. if ioErr3 != nil {
  34841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34843. return
  34844. }
  34845. var respJSON3 map[string]interface{}
  34846. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34849. return
  34850. }
  34851. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34852. if status == "0" {
  34853. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34854. c.ServeSuccessJSON(map[string]interface{}{
  34855. "failed_code": -10,
  34856. "msg": err_msg,
  34857. })
  34858. return
  34859. }
  34860. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34861. userJSONBytes3, _ := json.Marshal(respJSON3)
  34862. fmt.Println("log")
  34863. fmt.Println(string(userJSONBytes3))
  34864. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34865. utils.ErrorLog("解析失败:%v", err)
  34866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34867. return
  34868. }
  34869. fmt.Println(res2.Infcode)
  34870. if res2.Infcode == -1 {
  34871. c.ServeSuccessJSON(map[string]interface{}{
  34872. "failed_code": -10,
  34873. "msg": res2.ErrMsg,
  34874. })
  34875. return
  34876. }
  34877. if res2.Infcode == 0 {
  34878. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34879. if err == nil {
  34880. c.ServeSuccessJSON(map[string]interface{}{
  34881. "msg": "撤销明细成功",
  34882. })
  34883. return
  34884. } else {
  34885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34886. return
  34887. }
  34888. } else {
  34889. c.ServeSuccessJSON(map[string]interface{}{
  34890. "failed_code": -10,
  34891. "msg": res2.ErrMsg,
  34892. })
  34893. }
  34894. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34895. if err == nil {
  34896. c.ServeSuccessJSON(map[string]interface{}{
  34897. "msg": "撤销明细成功",
  34898. })
  34899. return
  34900. } else {
  34901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34902. return
  34903. }
  34904. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34905. var api3 string
  34906. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34907. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34908. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34909. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34910. resp3, requestErr3 := http.Get(api3)
  34911. utils.ErrorLog("接口: %v", requestErr3)
  34912. if requestErr3 != nil {
  34913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34914. return
  34915. }
  34916. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34917. if ioErr3 != nil {
  34918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34920. return
  34921. }
  34922. var respJSON3 map[string]interface{}
  34923. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34926. return
  34927. }
  34928. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34929. if status == "0" {
  34930. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34931. c.ServeSuccessJSON(map[string]interface{}{
  34932. "failed_code": -10,
  34933. "msg": err_msg,
  34934. })
  34935. return
  34936. }
  34937. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34938. userJSONBytes3, _ := json.Marshal(respJSON3)
  34939. fmt.Println("log")
  34940. fmt.Println(string(userJSONBytes3))
  34941. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34942. utils.ErrorLog("解析失败:%v", err)
  34943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34944. return
  34945. }
  34946. fmt.Println(res2.Infcode)
  34947. if res2.Infcode == -1 {
  34948. c.ServeSuccessJSON(map[string]interface{}{
  34949. "failed_code": -10,
  34950. "msg": res2.ErrMsg,
  34951. })
  34952. return
  34953. }
  34954. if res2.Infcode == 0 {
  34955. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34956. if err == nil {
  34957. c.ServeSuccessJSON(map[string]interface{}{
  34958. "msg": "撤销明细成功",
  34959. })
  34960. return
  34961. } else {
  34962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34963. return
  34964. }
  34965. } else {
  34966. c.ServeSuccessJSON(map[string]interface{}{
  34967. "failed_code": -10,
  34968. "msg": res2.ErrMsg,
  34969. })
  34970. }
  34971. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34972. if err == nil {
  34973. c.ServeSuccessJSON(map[string]interface{}{
  34974. "msg": "撤销明细成功",
  34975. })
  34976. return
  34977. } else {
  34978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34979. return
  34980. }
  34981. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34982. var resSix10265 ResultSix10265
  34983. new_chrg_bchno := order.Number
  34984. if adminUser.CurrentOrgId == 10265 {
  34985. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  34986. new_chrg_bchno = "0000"
  34987. }
  34988. }
  34989. var api3 string
  34990. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  34991. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34992. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34993. resp3, requestErr3 := http.Get(api3)
  34994. if requestErr3 != nil {
  34995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34996. return
  34997. }
  34998. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34999. if ioErr3 != nil {
  35000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35002. return
  35003. }
  35004. var respJSON3 map[string]interface{}
  35005. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35008. return
  35009. }
  35010. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35011. userJSONBytes3, _ := json.Marshal(respJSON3)
  35012. fmt.Println("log")
  35013. fmt.Println(string(userJSONBytes3))
  35014. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  35015. utils.ErrorLog("解析失败:%v", err)
  35016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35017. return
  35018. }
  35019. res2.InfRefmsgid = resSix10265.InfRefmsgid
  35020. res2.Output = resSix10265.Output
  35021. res2.ErrMsg = resSix10265.ErrMsg
  35022. res2.Cainfo = resSix10265.Cainfo
  35023. res2.WarnMsg = resSix10265.WarnMsg
  35024. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35025. res2.Infcode = infocode
  35026. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35027. if err == nil {
  35028. c.ServeSuccessJSON(map[string]interface{}{
  35029. "msg": "撤销明细成功",
  35030. })
  35031. return
  35032. } else {
  35033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35034. return
  35035. }
  35036. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35037. 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)
  35038. var dat map[string]interface{}
  35039. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35040. fmt.Println(dat)
  35041. } else {
  35042. fmt.Println(err)
  35043. }
  35044. saveLog(result2, src_request, "2205", "撤销明细")
  35045. userJSONBytes, _ := json.Marshal(dat)
  35046. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35047. utils.ErrorLog("解析失败:%v", err)
  35048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35049. return
  35050. }
  35051. if res2.Infcode == 0 {
  35052. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35053. if err == nil {
  35054. c.ServeSuccessJSON(map[string]interface{}{
  35055. "msg": "撤销明细成功",
  35056. })
  35057. return
  35058. } else {
  35059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35060. return
  35061. }
  35062. } else {
  35063. c.ServeSuccessJSON(map[string]interface{}{
  35064. "failed_code": -10,
  35065. "msg": res2.ErrMsg,
  35066. })
  35067. }
  35068. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35069. 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, "")
  35070. var dat map[string]interface{}
  35071. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35072. fmt.Println(dat)
  35073. } else {
  35074. fmt.Println(err)
  35075. }
  35076. saveLog(result2, src_request, "2205", "撤销明细")
  35077. userJSONBytes, _ := json.Marshal(dat)
  35078. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35079. utils.ErrorLog("解析失败:%v", err)
  35080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35081. return
  35082. }
  35083. if res2.Infcode == 0 {
  35084. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35085. if err == nil {
  35086. c.ServeSuccessJSON(map[string]interface{}{
  35087. "msg": "撤销明细成功",
  35088. })
  35089. return
  35090. } else {
  35091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35092. return
  35093. }
  35094. } else {
  35095. c.ServeSuccessJSON(map[string]interface{}{
  35096. "failed_code": -10,
  35097. "msg": res2.ErrMsg,
  35098. })
  35099. }
  35100. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35101. 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, "")
  35102. var dat map[string]interface{}
  35103. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35104. fmt.Println(dat)
  35105. } else {
  35106. fmt.Println(err)
  35107. }
  35108. saveLog(result2, src_request, "2205", "撤销明细")
  35109. userJSONBytes, _ := json.Marshal(dat)
  35110. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35111. utils.ErrorLog("解析失败:%v", err)
  35112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35113. return
  35114. }
  35115. if res2.Infcode == 0 {
  35116. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35117. if err == nil {
  35118. c.ServeSuccessJSON(map[string]interface{}{
  35119. "msg": "撤销明细成功",
  35120. })
  35121. return
  35122. } else {
  35123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35124. return
  35125. }
  35126. } else {
  35127. c.ServeSuccessJSON(map[string]interface{}{
  35128. "failed_code": -10,
  35129. "msg": res2.ErrMsg,
  35130. })
  35131. }
  35132. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35133. 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, "")
  35134. var dat map[string]interface{}
  35135. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35136. fmt.Println(dat)
  35137. } else {
  35138. fmt.Println(err)
  35139. }
  35140. saveLog(result2, src_request, "2205", "撤销明细")
  35141. userJSONBytes, _ := json.Marshal(dat)
  35142. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35143. utils.ErrorLog("解析失败:%v", err)
  35144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35145. return
  35146. }
  35147. if res2.Infcode == 0 {
  35148. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35149. if err == nil {
  35150. c.ServeSuccessJSON(map[string]interface{}{
  35151. "msg": "撤销明细成功",
  35152. })
  35153. return
  35154. } else {
  35155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35156. return
  35157. }
  35158. } else {
  35159. c.ServeSuccessJSON(map[string]interface{}{
  35160. "failed_code": -10,
  35161. "msg": res2.ErrMsg,
  35162. })
  35163. }
  35164. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35165. 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, "")
  35166. var dat map[string]interface{}
  35167. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35168. fmt.Println(dat)
  35169. } else {
  35170. fmt.Println(err)
  35171. }
  35172. saveLog(result2, src_request, "2205", "撤销明细")
  35173. userJSONBytes, _ := json.Marshal(dat)
  35174. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35175. utils.ErrorLog("解析失败:%v", err)
  35176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35177. return
  35178. }
  35179. if res2.Infcode == 0 {
  35180. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35181. if err == nil {
  35182. c.ServeSuccessJSON(map[string]interface{}{
  35183. "msg": "撤销明细成功",
  35184. })
  35185. return
  35186. } else {
  35187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35188. return
  35189. }
  35190. } else {
  35191. c.ServeSuccessJSON(map[string]interface{}{
  35192. "failed_code": -10,
  35193. "msg": res2.ErrMsg,
  35194. })
  35195. }
  35196. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35197. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  35198. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35199. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35200. resp2, requestErr2 := http.Get(api2)
  35201. if requestErr2 != nil {
  35202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35203. return
  35204. }
  35205. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35206. if ioErr2 != nil {
  35207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35209. return
  35210. }
  35211. var respJSON2 map[string]interface{}
  35212. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35215. return
  35216. }
  35217. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35218. userJSONBytes3, _ := json.Marshal(respJSON2)
  35219. fmt.Println("log")
  35220. fmt.Println(string(userJSONBytes3))
  35221. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35222. utils.ErrorLog("解析失败:%v", err)
  35223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35224. return
  35225. }
  35226. if res2.Infcode == 0 {
  35227. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35228. if err == nil {
  35229. c.ServeSuccessJSON(map[string]interface{}{
  35230. "msg": "撤销明细成功",
  35231. })
  35232. return
  35233. } else {
  35234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35235. return
  35236. }
  35237. } else {
  35238. c.ServeSuccessJSON(map[string]interface{}{
  35239. "failed_code": -10,
  35240. "msg": res2.ErrMsg,
  35241. })
  35242. }
  35243. } else {
  35244. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  35245. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35246. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35247. resp2, requestErr2 := http.Get(api2)
  35248. if requestErr2 != nil {
  35249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35250. return
  35251. }
  35252. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35253. if ioErr2 != nil {
  35254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35256. return
  35257. }
  35258. var respJSON2 map[string]interface{}
  35259. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35262. return
  35263. }
  35264. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35265. userJSONBytes3, _ := json.Marshal(respJSON2)
  35266. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35267. utils.ErrorLog("解析失败:%v", err)
  35268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35269. return
  35270. }
  35271. if res2.Infcode == -1 {
  35272. c.ServeSuccessJSON(map[string]interface{}{
  35273. "failed_code": -10,
  35274. "msg": res2.ErrMsg,
  35275. })
  35276. return
  35277. } else {
  35278. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35279. if err == nil {
  35280. c.ServeSuccessJSON(map[string]interface{}{
  35281. "msg": "撤销明细成功",
  35282. })
  35283. return
  35284. } else {
  35285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35286. return
  35287. }
  35288. }
  35289. }
  35290. } else {
  35291. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35292. if err == nil {
  35293. c.ServeSuccessJSON(map[string]interface{}{
  35294. "msg": "退费成功",
  35295. })
  35296. } else {
  35297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35298. return
  35299. }
  35300. }
  35301. }
  35302. // 对账
  35303. func (c *HisApiController) GetCheckAccount() {
  35304. start_time := c.GetString("start_time")
  35305. end_time := c.GetString("end_time")
  35306. insutype := c.GetString("insutype")
  35307. clr_type := c.GetString("clr_type")
  35308. clr_org := c.GetString("clr_optins")
  35309. admin_user_id, _ := c.GetInt64("admin_user_id")
  35310. adminUser := c.GetAdminUserInfo()
  35311. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35312. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35313. if len(clr_org) == 0 {
  35314. clr_org = miConfig.InsuplcAdmdvs
  35315. }
  35316. timeLayout := "2006-01-02"
  35317. loc, _ := time.LoadLocation("Local")
  35318. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35319. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35320. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35321. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35322. fixmedins_setl_cnt := int64(len(orders))
  35323. var medfee_sumamt float64
  35324. var acct_pay float64
  35325. var fund_pay_sumamt float64
  35326. for _, item := range orders {
  35327. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35328. acct_pay = acct_pay + item.AcctPay
  35329. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  35330. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  35331. } else {
  35332. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35333. }
  35334. }
  35335. var user_name string
  35336. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35337. if role.ID == 0 {
  35338. user_name = "xxx"
  35339. } else {
  35340. user_name = role.UserName
  35341. }
  35342. var res ResultEight
  35343. var res10188 ResultEightFor10188
  35344. if config.IsOpen == 1 {
  35345. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  35346. api := miConfig.AppSecret + "jsyb/3201?" +
  35347. "insutype=" + insutype +
  35348. "&clr_type=" + clr_type +
  35349. "&setl_optins=" + clr_org +
  35350. "&stmt_begndate=" + start_time +
  35351. "&stm_enddate=" + end_time +
  35352. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35353. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35354. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35355. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35356. "&fixmedins_code=" + miConfig.Code +
  35357. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35358. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35359. "&secret_key=" + miConfig.SecretKey +
  35360. "&org_name=" + miConfig.OrgName +
  35361. "&doctor=" + user_name +
  35362. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35363. fmt.Println(api)
  35364. resp, requestErr := http.Get(api)
  35365. if requestErr != nil {
  35366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35367. return
  35368. }
  35369. body, ioErr := ioutil.ReadAll(resp.Body)
  35370. fmt.Println(body)
  35371. if ioErr != nil {
  35372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35374. return
  35375. }
  35376. var respJSON map[string]interface{}
  35377. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35380. return
  35381. }
  35382. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35383. userJSONBytes, _ := json.Marshal(respJSON)
  35384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35385. utils.ErrorLog("解析失败:%v", err)
  35386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35387. return
  35388. }
  35389. res.InfRefmsgid = res10188.InfRefmsgid
  35390. res.Output = res10188.Output
  35391. res.ErrMsg = res10188.ErrMsg
  35392. res.Cainfo = res10188.Cainfo
  35393. res.WarnMsg = res10188.WarnMsg
  35394. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35395. res.Infcode = infocode
  35396. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35397. if clr_type != "9903" {
  35398. clr_type = "99" // 就诊 ID(来自2201接口返回)
  35399. }
  35400. if clr_type == "9903" {
  35401. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  35402. }
  35403. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  35404. "insutype=" + insutype +
  35405. "&clr_type=" + clr_type +
  35406. "&setl_optins=" + clr_org +
  35407. "&stmt_begndate=" + start_time +
  35408. "&stm_enddate=" + end_time +
  35409. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35410. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35411. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35412. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35413. "&fixmedins_code=" + miConfig.Code +
  35414. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35415. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35416. "&secret_key=" + miConfig.SecretKey +
  35417. "&org_name=" + miConfig.OrgName +
  35418. "&doctor=" + user_name
  35419. resp, requestErr := http.Get(api)
  35420. if requestErr != nil {
  35421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35422. return
  35423. }
  35424. body, ioErr := ioutil.ReadAll(resp.Body)
  35425. if ioErr != nil {
  35426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35428. return
  35429. }
  35430. var respJSON map[string]interface{}
  35431. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35434. return
  35435. }
  35436. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35437. result, _ := json.Marshal(respJSON)
  35438. fmt.Println("log")
  35439. fmt.Println(string(result))
  35440. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  35441. utils.ErrorLog("解析失败:%v", err)
  35442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35443. return
  35444. }
  35445. res.InfRefmsgid = res10188.InfRefmsgid
  35446. res.Output = res10188.Output
  35447. res.ErrMsg = res10188.ErrMsg
  35448. res.Cainfo = res10188.Cainfo
  35449. res.WarnMsg = res10188.WarnMsg
  35450. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35451. res.Infcode = infocode
  35452. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35453. var baseParams models.BaseParams
  35454. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35455. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35456. baseParams.SecretKey = miConfig.SecretKey
  35457. baseParams.OrgName = miConfig.OrgName
  35458. baseParams.FixmedinsCode = miConfig.Code
  35459. baseParams.EncKey = miConfig.EncKey
  35460. baseParams.AppSecret = miConfig.AppSecret
  35461. baseParams.SignKey = miConfig.SignKey
  35462. baseParams.AppID = miConfig.Code
  35463. baseParams.Doctor = role.UserName
  35464. baseParams.RequestUrl = miConfig.Url
  35465. businessParams := models.BusinessParams{
  35466. Insutype: insutype,
  35467. ClrType: clr_type,
  35468. SetlOptins: clr_org,
  35469. StmtBegndate: start_time,
  35470. StmtEnddate: end_time,
  35471. MedfeeSumamt: medfee_sumamt,
  35472. FundPaySumamt: fund_pay_sumamt,
  35473. AcctPay: acct_pay,
  35474. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35475. }
  35476. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35477. fmt.Println(requestLog)
  35478. fmt.Println(result)
  35479. fmt.Println(err_msg)
  35480. var dat map[string]interface{}
  35481. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35482. fmt.Println(dat)
  35483. } else {
  35484. fmt.Println(err)
  35485. }
  35486. userJSONBytes, _ := json.Marshal(dat)
  35487. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35488. utils.ErrorLog("解析失败:%v", err)
  35489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35490. return
  35491. }
  35492. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35493. var baseParams models.BaseParams
  35494. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35495. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35496. baseParams.SecretKey = miConfig.SecretKey
  35497. baseParams.OrgName = miConfig.OrgName
  35498. baseParams.FixmedinsCode = miConfig.Code
  35499. baseParams.EncKey = miConfig.EncKey
  35500. baseParams.AppSecret = miConfig.AppSecret
  35501. baseParams.SignKey = miConfig.SignKey
  35502. baseParams.AppID = miConfig.Code
  35503. baseParams.Doctor = role.UserName
  35504. baseParams.RequestUrl = miConfig.Url
  35505. baseParams.AccessKey = miConfig.AccessKey
  35506. businessParams := models.BusinessParams{
  35507. Insutype: insutype,
  35508. ClrType: clr_type,
  35509. SetlOptins: "430822",
  35510. StmtBegndate: start_time,
  35511. StmtEnddate: end_time,
  35512. MedfeeSumamt: medfee_sumamt,
  35513. FundPaySumamt: fund_pay_sumamt,
  35514. AcctPay: acct_pay,
  35515. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35516. }
  35517. 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)
  35518. fmt.Println(requestLog)
  35519. fmt.Println(result)
  35520. var dat map[string]interface{}
  35521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35522. fmt.Println(dat)
  35523. } else {
  35524. fmt.Println(err)
  35525. }
  35526. userJSONBytes, _ := json.Marshal(dat)
  35527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35528. utils.ErrorLog("解析失败:%v", err)
  35529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35530. return
  35531. }
  35532. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35533. var baseParams models.BaseParams
  35534. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35535. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35536. baseParams.SecretKey = miConfig.SecretKey
  35537. baseParams.OrgName = miConfig.OrgName
  35538. baseParams.FixmedinsCode = miConfig.Code
  35539. baseParams.EncKey = miConfig.EncKey
  35540. baseParams.AppSecret = miConfig.AppSecret
  35541. baseParams.SignKey = miConfig.SignKey
  35542. baseParams.AppID = miConfig.Code
  35543. baseParams.Doctor = role.UserName
  35544. baseParams.RequestUrl = miConfig.Url
  35545. businessParams := models.BusinessParams{
  35546. Insutype: insutype,
  35547. ClrType: clr_type,
  35548. SetlOptins: clr_org,
  35549. StmtBegndate: start_time,
  35550. StmtEnddate: end_time,
  35551. MedfeeSumamt: medfee_sumamt,
  35552. FundPaySumamt: fund_pay_sumamt,
  35553. AcctPay: acct_pay,
  35554. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35555. }
  35556. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35557. fmt.Println(requestLog)
  35558. fmt.Println(result)
  35559. fmt.Println(err_msg)
  35560. var dat map[string]interface{}
  35561. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35562. fmt.Println(dat)
  35563. } else {
  35564. fmt.Println(err)
  35565. }
  35566. userJSONBytes, _ := json.Marshal(dat)
  35567. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35568. utils.ErrorLog("解析失败:%v", err)
  35569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35570. return
  35571. }
  35572. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35573. if len(clr_type) == 0 {
  35574. clr_type = "11"
  35575. }
  35576. api := miConfig.Url + "gdyb/ten?" +
  35577. "insutype=" + insutype +
  35578. "&clr_type=" + clr_type +
  35579. "&setl_optins=" + clr_org +
  35580. "&stmt_begndate=" + start_time +
  35581. "&stm_enddate=" + end_time +
  35582. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35583. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35584. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35585. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35586. "&fixmedins_code=" + miConfig.Code +
  35587. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35588. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35589. "&secret_key=" + miConfig.SecretKey +
  35590. "&org_name=" + miConfig.OrgName +
  35591. "&doctor=" + user_name
  35592. fmt.Println(api)
  35593. resp, requestErr := http.Get(api)
  35594. if requestErr != nil {
  35595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35596. return
  35597. }
  35598. body, ioErr := ioutil.ReadAll(resp.Body)
  35599. fmt.Println(body)
  35600. if ioErr != nil {
  35601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35603. return
  35604. }
  35605. var respJSON map[string]interface{}
  35606. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35609. return
  35610. }
  35611. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35612. userJSONBytes, _ := json.Marshal(respJSON)
  35613. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35614. utils.ErrorLog("解析失败:%v", err)
  35615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35616. return
  35617. }
  35618. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35619. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35620. //fixmedins_setl_cnt := int64(len(orders_two))
  35621. //var medfee_sumamt float64
  35622. //var acct_pay float64
  35623. //var fund_pay_sumamt float64
  35624. //for _, item := range orders_two {
  35625. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35626. // acct_pay = acct_pay + item.AcctPay
  35627. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35628. //}
  35629. var baseParams models.BaseParams
  35630. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35631. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35632. baseParams.SecretKey = miConfig.SecretKey
  35633. baseParams.OrgName = miConfig.OrgName
  35634. baseParams.FixmedinsCode = miConfig.Code
  35635. baseParams.EncKey = miConfig.EncKey
  35636. baseParams.AppSecret = miConfig.AppSecret
  35637. baseParams.SignKey = miConfig.SignKey
  35638. baseParams.AppID = miConfig.Code
  35639. baseParams.Doctor = role.UserName
  35640. baseParams.RequestUrl = miConfig.Url
  35641. businessParams := models.BusinessParams{
  35642. Insutype: insutype,
  35643. ClrType: clr_type,
  35644. SetlOptins: "360102",
  35645. StmtBegndate: start_time,
  35646. StmtEnddate: end_time,
  35647. MedfeeSumamt: 0,
  35648. FundPaySumamt: 0,
  35649. AcctPay: 0,
  35650. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35651. }
  35652. 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))
  35653. fmt.Println(requestLog)
  35654. fmt.Println(result)
  35655. var dat map[string]interface{}
  35656. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35657. fmt.Println(dat)
  35658. } else {
  35659. fmt.Println(err)
  35660. }
  35661. userJSONBytes, _ := json.Marshal(dat)
  35662. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35663. utils.ErrorLog("解析失败:%v", err)
  35664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35665. return
  35666. }
  35667. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35668. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35669. //fixmedins_setl_cnt := int64(len(orders_two))
  35670. //var medfee_sumamt float64
  35671. //var acct_pay float64
  35672. //var fund_pay_sumamt float64
  35673. //for _, item := range orders_two {
  35674. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35675. // acct_pay = acct_pay + item.AcctPay
  35676. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35677. //}
  35678. var baseParams models.BaseParams
  35679. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35680. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35681. baseParams.SecretKey = miConfig.SecretKey
  35682. baseParams.OrgName = miConfig.OrgName
  35683. baseParams.FixmedinsCode = miConfig.Code
  35684. baseParams.EncKey = miConfig.EncKey
  35685. baseParams.AppSecret = miConfig.AppSecret
  35686. baseParams.SignKey = miConfig.SignKey
  35687. baseParams.AppID = miConfig.Code
  35688. baseParams.Doctor = role.UserName
  35689. baseParams.RequestUrl = miConfig.Url
  35690. if clr_type == "9903" {
  35691. clr_type = "9994"
  35692. }
  35693. businessParams := models.BusinessParams{
  35694. Insutype: insutype,
  35695. ClrType: clr_type,
  35696. SetlOptins: "361025",
  35697. StmtBegndate: start_time,
  35698. StmtEnddate: end_time,
  35699. MedfeeSumamt: 0,
  35700. FundPaySumamt: 0,
  35701. AcctPay: 0,
  35702. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35703. }
  35704. result, requestLog := service.Jxyb32012(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))
  35705. fmt.Println(requestLog)
  35706. fmt.Println(result)
  35707. var dat map[string]interface{}
  35708. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35709. fmt.Println(dat)
  35710. } else {
  35711. fmt.Println(err)
  35712. }
  35713. userJSONBytes, _ := json.Marshal(dat)
  35714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35715. utils.ErrorLog("解析失败:%v", err)
  35716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35717. return
  35718. }
  35719. } else if miConfig.MdtrtareaAdmvs == "360106" {
  35720. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35721. //fixmedins_setl_cnt := int64(len(orders_two))
  35722. //var medfee_sumamt float64
  35723. //var acct_pay float64
  35724. //var fund_pay_sumamt float64
  35725. //for _, item := range orders_two {
  35726. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35727. // acct_pay = acct_pay + item.AcctPay
  35728. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35729. //}
  35730. var baseParams models.BaseParams
  35731. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35732. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35733. baseParams.SecretKey = miConfig.SecretKey
  35734. baseParams.OrgName = miConfig.OrgName
  35735. baseParams.FixmedinsCode = miConfig.Code
  35736. baseParams.EncKey = miConfig.EncKey
  35737. baseParams.AppSecret = miConfig.AppSecret
  35738. baseParams.SignKey = miConfig.SignKey
  35739. baseParams.AppID = miConfig.Code
  35740. baseParams.Doctor = role.UserName
  35741. baseParams.RequestUrl = miConfig.Url
  35742. if clr_type == "9903" {
  35743. clr_type = "9994"
  35744. }
  35745. businessParams := models.BusinessParams{
  35746. Insutype: insutype,
  35747. ClrType: clr_type,
  35748. SetlOptins: "360102",
  35749. StmtBegndate: start_time,
  35750. StmtEnddate: end_time,
  35751. MedfeeSumamt: 0,
  35752. FundPaySumamt: 0,
  35753. AcctPay: 0,
  35754. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35755. }
  35756. result, requestLog := service.Jxyb32012(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))
  35757. fmt.Println(requestLog)
  35758. fmt.Println(result)
  35759. var dat map[string]interface{}
  35760. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35761. fmt.Println(dat)
  35762. } else {
  35763. fmt.Println(err)
  35764. }
  35765. userJSONBytes, _ := json.Marshal(dat)
  35766. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35767. utils.ErrorLog("解析失败:%v", err)
  35768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35769. return
  35770. }
  35771. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35772. var api string
  35773. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35774. "&clr_type=" + clr_type +
  35775. "&setl_optins=" + clr_org +
  35776. "&stmt_begndate=" + start_time +
  35777. "&stm_enddate=" + end_time +
  35778. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35779. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35780. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35781. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35782. "&fixmedins_code=" + miConfig.Code +
  35783. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35784. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35785. "&secret_key=" + miConfig.SecretKey +
  35786. "&org_name=" + miConfig.OrgName +
  35787. "&doctor=" + user_name + "&url=" + miConfig.Url
  35788. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35789. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35790. resp, requestErr := http.Get(api)
  35791. if requestErr != nil {
  35792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35793. return
  35794. }
  35795. body, ioErr := ioutil.ReadAll(resp.Body)
  35796. if ioErr != nil {
  35797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35799. return
  35800. }
  35801. var respJSON map[string]interface{}
  35802. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35805. return
  35806. }
  35807. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35808. if status == "0" {
  35809. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35810. c.ServeSuccessJSON(map[string]interface{}{
  35811. "failed_code": -10,
  35812. "msg": err_msg,
  35813. })
  35814. return
  35815. }
  35816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35817. userJSONBytes, _ := json.Marshal(respJSON)
  35818. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35819. utils.ErrorLog("解析失败:%v", err)
  35820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35821. return
  35822. }
  35823. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35824. var api string
  35825. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35826. "&clr_type=" + clr_type +
  35827. "&setl_optins=" + clr_org +
  35828. "&stmt_begndate=" + start_time +
  35829. "&stm_enddate=" + end_time +
  35830. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35831. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35832. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35833. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35834. "&fixmedins_code=" + miConfig.Code +
  35835. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35836. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35837. "&secret_key=" + miConfig.SecretKey +
  35838. "&org_name=" + miConfig.OrgName +
  35839. "&doctor=" + user_name + "&url=" + miConfig.Url
  35840. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35841. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35842. resp, requestErr := http.Get(api)
  35843. if requestErr != nil {
  35844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35845. return
  35846. }
  35847. body, ioErr := ioutil.ReadAll(resp.Body)
  35848. if ioErr != nil {
  35849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35851. return
  35852. }
  35853. var respJSON map[string]interface{}
  35854. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35857. return
  35858. }
  35859. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35860. if status == "0" {
  35861. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35862. c.ServeSuccessJSON(map[string]interface{}{
  35863. "failed_code": -10,
  35864. "msg": err_msg,
  35865. })
  35866. return
  35867. }
  35868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35869. userJSONBytes, _ := json.Marshal(respJSON)
  35870. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35871. utils.ErrorLog("解析失败:%v", err)
  35872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35873. return
  35874. }
  35875. } else {
  35876. if len(clr_type) == 0 {
  35877. clr_type = "11"
  35878. }
  35879. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35880. "insutype=" + insutype +
  35881. "&clr_type=" + clr_type +
  35882. "&setl_optins=" + clr_org +
  35883. "&stmt_begndate=" + start_time +
  35884. "&stm_enddate=" + end_time +
  35885. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35886. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35887. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35888. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35889. "&fixmedins_code=" + miConfig.Code +
  35890. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35891. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35892. "&secret_key=" + miConfig.SecretKey +
  35893. "&org_name=" + miConfig.OrgName +
  35894. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35895. fmt.Println(api)
  35896. resp, requestErr := http.Get(api)
  35897. if requestErr != nil {
  35898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35899. return
  35900. }
  35901. body, ioErr := ioutil.ReadAll(resp.Body)
  35902. fmt.Println(body)
  35903. if ioErr != nil {
  35904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35906. return
  35907. }
  35908. var respJSON map[string]interface{}
  35909. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35912. return
  35913. }
  35914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35915. userJSONBytes, _ := json.Marshal(respJSON)
  35916. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35917. utils.ErrorLog("解析失败:%v", err)
  35918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35919. return
  35920. }
  35921. }
  35922. if res.Infcode == 0 {
  35923. if res.Output.Stmtinfo.StmtRslt == "0" {
  35924. micc := &models.MedicalInsuranceCostCompare{
  35925. StartTime: startime.Unix(),
  35926. EndTime: endtime.Unix(),
  35927. Insutype: insutype,
  35928. CheckType: 1,
  35929. Num: fixmedins_setl_cnt,
  35930. Mtime: time.Now().Unix(),
  35931. Status: 1,
  35932. UserOrgId: adminUser.CurrentOrgId,
  35933. CostTotal: medfee_sumamt,
  35934. FuncTotal: fund_pay_sumamt,
  35935. PsnPay: acct_pay,
  35936. Creator: admin_user_id,
  35937. Ctime: time.Now().Unix(),
  35938. ClrType: clr_type,
  35939. }
  35940. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  35941. if err == nil {
  35942. c.ServeSuccessJSON(map[string]interface{}{
  35943. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35944. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35945. })
  35946. } else {
  35947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35948. }
  35949. } else {
  35950. c.ServeSuccessJSON(map[string]interface{}{
  35951. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35952. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35953. })
  35954. }
  35955. } else {
  35956. c.ServeSuccessJSON(map[string]interface{}{
  35957. "failed_code": -10,
  35958. "msg": res.ErrMsg,
  35959. })
  35960. }
  35961. }
  35962. }
  35963. func (c *HisApiController) Check310() {
  35964. adminUser := c.GetAdminUserInfo()
  35965. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35966. var user_name string
  35967. user_name = "高慧裕"
  35968. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35969. "insutype=" + "310" +
  35970. "&clr_type=" + "" +
  35971. "&setl_optins=" + "441202" +
  35972. "&stmt_begndate=" + "2022-03-01" +
  35973. "&stm_enddate=" + "2022-03-31" +
  35974. "&medfee_sumamt=" + "194930.12" +
  35975. "&fund_pay_sumamt=" + "188741.46" +
  35976. "&acct_pay=" + "0" +
  35977. "&fixmedins_setl_cnt=" + "452" +
  35978. "&fixmedins_code=" + miConfig.Code +
  35979. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35980. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35981. "&secret_key=" + miConfig.SecretKey +
  35982. "&org_name=" + miConfig.OrgName +
  35983. "&doctor=" + user_name
  35984. fmt.Println(api)
  35985. resp, requestErr := http.Get(api)
  35986. if requestErr != nil {
  35987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35988. return
  35989. }
  35990. body, ioErr := ioutil.ReadAll(resp.Body)
  35991. fmt.Println(body)
  35992. if ioErr != nil {
  35993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35995. return
  35996. }
  35997. var respJSON map[string]interface{}
  35998. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36001. return
  36002. }
  36003. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36004. userJSONBytes, _ := json.Marshal(respJSON)
  36005. var res ResultEight
  36006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36007. utils.ErrorLog("解析失败:%v", err)
  36008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36009. return
  36010. }
  36011. }
  36012. func (c *HisApiController) Check390() {
  36013. adminUser := c.GetAdminUserInfo()
  36014. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36015. var user_name string
  36016. user_name = "高慧裕"
  36017. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  36018. "insutype=" + "390" +
  36019. "&clr_type=" + "" +
  36020. "&setl_optins=" + "441202" +
  36021. "&stmt_begndate=" + "2022-03-01" +
  36022. "&stm_enddate=" + "2022-03-31" +
  36023. "&medfee_sumamt=" + "1068448.89" +
  36024. "&fund_pay_sumamt=" + "1014677.62" +
  36025. "&acct_pay=" + "0" +
  36026. "&fixmedins_setl_cnt=" + "1950" +
  36027. "&fixmedins_code=" + miConfig.Code +
  36028. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36029. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36030. "&secret_key=" + miConfig.SecretKey +
  36031. "&org_name=" + miConfig.OrgName +
  36032. "&doctor=" + user_name
  36033. fmt.Println(api)
  36034. resp, requestErr := http.Get(api)
  36035. if requestErr != nil {
  36036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36037. return
  36038. }
  36039. body, ioErr := ioutil.ReadAll(resp.Body)
  36040. fmt.Println(body)
  36041. if ioErr != nil {
  36042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36044. return
  36045. }
  36046. var respJSON map[string]interface{}
  36047. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36050. return
  36051. }
  36052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36053. userJSONBytes, _ := json.Marshal(respJSON)
  36054. var res ResultEight
  36055. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36056. utils.ErrorLog("解析失败:%v", err)
  36057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36058. return
  36059. }
  36060. }
  36061. // 对账明细
  36062. func (c *HisApiController) GetCheckDetailAccount() {
  36063. start_time := c.GetString("start_time")
  36064. end_time := c.GetString("end_time")
  36065. admin_user_id, _ := c.GetInt64("admin_user_id")
  36066. adminUser := c.GetAdminUserInfo()
  36067. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36068. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36069. timeLayout := "2006-01-02"
  36070. loc, _ := time.LoadLocation("Local")
  36071. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  36072. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  36073. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36074. rand.Seed(time.Now().UnixNano())
  36075. num := rand.Intn(30000)
  36076. Mkdir(miConfig.OrgName)
  36077. file := strconv.FormatInt(int64(num), 10)
  36078. file_name := file + ".txt"
  36079. zip_name := file + ".zip"
  36080. zip_path := miConfig.OrgName + "/" + zip_name
  36081. file_path := miConfig.OrgName + "/" + file_name
  36082. decimal.DivisionPrecision = 2
  36083. var medfee_sumamt float64
  36084. var psn_cash_pay float64
  36085. var fund_pay_sumamt float64
  36086. fixmedins_setl_cnt := int64(len(orders))
  36087. for _, item := range orders {
  36088. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  36089. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  36090. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  36091. }
  36092. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  36093. defer f.Close()
  36094. if err != nil {
  36095. fmt.Println(err.Error())
  36096. } else {
  36097. for _, item := range orders {
  36098. var refd_setl_flag string
  36099. if item.OrderStatus == 2 {
  36100. refd_setl_flag = "0"
  36101. var str string
  36102. str = item.SetlId + " " +
  36103. item.MdtrtId + " " +
  36104. item.PsnNo + " " +
  36105. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  36106. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  36107. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  36108. _, err = f.Write([]byte(str))
  36109. }
  36110. if item.OrderStatus == 3 {
  36111. var str string
  36112. str = item.SetlId + " " +
  36113. item.MdtrtId + " " +
  36114. item.PsnNo + " " +
  36115. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  36116. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  36117. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  36118. _, err = f.Write([]byte(str))
  36119. var str2 string
  36120. str2 = item.SetlId + " " +
  36121. item.MdtrtId + " " +
  36122. item.PsnNo + " " +
  36123. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  36124. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  36125. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  36126. _, err = f.Write([]byte(str2))
  36127. }
  36128. }
  36129. }
  36130. Zip(file_path, zip_path)
  36131. fmt.Println(ReadFile(zip_path))
  36132. fmt.Println(string(ReadFile(zip_path)))
  36133. if config.IsOpen == 1 {
  36134. var user_name string
  36135. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36136. if role.ID == 0 {
  36137. user_name = "管理员"
  36138. } else {
  36139. user_name = role.UserName
  36140. }
  36141. baseParams := models.BaseParams{
  36142. SecretKey: miConfig.SecretKey,
  36143. FixmedinsCode: miConfig.Code,
  36144. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36145. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36146. OrgName: miConfig.OrgName,
  36147. Doctor: user_name,
  36148. }
  36149. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  36150. var dat map[string]interface{}
  36151. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36152. fmt.Println(dat)
  36153. } else {
  36154. fmt.Println(err)
  36155. }
  36156. userJSONBytes, _ := json.Marshal(dat)
  36157. var res ResultNine
  36158. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36159. utils.ErrorLog("解析失败:%v", err)
  36160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36161. return
  36162. }
  36163. if res.Infcode == 0 {
  36164. fileNo := res.Output.FileQuryNo
  36165. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  36166. "file_qury_no=" + fileNo +
  36167. "&setl_optins=" + "定点医保中心" +
  36168. "&stmt_begndate=" + start_time +
  36169. "&stm_enddate=" + end_time +
  36170. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36171. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36172. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  36173. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  36174. "&fixmedins_code=" + miConfig.Code +
  36175. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36176. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36177. "&secret_key=" + miConfig.SecretKey +
  36178. "&org_name=" + miConfig.OrgName +
  36179. "&doctor=" + user_name
  36180. resp, requestErr := http.Get(api)
  36181. if requestErr != nil {
  36182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36183. return
  36184. }
  36185. body, ioErr := ioutil.ReadAll(resp.Body)
  36186. if ioErr != nil {
  36187. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36189. return
  36190. }
  36191. var respJSON map[string]interface{}
  36192. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36195. return
  36196. }
  36197. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36198. userJSONBytes, _ := json.Marshal(respJSON)
  36199. var res ResultTen
  36200. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36201. utils.ErrorLog("解析失败:%v", err)
  36202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36203. return
  36204. }
  36205. if res.Infcode == 0 {
  36206. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  36207. micc := &models.MedicalInsuranceCostCompare{
  36208. StartTime: startime.Unix(),
  36209. EndTime: endtime.Unix(),
  36210. Insutype: "0",
  36211. CheckType: 2,
  36212. Num: fixmedins_setl_cnt,
  36213. Mtime: time.Now().Unix(),
  36214. Status: 1,
  36215. UserOrgId: adminUser.CurrentOrgId,
  36216. CostTotal: medfee_sumamt,
  36217. FuncTotal: fund_pay_sumamt,
  36218. PsnPay: psn_cash_pay,
  36219. Creator: admin_user_id,
  36220. Ctime: time.Now().Unix(),
  36221. }
  36222. service.CreateMedicalInsuranceCostCompareRecord(micc)
  36223. c.ServeSuccessJSON(map[string]interface{}{
  36224. "msg": "明细对账成功",
  36225. })
  36226. }
  36227. } else {
  36228. }
  36229. }
  36230. }
  36231. type CustomOrderInfo struct {
  36232. Name string
  36233. Spec string
  36234. Unit string
  36235. Count float64
  36236. Price float64
  36237. Total float64
  36238. }
  36239. func (c *HisApiController) GetBatchSettleAccounts() {
  36240. admin_user_id, _ := c.GetInt64("admin_user_id")
  36241. order_ids := c.GetString("order_ids")
  36242. order_ids_arr := strings.Split(order_ids, ",")
  36243. data3 := []map[string]interface{}{}
  36244. for _, item := range order_ids_arr {
  36245. id, _ := strconv.ParseInt(item, 10, 64)
  36246. order_id := id
  36247. adminUser := c.GetAdminUserInfo()
  36248. order, _ := service.GetHisOrderByID(order_id)
  36249. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36250. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36251. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36252. orderInfos = append(orderInfos, orderInfos_two...)
  36253. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36254. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36255. var diagnosis_ids []string
  36256. if his.ID > 0 {
  36257. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36258. } else {
  36259. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36260. }
  36261. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36262. var dia_config []*models.HisXtDiagnoseConfig
  36263. var name string
  36264. for _, item := range diagnosis_ids {
  36265. id, _ := strconv.ParseInt(item, 10, 64)
  36266. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36267. dia_config = append(dia_config, &diagnosisConfig)
  36268. if len(name) == 0 {
  36269. name = diagnosisConfig.ClassName
  36270. }
  36271. //} else {
  36272. // name = name + "," + diagnosisConfig.ClassName
  36273. //}
  36274. }
  36275. var bedCostTotal float64 = 0 //床位总费
  36276. var bedCostSelfTotal float64 = 0 //床位自费
  36277. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36278. var bedSelfTotal float64 = 0 //床位部分项目自费
  36279. var bedInscpTotal float64 = 0 //床位部分项目自费
  36280. var operationCostTotal float64 = 0 //手术费
  36281. var operationCostSelfTotal float64 = 0 //手术费
  36282. var operationCostPartSelfTotal float64 = 0 //手术费
  36283. var operationSelfTotal float64 = 0 //床位部分项目自费
  36284. var operationInscpTotal float64 = 0 //床位部分项目自费
  36285. var otherCostTotal float64 = 0 //其他费用
  36286. var otherCostSelfTotal float64 = 0 //其他费用
  36287. var otherCostPartSelfTotal float64 = 0 //其他费用
  36288. var otherSelfTotal float64 = 0 //床位部分项目自费
  36289. var otherInscpTotal float64 = 0 //床位部分项目自费
  36290. var materialCostTotal float64 = 0 //材料费
  36291. var materialCostSelfTotal float64 = 0 //材料费
  36292. var materialCostPartSelfTotal float64 = 0 //材料费
  36293. var materialSelfTotal float64 = 0 //床位部分项目自费
  36294. var materialInscpTotal float64 = 0 //床位部分项目自费
  36295. var westernMedicineCostTotal float64 = 0 //西药费
  36296. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36297. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36298. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36299. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36300. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36301. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36302. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36303. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36304. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36305. var checkCostTotal float64 = 0 //检查费
  36306. var checkCostSelfTotal float64 = 0 //检查费
  36307. var checkCostPartSelfTotal float64 = 0 //检查费
  36308. var checkSelfTotal float64 = 0 //床位部分项目自费
  36309. var checkInscpTotal float64 = 0 //床位部分项目自费
  36310. var laboratoryCostTotal float64 = 0 //化验费
  36311. var laboratoryCostSelfTotal float64 = 0 //化验费
  36312. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36313. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36314. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36315. var treatCostTotal float64 = 0 //治疗费用
  36316. var treatCostSelfTotal float64 = 0 //治疗费用
  36317. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36318. var treatSelfTotal float64 = 0 //床位部分项目自费
  36319. var treatInscpTotal float64 = 0 //床位部分项目自费
  36320. decimal.DivisionPrecision = 2
  36321. for _, item := range orderInfos {
  36322. if item.MedChrgitmType == "01" { //床位费
  36323. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36324. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36325. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36326. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36327. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36328. }
  36329. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36330. if item.MedChrgitmType == "03" { //检查费
  36331. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36332. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36333. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36334. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36335. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36336. }
  36337. } else {
  36338. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36339. fmt.Println("------------")
  36340. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36341. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36342. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36343. }
  36344. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36345. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36346. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36347. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36348. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36349. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36350. }
  36351. }
  36352. if item.MedChrgitmType == "04" { //化验费
  36353. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36354. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36355. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36356. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36357. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36358. }
  36359. if item.MedChrgitmType == "05" { //治疗费
  36360. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36361. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36362. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36363. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36364. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36365. }
  36366. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36367. fmt.Println("------------")
  36368. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36369. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36370. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36371. }
  36372. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36373. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36374. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36375. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36376. }
  36377. //if item.MedChrgitmType == "06" { //手术费
  36378. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36379. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36380. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36381. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36382. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36383. //
  36384. //}
  36385. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36386. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36387. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36388. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36389. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36390. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36391. }
  36392. if item.MedChrgitmType == "09" { //西药费
  36393. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36394. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36395. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36396. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36397. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36398. }
  36399. if item.MedChrgitmType == "11" { //中成费
  36400. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36401. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36402. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36403. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36404. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36405. }
  36406. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  36407. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36408. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36409. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36410. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36411. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36412. }
  36413. }
  36414. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36415. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36416. var user_name string
  36417. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36418. if role.ID == 0 {
  36419. user_name = "管理员"
  36420. } else {
  36421. user_name = role.UserName
  36422. }
  36423. baseParams := models.BaseParams{
  36424. SecretKey: miConfig.SecretKey,
  36425. FixmedinsCode: miConfig.Code,
  36426. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36427. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36428. OrgName: miConfig.OrgName,
  36429. Doctor: user_name,
  36430. RequestUrl: miConfig.Url,
  36431. AccessKey: miConfig.AccessKey,
  36432. }
  36433. businessParams := models.BusinessParams{
  36434. PsnNo: order.PsnNo,
  36435. MdtrtId: order.MdtrtId,
  36436. SetlId: order.SetlId,
  36437. }
  36438. var res ResultEleven
  36439. var resEleven10265 ResultEleven10265
  36440. if config.IsOpen == 1 {
  36441. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36442. result := service.Gdyb5203(baseParams, businessParams)
  36443. service.Gdyb5204(baseParams, businessParams)
  36444. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36445. var dat map[string]interface{}
  36446. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36447. fmt.Println(dat)
  36448. } else {
  36449. fmt.Println(err)
  36450. }
  36451. userJSONBytes, _ := json.Marshal(dat)
  36452. if miConfig.Code == "H15049901371" {
  36453. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36454. utils.ErrorLog("解析失败:%v", err)
  36455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36456. return
  36457. }
  36458. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36459. res.Output = resEleven10265.Output
  36460. res.ErrMsg = resEleven10265.ErrMsg
  36461. res.Cainfo = resEleven10265.Cainfo
  36462. res.WarnMsg = resEleven10265.WarnMsg
  36463. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36464. res.Infcode = infocode
  36465. } else {
  36466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36467. utils.ErrorLog("解析失败:%v", err)
  36468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36469. return
  36470. }
  36471. }
  36472. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36473. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36474. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36475. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36476. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36477. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36478. var doctor_name string
  36479. if roles.ID == 0 {
  36480. doctor_name = "管理员"
  36481. } else {
  36482. doctor_name = roles.UserName
  36483. }
  36484. yiliao_leibie := ""
  36485. switch order.MedType {
  36486. case "11":
  36487. yiliao_leibie = "普通门诊"
  36488. break
  36489. case "12":
  36490. yiliao_leibie = "门诊挂号"
  36491. break
  36492. case "13":
  36493. yiliao_leibie = "急诊"
  36494. break
  36495. case "14":
  36496. yiliao_leibie = "门诊特殊病"
  36497. break
  36498. case "15":
  36499. yiliao_leibie = "门诊统筹"
  36500. break
  36501. case "16":
  36502. yiliao_leibie = "门诊慢性病"
  36503. break
  36504. case "21":
  36505. yiliao_leibie = "普通住院"
  36506. break
  36507. }
  36508. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36509. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  36510. if res.Infcode == 0 {
  36511. data2 := map[string]interface{}{
  36512. "diagnosis": name,
  36513. "order_infos": orderInfos,
  36514. "number": order.MdtrtId,
  36515. "date": order.SettleAccountsDate,
  36516. "charge_admin": charge_admin,
  36517. "printor_admin": printor_admin,
  36518. "info": res.Output.Setlinfo,
  36519. "order": order,
  36520. "bedCostTotal": bedCostTotal,
  36521. "bedCostSelfTotal": bedCostSelfTotal,
  36522. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36523. "bedSelfTotal": bedSelfTotal,
  36524. "bedInscpTotal": bedInscpTotal,
  36525. "operationCostTotal": operationCostTotal,
  36526. "operationCostSelfTotal": operationCostSelfTotal,
  36527. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36528. "operationSelfTotal": operationSelfTotal,
  36529. "operationInscpTotal": operationInscpTotal,
  36530. "otherCostTotal": otherCostTotal,
  36531. "otherCostSelfTotal": otherCostSelfTotal,
  36532. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36533. "otherSelfTotal": otherSelfTotal,
  36534. "otherInscpTotal": otherInscpTotal,
  36535. "materialCostTotal": materialCostTotal,
  36536. "materialCostSelfTotal": materialCostSelfTotal,
  36537. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36538. "materialSelfTotal": materialSelfTotal,
  36539. "materialInscpTotal": materialInscpTotal,
  36540. "westernMedicineCostTotal": westernMedicineCostTotal,
  36541. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36542. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36543. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36544. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36545. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36546. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36547. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36548. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36549. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36550. "checkCostTotal": checkCostTotal,
  36551. "checkCostSelfTotal": checkCostSelfTotal,
  36552. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36553. "checkSelfTotal": checkSelfTotal,
  36554. "checkInscpTotal": checkInscpTotal,
  36555. "laboratoryCostTotal": laboratoryCostTotal,
  36556. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36557. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36558. "laboratorySelfTotal": laboratorySelfTotal,
  36559. "laboratoryInscpTotal": laboratoryInscpTotal,
  36560. "treatCostTotal": treatCostTotal,
  36561. "treatCostSelfTotal": treatCostSelfTotal,
  36562. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36563. "treatSelfTotal": treatSelfTotal,
  36564. "treatInscpTotal": treatInscpTotal,
  36565. "doctor_info": doctor_info,
  36566. "doctor_code": adminRole_two.DoctorCode,
  36567. "doctor_name": doctor_name,
  36568. "health_card_no": order.PsnNo,
  36569. "department": departments.Name,
  36570. "yiliao_leibie": yiliao_leibie,
  36571. "after_money": order.AccountPrice,
  36572. "patient": patient,
  36573. "org_name": miConfig.OrgName,
  36574. "org_code": miConfig.Code,
  36575. "order_number": order.Number,
  36576. "his_hospital": his_hospital,
  36577. "his": his,
  36578. "dia_config": dia_config,
  36579. "psn_cash_pay": order.PsnCashPay,
  36580. //"check_order_info": cus_slice,
  36581. }
  36582. data3 = append(data3, data2)
  36583. }
  36584. }
  36585. }
  36586. c.ServeSuccessJSON(map[string]interface{}{
  36587. "infos": data3,
  36588. })
  36589. }
  36590. func (c *HisApiController) GetSettleAccounts() {
  36591. //id, _ := c.GetInt64("id")
  36592. //record_time := c.GetString("record_time")
  36593. order_id, _ := c.GetInt64("order_id")
  36594. admin_user_id, _ := c.GetInt64("admin_user_id")
  36595. //timeLayout := "2006-01-02"
  36596. //loc, _ := time.LoadLocation("Local")
  36597. //
  36598. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36599. //if err != nil {
  36600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36601. // return
  36602. //}Hbyb5203
  36603. //recordDateTime := theTime.Unix()
  36604. adminUser := c.GetAdminUserInfo()
  36605. order, _ := service.GetHisOrderByID(order_id)
  36606. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36607. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36608. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36609. orderInfos = append(orderInfos, orderInfos_two...)
  36610. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36611. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36612. var diagnosis_ids []string
  36613. if his.ID > 0 {
  36614. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36615. } else {
  36616. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36617. }
  36618. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36619. var dia_config []*models.HisXtDiagnoseConfig
  36620. var name string
  36621. for _, item := range diagnosis_ids {
  36622. id, _ := strconv.ParseInt(item, 10, 64)
  36623. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36624. dia_config = append(dia_config, &diagnosisConfig)
  36625. if len(name) == 0 {
  36626. name = diagnosisConfig.ClassName
  36627. } else {
  36628. name = name + "," + diagnosisConfig.ClassName
  36629. }
  36630. }
  36631. if patient.UserOrgId == 10215 {
  36632. name = "慢性肾功能不全(血透治疗)"
  36633. }
  36634. var bedCostTotal float64 = 0 //床位总费
  36635. var bedCostSelfTotal float64 = 0 //床位自费
  36636. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36637. var bedSelfTotal float64 = 0 //床位部分项目自费
  36638. var bedInscpTotal float64 = 0 //床位部分项目自费
  36639. var operationCostTotal float64 = 0 //手术费
  36640. var operationCostSelfTotal float64 = 0 //手术费
  36641. var operationCostPartSelfTotal float64 = 0 //手术费
  36642. var operationSelfTotal float64 = 0 //床位部分项目自费
  36643. var operationInscpTotal float64 = 0 //床位部分项目自费
  36644. var otherCostTotal float64 = 0 //其他费用
  36645. var otherCostSelfTotal float64 = 0 //其他费用
  36646. var otherCostPartSelfTotal float64 = 0 //其他费用
  36647. var otherSelfTotal float64 = 0 //床位部分项目自费
  36648. var otherInscpTotal float64 = 0 //床位部分项目自费
  36649. var materialCostTotal float64 = 0 //材料费
  36650. var materialCostSelfTotal float64 = 0 //材料费
  36651. var materialCostPartSelfTotal float64 = 0 //材料费
  36652. var materialSelfTotal float64 = 0 //床位部分项目自费
  36653. var materialInscpTotal float64 = 0 //床位部分项目自费
  36654. var westernMedicineCostTotal float64 = 0 //西药费
  36655. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36656. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36657. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36658. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36659. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36660. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36661. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36662. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36663. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36664. var checkCostTotal float64 = 0 //检查费
  36665. var checkCostSelfTotal float64 = 0 //检查费
  36666. var checkCostPartSelfTotal float64 = 0 //检查费
  36667. var checkSelfTotal float64 = 0 //床位部分项目自费
  36668. var checkInscpTotal float64 = 0 //床位部分项目自费
  36669. var laboratoryCostTotal float64 = 0 //化验费
  36670. var laboratoryCostSelfTotal float64 = 0 //化验费
  36671. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36672. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36673. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36674. var treatCostTotal float64 = 0 //治疗费用
  36675. var treatCostSelfTotal float64 = 0 //治疗费用
  36676. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36677. var treatSelfTotal float64 = 0 //床位部分项目自费
  36678. var treatInscpTotal float64 = 0 //床位部分项目自费
  36679. var zcCostTotal float64 = 0 //治疗费用
  36680. var zcCostSelfTotal float64 = 0 //治疗费用
  36681. var zcCostPartSelfTotal float64 = 0 //治疗费用
  36682. var zcSelfTotal float64 = 0 //床位部分项目自费
  36683. var zcInscpTotal float64 = 0 //床位部分项目自费
  36684. var huliCostTotal float64 = 0 //治疗费用
  36685. var huliCostSelfTotal float64 = 0 //治疗费用
  36686. var huliCostPartSelfTotal float64 = 0 //治疗费用
  36687. var huliSelfTotal float64 = 0 //床位部分项目自费
  36688. var huliInscpTotal float64 = 0 //床位部分项目自费
  36689. decimal.DivisionPrecision = 2
  36690. for _, item := range orderInfos {
  36691. if item.MedChrgitmType == "01" { //床位费
  36692. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36693. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36694. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36695. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36696. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36697. }
  36698. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36699. if item.MedChrgitmType == "03" { //检查费
  36700. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36701. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36702. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36703. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36704. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36705. }
  36706. } else {
  36707. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36708. fmt.Println("------------")
  36709. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36710. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36711. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36712. }
  36713. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36714. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36715. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36716. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36717. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36718. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36719. }
  36720. }
  36721. if item.MedChrgitmType == "04" { //化验费
  36722. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36723. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36724. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36725. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36726. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36727. }
  36728. if item.MedChrgitmType == "05" { //治疗费
  36729. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36730. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36731. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36732. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36733. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36734. }
  36735. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36736. fmt.Println("------------")
  36737. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36738. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36739. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36740. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36741. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36742. }
  36743. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36744. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36745. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36746. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36747. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36748. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36749. }
  36750. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36751. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36752. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36753. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36754. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36755. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36756. }
  36757. if item.MedChrgitmType == "09" { //西药费
  36758. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36759. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36760. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36761. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36762. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36763. }
  36764. if item.MedChrgitmType == "11" { //中成费
  36765. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36766. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36767. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36768. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36769. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36770. }
  36771. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  36772. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36773. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36774. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36775. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36776. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36777. }
  36778. if item.MedChrgitmType == "02" { //其他费
  36779. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36780. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36781. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36782. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36783. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36784. }
  36785. if item.MedChrgitmType == "07" { //其他费
  36786. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36787. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36788. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36789. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36790. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36791. }
  36792. }
  36793. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36794. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36795. var user_name string
  36796. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36797. if role.ID == 0 {
  36798. user_name = "管理员"
  36799. } else {
  36800. user_name = role.UserName
  36801. }
  36802. baseParams := models.BaseParams{
  36803. SecretKey: miConfig.SecretKey,
  36804. FixmedinsCode: miConfig.Code,
  36805. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36806. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36807. OrgName: miConfig.OrgName,
  36808. Doctor: user_name,
  36809. RequestUrl: miConfig.Url,
  36810. AccessKey: miConfig.AccessKey,
  36811. }
  36812. businessParams := models.BusinessParams{
  36813. PsnNo: order.PsnNo,
  36814. MdtrtId: order.MdtrtId,
  36815. SetlId: order.SetlId,
  36816. }
  36817. var res ResultEleven
  36818. var resah ResultElevenah
  36819. var resEleven10265 ResultEleven10265
  36820. if config.IsOpen == 1 {
  36821. if miConfig.MdtrtareaAdmvs == "421300" {
  36822. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36823. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36824. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36825. resp, requestErr := http.Get(api)
  36826. if requestErr != nil {
  36827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36828. return
  36829. }
  36830. body, ioErr := ioutil.ReadAll(resp.Body)
  36831. if ioErr != nil {
  36832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36834. return
  36835. }
  36836. var respJSON map[string]interface{}
  36837. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36840. return
  36841. }
  36842. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36843. result, _ := json.Marshal(respJSON)
  36844. fmt.Println("log")
  36845. fmt.Println(string(result))
  36846. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36847. utils.ErrorLog("解析失败:%v", err)
  36848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36849. return
  36850. }
  36851. } else if miConfig.MdtrtareaAdmvs == "420200" {
  36852. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36853. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36854. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36855. resp, requestErr := http.Get(api)
  36856. if requestErr != nil {
  36857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36858. return
  36859. }
  36860. body, ioErr := ioutil.ReadAll(resp.Body)
  36861. if ioErr != nil {
  36862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36864. return
  36865. }
  36866. var respJSON map[string]interface{}
  36867. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36870. return
  36871. }
  36872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36873. result, _ := json.Marshal(respJSON)
  36874. fmt.Println("log")
  36875. fmt.Println(string(result))
  36876. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36877. utils.ErrorLog("解析失败:%v", err)
  36878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36879. return
  36880. }
  36881. } else if miConfig.MdtrtareaAdmvs == "420902" {
  36882. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36883. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36884. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36885. resp, requestErr := http.Get(api)
  36886. if requestErr != nil {
  36887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36888. return
  36889. }
  36890. body, ioErr := ioutil.ReadAll(resp.Body)
  36891. if ioErr != nil {
  36892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36894. return
  36895. }
  36896. var respJSON map[string]interface{}
  36897. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36900. return
  36901. }
  36902. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36903. result, _ := json.Marshal(respJSON)
  36904. fmt.Println("log")
  36905. fmt.Println(string(result))
  36906. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36907. utils.ErrorLog("解析失败:%v", err)
  36908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36909. return
  36910. }
  36911. } else if miConfig.MdtrtareaAdmvs == "421182" {
  36912. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36913. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36914. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  36915. resp, requestErr := http.Get(api)
  36916. if requestErr != nil {
  36917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36918. return
  36919. }
  36920. body, ioErr := ioutil.ReadAll(resp.Body)
  36921. if ioErr != nil {
  36922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36924. return
  36925. }
  36926. var respJSON map[string]interface{}
  36927. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36930. return
  36931. }
  36932. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36933. result, _ := json.Marshal(respJSON)
  36934. fmt.Println("log")
  36935. fmt.Println(string(result))
  36936. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36937. utils.ErrorLog("解析失败:%v", err)
  36938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36939. return
  36940. }
  36941. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  36942. var api string
  36943. if miConfig.MdtrtareaAdmvs == "320830" {
  36944. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36945. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36946. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36947. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36948. } else if miConfig.MdtrtareaAdmvs == "320921" {
  36949. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36950. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36951. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36952. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36953. } else {
  36954. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36955. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36956. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36957. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36958. }
  36959. resp, requestErr := http.Get(api)
  36960. if requestErr != nil {
  36961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36962. return
  36963. }
  36964. body, ioErr := ioutil.ReadAll(resp.Body)
  36965. if ioErr != nil {
  36966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36968. return
  36969. }
  36970. var respJSON map[string]interface{}
  36971. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36974. return
  36975. }
  36976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36977. result, _ := json.Marshal(respJSON)
  36978. fmt.Println("log")
  36979. fmt.Println(string(result))
  36980. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  36981. utils.ErrorLog("解析失败:%v", err)
  36982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36983. return
  36984. }
  36985. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36986. res.Output = resEleven10265.Output
  36987. res.ErrMsg = resEleven10265.ErrMsg
  36988. res.Cainfo = resEleven10265.Cainfo
  36989. res.WarnMsg = resEleven10265.WarnMsg
  36990. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36991. res.Infcode = infocode
  36992. } else if miConfig.MdtrtareaAdmvs == "350500" {
  36993. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  36994. saveLog(result, requestLog, "5203", "结算单")
  36995. var dat map[string]interface{}
  36996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36997. fmt.Println(dat)
  36998. } else {
  36999. fmt.Println(err)
  37000. }
  37001. userJSONBytes, _ := json.Marshal(dat)
  37002. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37003. utils.ErrorLog("解析失败:%v", err)
  37004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37005. return
  37006. }
  37007. } else if miConfig.MdtrtareaAdmvs == "360302" {
  37008. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37009. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37010. saveLog(result, requestLog, "5203", "结算单")
  37011. var dat map[string]interface{}
  37012. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37013. fmt.Println(dat)
  37014. } else {
  37015. fmt.Println(err)
  37016. }
  37017. userJSONBytes, _ := json.Marshal(dat)
  37018. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37019. utils.ErrorLog("解析失败:%v", err)
  37020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37021. return
  37022. }
  37023. } else if miConfig.MdtrtareaAdmvs == "361025" {
  37024. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37025. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37026. saveLog(result, requestLog, "5203", "结算单")
  37027. var dat map[string]interface{}
  37028. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37029. fmt.Println(dat)
  37030. } else {
  37031. fmt.Println(err)
  37032. }
  37033. userJSONBytes, _ := json.Marshal(dat)
  37034. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37035. utils.ErrorLog("解析失败:%v", err)
  37036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37037. return
  37038. }
  37039. } else if miConfig.MdtrtareaAdmvs == "360100" {
  37040. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37041. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37042. saveLog(result, requestLog, "5203", "结算单")
  37043. var dat map[string]interface{}
  37044. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37045. fmt.Println(dat)
  37046. } else {
  37047. fmt.Println(err)
  37048. }
  37049. userJSONBytes, _ := json.Marshal(dat)
  37050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37051. utils.ErrorLog("解析失败:%v", err)
  37052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37053. return
  37054. }
  37055. } else if miConfig.MdtrtareaAdmvs == "341203" {
  37056. var api string
  37057. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37058. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37059. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37060. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37061. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37062. resp, requestErr := http.Get(api)
  37063. if requestErr != nil {
  37064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37065. return
  37066. }
  37067. body, ioErr := ioutil.ReadAll(resp.Body)
  37068. if ioErr != nil {
  37069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37071. return
  37072. }
  37073. var respJSON map[string]interface{}
  37074. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37077. return
  37078. }
  37079. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37080. if status == "0" {
  37081. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37082. c.ServeSuccessJSON(map[string]interface{}{
  37083. "failed_code": -10,
  37084. "msg": err_msg,
  37085. })
  37086. return
  37087. }
  37088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37089. result, _ := json.Marshal(respJSON)
  37090. fmt.Println("log")
  37091. fmt.Println(string(result))
  37092. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37093. utils.ErrorLog("解析失败:%v", err)
  37094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37095. return
  37096. }
  37097. res.InfRefmsgid = resah.InfRefmsgid
  37098. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37099. // 创建对应的Time类型
  37100. t := time.UnixMilli(timestamp)
  37101. // 格式化成指定的日期字符串
  37102. str := t.Format("2006-01-02 15:04:05")
  37103. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37104. // 创建对应的Time类型
  37105. t3 := time.UnixMilli(timestamp2)
  37106. // 格式化成指定的日期字符串
  37107. str2 := t3.Format("2006-01-02 15:04:05")
  37108. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37109. // 创建对应的Time类型
  37110. t4 := time.UnixMilli(timestamp3)
  37111. // 格式化成指定的日期字符串
  37112. str3 := t4.Format("2006-01-02 15:04:05")
  37113. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37114. // 创建对应的Time类型
  37115. t5 := time.UnixMilli(timestamp4)
  37116. // 格式化成指定的日期字符串
  37117. str5 := t5.Format("2006-01-02 15:04:05")
  37118. res.Output.Setlinfo.Brdy = str2
  37119. res.Output.Setlinfo.SetlTime = str
  37120. res.Output.Setlinfo.Begndate = str3
  37121. res.Output.Setlinfo.Enddate = str5
  37122. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37123. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37124. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37125. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37126. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37127. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37128. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37129. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37130. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37131. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37132. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37133. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37134. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37135. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37136. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37137. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37138. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37139. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37140. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37141. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37142. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37143. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37144. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37145. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37146. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37147. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37148. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37149. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37150. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37151. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37152. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37153. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37154. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37155. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37156. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37157. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37158. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37159. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37160. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37161. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37162. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37163. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37164. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37165. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37166. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37167. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37168. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37169. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37170. //res.Output.Setldetail = resah.Output.Setldetail
  37171. res.ErrMsg = resah.ErrMsg
  37172. res.Cainfo = resah.Cainfo
  37173. res.WarnMsg = resah.WarnMsg
  37174. } else if miConfig.MdtrtareaAdmvs == "340699" {
  37175. var api string
  37176. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37177. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37178. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37179. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37180. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37181. resp, requestErr := http.Get(api)
  37182. if requestErr != nil {
  37183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37184. return
  37185. }
  37186. body, ioErr := ioutil.ReadAll(resp.Body)
  37187. if ioErr != nil {
  37188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37190. return
  37191. }
  37192. var respJSON map[string]interface{}
  37193. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37196. return
  37197. }
  37198. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37199. if status == "0" {
  37200. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37201. c.ServeSuccessJSON(map[string]interface{}{
  37202. "failed_code": -10,
  37203. "msg": err_msg,
  37204. })
  37205. return
  37206. }
  37207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37208. result, _ := json.Marshal(respJSON)
  37209. fmt.Println("log")
  37210. fmt.Println(string(result))
  37211. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37212. utils.ErrorLog("解析失败:%v", err)
  37213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37214. return
  37215. }
  37216. res.InfRefmsgid = resah.InfRefmsgid
  37217. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37218. // 创建对应的Time类型
  37219. t := time.UnixMilli(timestamp)
  37220. // 格式化成指定的日期字符串
  37221. str := t.Format("2006-01-02 15:04:05")
  37222. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37223. // 创建对应的Time类型
  37224. t3 := time.UnixMilli(timestamp2)
  37225. // 格式化成指定的日期字符串
  37226. str2 := t3.Format("2006-01-02 15:04:05")
  37227. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37228. // 创建对应的Time类型
  37229. t4 := time.UnixMilli(timestamp3)
  37230. // 格式化成指定的日期字符串
  37231. str3 := t4.Format("2006-01-02 15:04:05")
  37232. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37233. // 创建对应的Time类型
  37234. t5 := time.UnixMilli(timestamp4)
  37235. // 格式化成指定的日期字符串
  37236. str5 := t5.Format("2006-01-02 15:04:05")
  37237. res.Output.Setlinfo.Brdy = str2
  37238. res.Output.Setlinfo.SetlTime = str
  37239. res.Output.Setlinfo.Begndate = str3
  37240. res.Output.Setlinfo.Enddate = str5
  37241. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37242. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37243. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37244. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37245. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37246. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37247. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37248. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37249. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37250. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37251. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37252. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37253. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37254. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37255. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37256. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37257. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37258. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37259. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37260. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37261. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37262. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37263. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37264. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37265. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37266. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37267. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37268. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37269. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37270. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37271. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37272. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37273. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37274. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37275. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37276. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37277. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37278. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37279. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37280. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37281. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37282. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37283. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37284. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37285. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37286. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37287. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37288. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37289. //res.Output.Setldetail = resah.Output.Setldetail
  37290. res.ErrMsg = resah.ErrMsg
  37291. res.Cainfo = resah.Cainfo
  37292. res.WarnMsg = resah.WarnMsg
  37293. } else if miConfig.MdtrtareaAdmvs == "430800" {
  37294. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  37295. saveLog(result, requestLog, "5203", "结算单")
  37296. var dat map[string]interface{}
  37297. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37298. fmt.Println(dat)
  37299. } else {
  37300. fmt.Println(err)
  37301. }
  37302. userJSONBytes, _ := json.Marshal(dat)
  37303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37304. utils.ErrorLog("解析失败:%v", err)
  37305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37306. return
  37307. }
  37308. } else if miConfig.MdtrtareaAdmvs == "150499" {
  37309. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37310. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37311. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37312. resp, requestErr := http.Get(api)
  37313. if requestErr != nil {
  37314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37315. return
  37316. }
  37317. body, ioErr := ioutil.ReadAll(resp.Body)
  37318. if ioErr != nil {
  37319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37321. return
  37322. }
  37323. var respJSON map[string]interface{}
  37324. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37327. return
  37328. }
  37329. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37330. result, _ := json.Marshal(respJSON)
  37331. fmt.Println("log")
  37332. fmt.Println(string(result))
  37333. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37334. utils.ErrorLog("解析失败:%v", err)
  37335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37336. return
  37337. }
  37338. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37339. res.Output = resEleven10265.Output
  37340. res.ErrMsg = resEleven10265.ErrMsg
  37341. res.Cainfo = resEleven10265.Cainfo
  37342. res.WarnMsg = resEleven10265.WarnMsg
  37343. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37344. res.Infcode = infocode
  37345. } else if miConfig.MdtrtareaAdmvs == "441799" {
  37346. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37347. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37348. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37349. resp, requestErr := http.Get(api)
  37350. if requestErr != nil {
  37351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37352. return
  37353. }
  37354. body, ioErr := ioutil.ReadAll(resp.Body)
  37355. if ioErr != nil {
  37356. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37358. return
  37359. }
  37360. var respJSON map[string]interface{}
  37361. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37362. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37364. return
  37365. }
  37366. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37367. result, _ := json.Marshal(respJSON)
  37368. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37369. utils.ErrorLog("解析失败:%v", err)
  37370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37371. return
  37372. }
  37373. } else if miConfig.MdtrtareaAdmvs == "450721" {
  37374. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  37375. //return
  37376. } else {
  37377. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  37378. if len(his.InsuplcAdmdvs) == 0 {
  37379. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  37380. } else {
  37381. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37382. }
  37383. result := service.Gdyb5203(baseParams, businessParams)
  37384. //service.Gdyb5204(baseParams, businessParams)
  37385. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  37386. var dat map[string]interface{}
  37387. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37388. fmt.Println(dat)
  37389. } else {
  37390. fmt.Println(err)
  37391. }
  37392. userJSONBytes, _ := json.Marshal(dat)
  37393. if miConfig.Code == "H15049901371" {
  37394. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  37395. utils.ErrorLog("解析失败:%v", err)
  37396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37397. return
  37398. }
  37399. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37400. res.Output = resEleven10265.Output
  37401. res.ErrMsg = resEleven10265.ErrMsg
  37402. res.Cainfo = resEleven10265.Cainfo
  37403. res.WarnMsg = resEleven10265.WarnMsg
  37404. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37405. res.Infcode = infocode
  37406. } else {
  37407. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37408. utils.ErrorLog("解析失败:%v", err)
  37409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37410. return
  37411. }
  37412. }
  37413. }
  37414. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37415. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  37416. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  37417. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  37418. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  37419. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37420. var doctor_name string
  37421. if roles.ID == 0 {
  37422. doctor_name = "管理员"
  37423. } else {
  37424. doctor_name = roles.UserName
  37425. }
  37426. yiliao_leibie := ""
  37427. switch order.MedType {
  37428. case "11":
  37429. yiliao_leibie = "普通门诊"
  37430. break
  37431. case "12":
  37432. yiliao_leibie = "门诊挂号"
  37433. break
  37434. case "13":
  37435. yiliao_leibie = "急诊"
  37436. break
  37437. case "14":
  37438. yiliao_leibie = "门诊特殊病"
  37439. break
  37440. case "15":
  37441. yiliao_leibie = "门诊统筹"
  37442. break
  37443. case "16":
  37444. yiliao_leibie = "门诊慢性病"
  37445. break
  37446. case "21":
  37447. yiliao_leibie = "普通住院"
  37448. break
  37449. }
  37450. //var rf []CustomFundPay
  37451. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  37452. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37453. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  37454. if res.Infcode == 0 {
  37455. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10454 || adminUser.CurrentOrgId == 10644 || adminUser.CurrentOrgId == 10653 || adminUser.CurrentOrgId == 10210 || adminUser.CurrentOrgId == 10571 || adminUser.CurrentOrgId == 10752 {
  37456. c.ServeSuccessJSON(map[string]interface{}{
  37457. "diagnosis": name,
  37458. "order_infos": orderInfos,
  37459. "number": order.MdtrtId,
  37460. "date": order.SettleAccountsDate,
  37461. "charge_admin": charge_admin,
  37462. "printor_admin": printor_admin,
  37463. "info": res.Output.Setlinfo,
  37464. "order": order,
  37465. "bedCostTotal": bedCostTotal,
  37466. "bedCostSelfTotal": bedCostSelfTotal,
  37467. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37468. "bedSelfTotal": bedSelfTotal,
  37469. "bedInscpTotal": bedInscpTotal,
  37470. "operationCostTotal": operationCostTotal,
  37471. "operationCostSelfTotal": operationCostSelfTotal,
  37472. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37473. "operationSelfTotal": operationSelfTotal,
  37474. "operationInscpTotal": operationInscpTotal,
  37475. "otherCostTotal": otherCostTotal,
  37476. "otherCostSelfTotal": otherCostSelfTotal,
  37477. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37478. "otherSelfTotal": otherSelfTotal,
  37479. "otherInscpTotal": otherInscpTotal,
  37480. "materialCostTotal": materialCostTotal,
  37481. "materialCostSelfTotal": materialCostSelfTotal,
  37482. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37483. "materialSelfTotal": materialSelfTotal,
  37484. "materialInscpTotal": materialInscpTotal,
  37485. "westernMedicineCostTotal": westernMedicineCostTotal,
  37486. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37487. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37488. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37489. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37490. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37491. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37492. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37493. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37494. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37495. "checkCostTotal": checkCostTotal,
  37496. "checkCostSelfTotal": checkCostSelfTotal,
  37497. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37498. "checkSelfTotal": checkSelfTotal,
  37499. "checkInscpTotal": checkInscpTotal,
  37500. "laboratoryCostTotal": laboratoryCostTotal,
  37501. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37502. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37503. "laboratorySelfTotal": laboratorySelfTotal,
  37504. "laboratoryInscpTotal": laboratoryInscpTotal,
  37505. "treatCostTotal": treatCostTotal,
  37506. "treatCostSelfTotal": treatCostSelfTotal,
  37507. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37508. "treatSelfTotal": treatSelfTotal,
  37509. "treatInscpTotal": treatInscpTotal,
  37510. "doctor_info": doctor_info,
  37511. "doctor_code": adminRole_two.DoctorCode,
  37512. "doctor_name": doctor_name,
  37513. "health_card_no": order.PsnNo,
  37514. "department": departments.Name,
  37515. "yiliao_leibie": yiliao_leibie,
  37516. "after_money": order.AccountPrice,
  37517. "patient": patient,
  37518. "org_name": miConfig.OrgName,
  37519. "org_code": miConfig.Code,
  37520. "order_number": order.Number,
  37521. "his_hospital": his_hospital,
  37522. "his": his,
  37523. "dia_config": dia_config,
  37524. "psn_cash_pay": order.PsnCashPay,
  37525. "zcCostTotal": zcCostTotal,
  37526. "zcCostSelfTotal": zcCostSelfTotal,
  37527. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37528. "zcSelfTotal": zcSelfTotal,
  37529. "zcInscpTotal": zcInscpTotal,
  37530. "huliCostTotal": huliCostTotal,
  37531. "huliCostSelfTotal": huliCostSelfTotal,
  37532. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37533. "huliSelfTotal": huliSelfTotal,
  37534. "huliInscpTotal": huliInscpTotal,
  37535. //"funds": rf,
  37536. //"check_order_info": cus_slice,
  37537. })
  37538. } else {
  37539. c.ServeSuccessJSON(map[string]interface{}{
  37540. "diagnosis": name,
  37541. "order_infos": orderInfos,
  37542. "number": order.MdtrtId,
  37543. "date": order.SettleAccountsDate,
  37544. "charge_admin": charge_admin,
  37545. "printor_admin": printor_admin,
  37546. "info": order,
  37547. "order": order,
  37548. "bedCostTotal": bedCostTotal,
  37549. "bedCostSelfTotal": bedCostSelfTotal,
  37550. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37551. "bedSelfTotal": bedSelfTotal,
  37552. "bedInscpTotal": bedInscpTotal,
  37553. "operationCostTotal": operationCostTotal,
  37554. "operationCostSelfTotal": operationCostSelfTotal,
  37555. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37556. "operationSelfTotal": operationSelfTotal,
  37557. "operationInscpTotal": operationInscpTotal,
  37558. "otherCostTotal": otherCostTotal,
  37559. "otherCostSelfTotal": otherCostSelfTotal,
  37560. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37561. "otherSelfTotal": otherSelfTotal,
  37562. "otherInscpTotal": otherInscpTotal,
  37563. "materialCostTotal": materialCostTotal,
  37564. "materialCostSelfTotal": materialCostSelfTotal,
  37565. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37566. "materialSelfTotal": materialSelfTotal,
  37567. "materialInscpTotal": materialInscpTotal,
  37568. "westernMedicineCostTotal": westernMedicineCostTotal,
  37569. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37570. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37571. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37572. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37573. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37574. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37575. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37576. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37577. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37578. "checkCostTotal": checkCostTotal,
  37579. "checkCostSelfTotal": checkCostSelfTotal,
  37580. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37581. "checkSelfTotal": checkSelfTotal,
  37582. "checkInscpTotal": checkInscpTotal,
  37583. "laboratoryCostTotal": laboratoryCostTotal,
  37584. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37585. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37586. "laboratorySelfTotal": laboratorySelfTotal,
  37587. "laboratoryInscpTotal": laboratoryInscpTotal,
  37588. "treatCostTotal": treatCostTotal,
  37589. "treatCostSelfTotal": treatCostSelfTotal,
  37590. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37591. "treatSelfTotal": treatSelfTotal,
  37592. "treatInscpTotal": treatInscpTotal,
  37593. "doctor_info": doctor_info,
  37594. "doctor_code": adminRole_two.DoctorCode,
  37595. "doctor_name": doctor_name,
  37596. "health_card_no": order.PsnNo,
  37597. "department": departments.Name,
  37598. "yiliao_leibie": yiliao_leibie,
  37599. "after_money": order.AccountPrice,
  37600. "patient": patient,
  37601. "org_name": miConfig.OrgName,
  37602. "org_code": miConfig.Code,
  37603. "order_number": order.Number,
  37604. "his_hospital": his_hospital,
  37605. "his": his,
  37606. "dia_config": dia_config,
  37607. "psn_cash_pay": order.PsnCashPay,
  37608. "zcCostTotal": zcCostTotal,
  37609. "zcCostSelfTotal": zcCostSelfTotal,
  37610. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37611. "zcSelfTotal": zcSelfTotal,
  37612. "zcInscpTotal": zcInscpTotal,
  37613. "huliCostTotal": huliCostTotal,
  37614. "huliCostSelfTotal": huliCostSelfTotal,
  37615. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37616. "huliSelfTotal": huliSelfTotal,
  37617. "huliInscpTotal": huliInscpTotal,
  37618. //"funds": rf,
  37619. //"check_order_info": cus_slice,
  37620. })
  37621. }
  37622. }
  37623. }
  37624. }
  37625. //func (c *HisApiController) CheckTreatment() {
  37626. // patient_id, _ := c.GetInt64("patient_id")
  37627. // id_card_no := c.GetString("id_card_no")
  37628. // insutype := c.GetString("insutype")
  37629. // med_type := c.GetString("med_type")
  37630. // admin_user_id, _ := c.GetInt64("admin_user_id")
  37631. //
  37632. // adminUser := c.GetAdminUserInfo()
  37633. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37634. //
  37635. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37636. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37637. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37638. //
  37639. // if miConfig.MdtrtareaAdmvs == "421300" {
  37640. // var res ResultTwo
  37641. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  37642. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37643. // "&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)
  37644. // resp, requestErr := http.Get(api)
  37645. // if requestErr != nil {
  37646. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37647. // return
  37648. // }
  37649. //
  37650. // body, ioErr := ioutil.ReadAll(resp.Body)
  37651. // if ioErr != nil {
  37652. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37654. // return
  37655. // }
  37656. // var respJSON map[string]interface{}
  37657. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37658. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37659. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37660. // return
  37661. // }
  37662. //
  37663. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37664. // result, _ := json.Marshal(respJSON)
  37665. //
  37666. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37667. // utils.ErrorLog("解析失败:%v", err)
  37668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37669. // return
  37670. // }
  37671. //
  37672. // if res.Infcode == 0 {
  37673. //
  37674. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  37675. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37676. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  37677. // resp, requestErr := http.Get(api)
  37678. // if requestErr != nil {
  37679. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37680. // return
  37681. // }
  37682. //
  37683. // body, ioErr := ioutil.ReadAll(resp.Body)
  37684. // if ioErr != nil {
  37685. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37686. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37687. // return
  37688. // }
  37689. // var respJSON map[string]interface{}
  37690. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37691. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37692. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37693. // return
  37694. // }
  37695. // var res Result2001
  37696. //
  37697. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37698. // result2, _ := json.Marshal(respJSON)
  37699. //
  37700. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  37701. // utils.ErrorLog("解析失败:%v", err)
  37702. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37703. // return
  37704. // }
  37705. //
  37706. // if res.Infcode == 0 {
  37707. // c.ServeSuccessJSON(map[string]interface{}{
  37708. // "msg": res.Output.Trtinfo,
  37709. // })
  37710. // }
  37711. //
  37712. // } else {
  37713. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37714. // return
  37715. // }
  37716. //
  37717. // } else {
  37718. //
  37719. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37720. // var dat map[string]interface{}
  37721. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37722. // fmt.Println(dat)
  37723. // } else {
  37724. // fmt.Println(err)
  37725. // }
  37726. // userJSONBytes, _ := json.Marshal(dat)
  37727. // var res ResultTwo
  37728. // var res10265 ResultTwo10265
  37729. // if miConfig.Code == "H15049901371" {
  37730. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37731. // utils.ErrorLog("解析失败:%v", err)
  37732. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37733. // return
  37734. // }
  37735. // res.ErrMsg = res10265.ErrMsg
  37736. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37737. // res.Infcode = infocode
  37738. // res.Output = res10265.Output
  37739. // res.InfRefmsgid = res10265.InfRefmsgid
  37740. // } else {
  37741. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37742. // utils.ErrorLog("解析失败:%v", err)
  37743. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37744. // return
  37745. // }
  37746. // }
  37747. //
  37748. // var user_name string
  37749. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  37750. // if role.ID == 0 {
  37751. // user_name = "xxx"
  37752. // } else {
  37753. // user_name = role.UserName
  37754. // }
  37755. //
  37756. // baseParams := models.BaseParams{
  37757. // SecretKey: miConfig.SecretKey,
  37758. // FixmedinsCode: miConfig.Code,
  37759. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37760. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37761. // OrgName: miConfig.OrgName,
  37762. // Doctor: user_name,
  37763. // }
  37764. //
  37765. // if config.IsOpen == 1 {
  37766. // if miConfig.Code == "H15049901371" {
  37767. // if med_type == "14" {
  37768. // if insutype == "390" {
  37769. // med_type = "9933"
  37770. // } else if insutype == "310" {
  37771. // med_type = "990502"
  37772. // }
  37773. // } else if med_type == "11" {
  37774. // med_type = "11"
  37775. // }
  37776. // }
  37777. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  37778. // var dat map[string]interface{}
  37779. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37780. // fmt.Println(dat)
  37781. // } else {
  37782. // fmt.Println(err)
  37783. // }
  37784. // var res Result2001
  37785. // var res10265 Result2001Org10265
  37786. // if miConfig.Code == "H15049901371" {
  37787. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37788. // utils.ErrorLog("解析失败:%v", err)
  37789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37790. // return
  37791. // }
  37792. // res.ErrMsg = res10265.ErrMsg
  37793. // res.Output = res10265.Output
  37794. // res.InfRefmsgid = res10265.InfRefmsgid
  37795. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37796. // res.Infcode = infocode
  37797. // } else {
  37798. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37799. // utils.ErrorLog("解析失败:%v", err)
  37800. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37801. // return
  37802. // }
  37803. // }
  37804. // if res.Infcode == 0 {
  37805. // c.ServeSuccessJSON(map[string]interface{}{
  37806. // "msg": res.Output.Trtinfo,
  37807. // })
  37808. // }
  37809. // }
  37810. // }
  37811. //}
  37812. //func (c *HisApiController) PutRecord() {
  37813. // id, _ := c.GetInt64("id")
  37814. // record_time := c.GetString("record_time")
  37815. // timeLayout := "2006-01-02"
  37816. // loc, _ := time.LoadLocation("Local")
  37817. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37818. // if err != nil {
  37819. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37820. // return
  37821. // }
  37822. // recordDateTime := theTime.Unix()
  37823. //
  37824. // adminInfo := c.GetAdminUserInfo()
  37825. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  37826. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37827. //
  37828. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37829. //
  37830. // fmt.Println(miConfig.SecretKey)
  37831. //
  37832. // if patient == nil {
  37833. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37834. // return
  37835. // }
  37836. // if len(patient.IdCardNo) == 0 {
  37837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  37838. // return
  37839. // }
  37840. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  37841. // if config.IsOpen == 1 {
  37842. // 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
  37843. // resp, requestErr := http.Get(api)
  37844. // if requestErr != nil {
  37845. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37846. // return
  37847. // }
  37848. // defer resp.Body.Close()
  37849. // body, ioErr := ioutil.ReadAll(resp.Body)
  37850. // if ioErr != nil {
  37851. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37852. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37853. // return
  37854. // }
  37855. // var respJSON map[string]interface{}
  37856. //
  37857. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37858. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37859. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37860. // return
  37861. // }
  37862. //
  37863. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37864. // userJSONBytes, _ := json.Marshal(userJSON)
  37865. // var res ResultTwo
  37866. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37867. // utils.ErrorLog("解析失败:%v", err)
  37868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37869. // return
  37870. // }
  37871. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37872. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37873. // infoStr := string(Iinfos)
  37874. // idetinfoStr := string(Idetinfos)
  37875. //
  37876. // if res.Infcode == 0 {
  37877. // his := models.VMHisPatient{
  37878. // Status: 1,
  37879. // Ctime: time.Now().Unix(),
  37880. // Mtime: time.Now().Unix(),
  37881. // PsnNo: res.Output.Baseinfo.PsnNo,
  37882. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  37883. // Certno: res.Output.Baseinfo.Certno,
  37884. // PsnName: res.Output.Baseinfo.PsnName,
  37885. // Gend: res.Output.Baseinfo.Gend,
  37886. // Naty: res.Output.Baseinfo.Naty,
  37887. // Brdy: res.Output.Baseinfo.Brdy,
  37888. // Age: res.Output.Baseinfo.Age,
  37889. // Iinfo: infoStr,
  37890. // Idetinfo: idetinfoStr,
  37891. // PatientId: patient.ID,
  37892. // RecordDate: theTime.Unix(),
  37893. // UserOrgId: adminInfo.CurrentOrgId,
  37894. // AdminUserId: adminInfo.AdminUser.Id,
  37895. // IsReturn: 1,
  37896. // }
  37897. //
  37898. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  37899. // //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")
  37900. // //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")
  37901. //
  37902. // //var dat map[string]interface{}
  37903. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37904. // // fmt.Println(dat)
  37905. // //} else {
  37906. // // fmt.Println(err)
  37907. // //}
  37908. //
  37909. // var dat2 map[string]interface{}
  37910. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37911. // fmt.Println(dat2)
  37912. // } else {
  37913. // fmt.Println(err)
  37914. // }
  37915. //
  37916. // } else {
  37917. // adminUser := c.GetAdminUserInfo()
  37918. // errlog := &models.HisOrderError{
  37919. // UserOrgId: adminUser.CurrentOrgId,
  37920. // Ctime: time.Now().Unix(),
  37921. // Mtime: time.Now().Unix(),
  37922. // ErrMsg: res.ErrMsg,
  37923. // Status: 1,
  37924. // PatientId: id,
  37925. // RecordTime: recordDateTime,
  37926. // Stage: 1,
  37927. // }
  37928. // service.CreateErrMsgLog(errlog)
  37929. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  37930. // return
  37931. // }
  37932. // }
  37933. //
  37934. //}
  37935. //func (c *HisApiController) GetUploadDiag() {
  37936. // id, _ := c.GetInt64("id")
  37937. // record_time := c.GetString("record_time")
  37938. //
  37939. // diagnosis_id, _ := c.GetInt64("diagnosis")
  37940. // sick_type, _ := c.GetInt64("sick_type")
  37941. // reg_type, _ := c.GetInt64("reg_type")
  37942. //
  37943. // timeLayout := "2006-01-02"
  37944. // loc, _ := time.LoadLocation("Local")
  37945. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37946. // if err != nil {
  37947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37948. // return
  37949. // }
  37950. //
  37951. // var patientPrescription models.HisPrescriptionInfo
  37952. // recordDateTime := theTime.Unix()
  37953. // adminInfo := c.GetAdminUserInfo()
  37954. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37955. //
  37956. // if patientPrescription.ID == 0 {
  37957. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37958. // }
  37959. //
  37960. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37961. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  37962. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37963. // sickConfig, _ := service.FindSickById(sick_type)
  37964. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37965. //
  37966. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  37967. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  37968. // "&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 +
  37969. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  37970. // resp2, requestErr2 := http.Get(api2)
  37971. // if requestErr2 != nil {
  37972. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37973. // return
  37974. // }
  37975. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  37976. // if ioErr2 != nil {
  37977. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  37978. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37979. // return
  37980. // }
  37981. // var respJSON2 map[string]interface{}
  37982. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  37983. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37984. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37985. // return
  37986. // }
  37987. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37988. // userJSONBytes2, _ := json.Marshal(respJSON2)
  37989. //
  37990. // var res2 ResultSix
  37991. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37992. // utils.ErrorLog("解析失败:%v", err)
  37993. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37994. // return
  37995. // }
  37996. // if res2.Infcode != 0 {
  37997. // adminUser := c.GetAdminUserInfo()
  37998. // errlog := &models.HisOrderError{
  37999. // UserOrgId: adminUser.CurrentOrgId,
  38000. // Ctime: time.Now().Unix(),
  38001. // Mtime: time.Now().Unix(),
  38002. // ErrMsg: res2.ErrMsg,
  38003. // Status: 1,
  38004. // PatientId: id,
  38005. // RecordTime: recordDateTime,
  38006. // Stage: 3,
  38007. // }
  38008. // service.CreateErrMsgLog(errlog)
  38009. //
  38010. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  38011. // return
  38012. // }
  38013. //
  38014. // c.ServeSuccessJSON(map[string]interface{}{
  38015. // "msg": "上传成功",
  38016. // })
  38017. //
  38018. //}
  38019. type QueryResult struct {
  38020. ID int64
  38021. Name string
  38022. Code string
  38023. List_type_code string
  38024. }
  38025. func (c *HisApiController) GetCheckCode() {
  38026. ids_str := c.GetString("ids")
  38027. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38028. ids_arr := strings.Split(ids_str, ",")
  38029. var queryResult []QueryResult
  38030. ids := make([]int64, 0)
  38031. for _, item := range ids_arr {
  38032. id, _ := strconv.ParseInt(item, 10, 64)
  38033. ids = append(ids, id)
  38034. }
  38035. if record_type == 1 {
  38036. drugs, _ := service.GetBatchDrugList(ids)
  38037. for _, item := range drugs {
  38038. result := QueryResult{
  38039. ID: item.ID,
  38040. Name: item.DrugName,
  38041. Code: item.MedicalInsuranceNumber,
  38042. List_type_code: "101",
  38043. }
  38044. queryResult = append(queryResult, result)
  38045. }
  38046. } else if record_type == 2 {
  38047. goods, _ := service.GetBatchGoodInformationList(ids)
  38048. fmt.Println(goods)
  38049. for _, item := range goods {
  38050. result := QueryResult{
  38051. ID: item.ID,
  38052. Name: item.GoodName,
  38053. Code: item.SocialSecurityDirectoryCode,
  38054. List_type_code: "301",
  38055. }
  38056. queryResult = append(queryResult, result)
  38057. }
  38058. } else if record_type == 3 {
  38059. projects, _ := service.GetBathchMyPorjecgList(ids)
  38060. for _, item := range projects {
  38061. result := QueryResult{
  38062. ID: item.ID,
  38063. Name: item.ProjectName,
  38064. Code: item.MedicalCode,
  38065. List_type_code: "201",
  38066. }
  38067. queryResult = append(queryResult, result)
  38068. }
  38069. }
  38070. admin_user_id, _ := c.GetInt64("admin_user_id")
  38071. adminUser := c.GetAdminUserInfo()
  38072. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38073. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38074. var user_name string
  38075. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38076. if role.ID == 0 {
  38077. user_name = "管理员"
  38078. } else {
  38079. user_name = role.UserName
  38080. }
  38081. baseParams := models.BaseParams{
  38082. SecretKey: miConfig.SecretKey,
  38083. FixmedinsCode: miConfig.Code,
  38084. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38085. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38086. OrgName: miConfig.OrgName,
  38087. Doctor: user_name,
  38088. }
  38089. var result string
  38090. if miConfig.MdtrtareaAdmvs == "430800" {
  38091. for _, item := range queryResult {
  38092. if record_type == 1 {
  38093. 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)
  38094. } else if record_type == 2 {
  38095. fmt.Println(item.Code)
  38096. 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)
  38097. } else if record_type == 3 {
  38098. 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)
  38099. }
  38100. var dat map[string]interface{}
  38101. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38102. fmt.Println(dat)
  38103. } else {
  38104. fmt.Println(err)
  38105. }
  38106. userJSONBytes, _ := json.Marshal(dat)
  38107. var res ResultSix
  38108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38109. utils.ErrorLog("解析失败:%v", err)
  38110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38111. return
  38112. }
  38113. if res.Infcode == 0 {
  38114. if record_type == 1 {
  38115. service.UpdateBaseDrugById(item.ID)
  38116. } else if record_type == 2 {
  38117. service.UpdateGoodInformaitonByDetail(item.ID)
  38118. } else if record_type == 3 {
  38119. service.UpdateProjectById(item.ID)
  38120. }
  38121. c.ServeSuccessJSON(map[string]interface{}{
  38122. "failed_code": 0,
  38123. "msg": "目录对照成功",
  38124. })
  38125. } else {
  38126. c.ServeSuccessJSON(map[string]interface{}{
  38127. "failed_code": -10,
  38128. "msg": res.ErrMsg,
  38129. })
  38130. }
  38131. }
  38132. } else {
  38133. for _, item := range queryResult {
  38134. var result string
  38135. if record_type == 1 {
  38136. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38137. } else if record_type == 2 {
  38138. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38139. } else if record_type == 3 {
  38140. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38141. }
  38142. var dat map[string]interface{}
  38143. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38144. fmt.Println(dat)
  38145. } else {
  38146. fmt.Println(err)
  38147. }
  38148. userJSONBytes, _ := json.Marshal(dat)
  38149. var res ResultSix
  38150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38151. utils.ErrorLog("解析失败:%v", err)
  38152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38153. return
  38154. }
  38155. if res.Infcode == 0 {
  38156. if record_type == 1 {
  38157. service.UpdateBaseDrugById(item.ID)
  38158. } else if record_type == 2 {
  38159. service.UpdateGoodInformaitonByDetail(item.ID)
  38160. } else if record_type == 3 {
  38161. service.UpdateProjectById(item.ID)
  38162. }
  38163. c.ServeSuccessJSON(map[string]interface{}{
  38164. "failed_code": 0,
  38165. "msg": "目录对照成功",
  38166. })
  38167. } else {
  38168. c.ServeSuccessJSON(map[string]interface{}{
  38169. "failed_code": -10,
  38170. "msg": res.ErrMsg,
  38171. })
  38172. }
  38173. }
  38174. }
  38175. }
  38176. func (c *HisApiController) UnCheckCode() {
  38177. ids_str := c.GetString("ids")
  38178. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38179. admin_user_id, _ := c.GetInt64("admin_user_id")
  38180. ids_arr := strings.Split(ids_str, ",")
  38181. var queryResult []QueryResult
  38182. ids := make([]int64, 0)
  38183. for _, item := range ids_arr {
  38184. id, _ := strconv.ParseInt(item, 10, 64)
  38185. ids = append(ids, id)
  38186. }
  38187. if record_type == 1 {
  38188. drugs, _ := service.GetBatchDrugList(ids)
  38189. for _, item := range drugs {
  38190. result := QueryResult{
  38191. ID: item.ID,
  38192. Name: item.DrugName,
  38193. Code: item.MedicalInsuranceNumber,
  38194. List_type_code: "101",
  38195. }
  38196. queryResult = append(queryResult, result)
  38197. }
  38198. } else if record_type == 2 {
  38199. goods, _ := service.GetBatchGoodInformationList(ids)
  38200. for _, item := range goods {
  38201. result := QueryResult{
  38202. ID: item.ID,
  38203. Name: item.GoodName,
  38204. Code: item.SocialSecurityDirectoryCode,
  38205. List_type_code: "301",
  38206. }
  38207. queryResult = append(queryResult, result)
  38208. }
  38209. } else if record_type == 3 {
  38210. projects, _ := service.GetBathchMyPorjecgList(ids)
  38211. for _, item := range projects {
  38212. result := QueryResult{
  38213. ID: item.ID,
  38214. Name: item.ProjectName,
  38215. Code: item.MedicalCode,
  38216. List_type_code: "201",
  38217. }
  38218. queryResult = append(queryResult, result)
  38219. }
  38220. }
  38221. adminUser := c.GetAdminUserInfo()
  38222. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38223. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38224. var user_name string
  38225. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38226. if role.ID == 0 {
  38227. user_name = "xxx"
  38228. } else {
  38229. user_name = role.UserName
  38230. }
  38231. baseParams := &models.BaseParams{
  38232. SecretKey: miConfig.SecretKey,
  38233. FixmedinsCode: miConfig.Code,
  38234. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38235. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38236. OrgName: miConfig.OrgName,
  38237. Doctor: user_name,
  38238. }
  38239. if config.IsOpen == 1 {
  38240. if miConfig.MdtrtareaAdmvs == "430800" {
  38241. for _, item := range queryResult {
  38242. var result string
  38243. if record_type == 1 {
  38244. 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)
  38245. } else if record_type == 2 {
  38246. fmt.Println(item.Code)
  38247. 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)
  38248. } else if record_type == 3 {
  38249. 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)
  38250. }
  38251. var dat map[string]interface{}
  38252. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38253. fmt.Println(dat)
  38254. } else {
  38255. fmt.Println(err)
  38256. }
  38257. userJSONBytes, _ := json.Marshal(dat)
  38258. var res ResultSix
  38259. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38260. utils.ErrorLog("解析失败:%v", err)
  38261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38262. return
  38263. }
  38264. if res.Infcode == 0 {
  38265. if record_type == 1 {
  38266. service.UpdateBaseDrugById(item.ID)
  38267. } else if record_type == 2 {
  38268. service.UpdateGoodInformaitonByDetail(item.ID)
  38269. } else if record_type == 3 {
  38270. service.UpdateProjectById(item.ID)
  38271. }
  38272. c.ServeSuccessJSON(map[string]interface{}{
  38273. "failed_code": 0,
  38274. "msg": "目录对照成功",
  38275. })
  38276. } else {
  38277. c.ServeSuccessJSON(map[string]interface{}{
  38278. "failed_code": -10,
  38279. "msg": res.ErrMsg,
  38280. })
  38281. }
  38282. }
  38283. } else {
  38284. for _, item := range queryResult {
  38285. var result string
  38286. if record_type == 1 {
  38287. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38288. } else if record_type == 2 {
  38289. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38290. } else if record_type == 3 {
  38291. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38292. }
  38293. var dat2 map[string]interface{}
  38294. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  38295. fmt.Println(dat2)
  38296. } else {
  38297. fmt.Println(err)
  38298. }
  38299. userJSONBytes, _ := json.Marshal(dat2)
  38300. var res ResultSix
  38301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38302. utils.ErrorLog("解析失败:%v", err)
  38303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38304. return
  38305. }
  38306. if res.Infcode == 0 {
  38307. if record_type == 1 {
  38308. service.UpdateDrugByIdDetail(item.ID)
  38309. } else if record_type == 2 {
  38310. service.UpdateGoodInfoById(item.ID)
  38311. } else if record_type == 3 {
  38312. service.UpdateMyProjectById(item.ID)
  38313. }
  38314. c.ServeSuccessJSON(map[string]interface{}{
  38315. "failed_code": 0,
  38316. "msg": "撤销目录对照成功",
  38317. })
  38318. } else {
  38319. c.ServeSuccessJSON(map[string]interface{}{
  38320. "failed_code": -10,
  38321. "msg": res.ErrMsg,
  38322. })
  38323. }
  38324. }
  38325. }
  38326. }
  38327. }
  38328. func (c *HisApiController) GetPatientInfo() {
  38329. id_card_no := c.GetString("id_card_no")
  38330. admin_user_id, _ := c.GetInt64("admin_user_id")
  38331. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  38332. if patient.ID == 0 {
  38333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38334. return
  38335. }
  38336. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  38337. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38338. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  38339. var res ResultTwo
  38340. var res10265 ResultTwo10265
  38341. if config.IsOpen == 1 {
  38342. if miConfig.MdtrtareaAdmvs == "150499" {
  38343. //请求内网数据
  38344. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  38345. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38346. "&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
  38347. resp, requestErr := http.Get(api)
  38348. if requestErr != nil {
  38349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38350. return
  38351. }
  38352. body, ioErr := ioutil.ReadAll(resp.Body)
  38353. if ioErr != nil {
  38354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38356. return
  38357. }
  38358. var respJSON map[string]interface{}
  38359. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38362. return
  38363. }
  38364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38365. result_byte, _ := json.Marshal(respJSON)
  38366. result := string(result_byte)
  38367. var dat map[string]interface{}
  38368. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38369. fmt.Println(dat)
  38370. } else {
  38371. fmt.Println(err)
  38372. }
  38373. userJSONBytes, _ := json.Marshal(dat)
  38374. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38375. utils.ErrorLog("解析失败:%v", err)
  38376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38377. return
  38378. }
  38379. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38380. res.Infcode = Infcode
  38381. res.ErrMsg = res10265.ErrMsg
  38382. res.Output = res10265.Output
  38383. res.InfRefmsgid = res10265.InfRefmsgid
  38384. res.RespondTime = res10265.RespondTime
  38385. res.WarnInfo = res10265.WarnInfo
  38386. } else {
  38387. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  38388. var dat map[string]interface{}
  38389. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38390. fmt.Println(dat)
  38391. } else {
  38392. fmt.Println(err)
  38393. }
  38394. userJSONBytes, _ := json.Marshal(dat)
  38395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38396. utils.ErrorLog("解析失败:%v", err)
  38397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38398. return
  38399. }
  38400. }
  38401. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38402. // utils.ErrorLog("解析失败:%v", err)
  38403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38404. // return
  38405. //}
  38406. for index, item := range res.Output.Iinfo {
  38407. if item.PsnInsuStas == "2" {
  38408. fmt.Println("--------")
  38409. res.Output.Iinfo[index].Insutype = "300"
  38410. res.Output.Iinfo[index].PsnInsuStas = "1"
  38411. }
  38412. }
  38413. fmt.Println(res.Output.Iinfo)
  38414. if res.Infcode != 0 {
  38415. c.ServeSuccessJSON(map[string]interface{}{
  38416. "failed_code": -10,
  38417. "msg": res.ErrMsg,
  38418. })
  38419. } else {
  38420. c.ServeSuccessJSON(map[string]interface{}{
  38421. "failed_code": 0,
  38422. "info": res,
  38423. })
  38424. }
  38425. }
  38426. }
  38427. func (c *HisApiController) PsnPutOnRecord() {
  38428. record_type, _ := c.GetInt64("type")
  38429. patient_id, _ := c.GetInt64("patient_id")
  38430. admin_user_id, _ := c.GetInt64("admin_user_id")
  38431. start_time := c.GetString("start_time")
  38432. end_time := c.GetString("end_time")
  38433. adminUser := c.GetAdminUserInfo()
  38434. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38435. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38436. var patients []*models.Patients
  38437. if record_type == 1 { //全部备案
  38438. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  38439. patients = append(patients, patient...)
  38440. } else { //单个备案
  38441. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38442. patients = append(patients, patient)
  38443. }
  38444. var user_name string
  38445. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38446. if role.ID == 0 {
  38447. user_name = "xxx"
  38448. } else {
  38449. user_name = role.UserName
  38450. }
  38451. if config.IsOpen == 1 {
  38452. for _, item := range patients {
  38453. 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
  38454. resp, requestErr := http.Get(api)
  38455. if requestErr != nil {
  38456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38457. return
  38458. }
  38459. defer resp.Body.Close()
  38460. body, ioErr := ioutil.ReadAll(resp.Body)
  38461. if ioErr != nil {
  38462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38464. return
  38465. }
  38466. var respJSON map[string]interface{}
  38467. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38470. return
  38471. }
  38472. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38473. userJSONBytes, _ := json.Marshal(userJSON)
  38474. var res ResultTwo
  38475. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38476. utils.ErrorLog("解析失败:%v", err)
  38477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38478. return
  38479. }
  38480. if res.Infcode == 0 {
  38481. 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)
  38482. var dat map[string]interface{}
  38483. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38484. fmt.Println(dat)
  38485. } else {
  38486. fmt.Println(err)
  38487. }
  38488. userJSONBytes, _ := json.Marshal(dat)
  38489. var res2 ResultThirteen
  38490. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38491. utils.ErrorLog("解析失败:%v", err)
  38492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38493. return
  38494. }
  38495. if res2.Infcode == 0 {
  38496. psnResult := &models.GdybPsnRecord{
  38497. UserOrgId: adminUser.CurrentOrgId,
  38498. PatientId: item.ID,
  38499. PsnNo: res.Output.Baseinfo.PsnNo,
  38500. Ctime: time.Now().Unix(),
  38501. Mtime: time.Now().Unix(),
  38502. Status: 1,
  38503. IsCancel: 1,
  38504. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38505. }
  38506. service.CreatePsnRecord(psnResult)
  38507. } else {
  38508. c.ServeSuccessJSON(map[string]interface{}{
  38509. "failed_code": -10,
  38510. "msg": res2.ErrMsg,
  38511. })
  38512. return
  38513. }
  38514. }
  38515. }
  38516. }
  38517. }
  38518. func (c *HisApiController) PsnUnPutOnRecord() {
  38519. id, _ := c.GetInt64("id")
  38520. //record_type, _ := c.GetInt64("type")
  38521. admin_user_id, _ := c.GetInt64("admin_user_id")
  38522. adminUser := c.GetAdminUserInfo()
  38523. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38524. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38525. var user_name string
  38526. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38527. if role.ID == 0 {
  38528. user_name = "xxx"
  38529. } else {
  38530. user_name = role.UserName
  38531. }
  38532. psn_record, _ := service.GetPsnRecordById(id)
  38533. if psn_record.ID == 0 {
  38534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38535. return
  38536. }
  38537. if config.IsOpen == 1 {
  38538. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38539. var dat map[string]interface{}
  38540. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38541. fmt.Println(dat)
  38542. } else {
  38543. fmt.Println(err)
  38544. }
  38545. userJSONBytes, _ := json.Marshal(dat)
  38546. var res ResultFourteen
  38547. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38548. utils.ErrorLog("解析失败:%v", err)
  38549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38550. return
  38551. }
  38552. if res.Infcode == 0 {
  38553. psn_record.IsCancel = 2
  38554. service.CreatePsnRecord(&psn_record)
  38555. } else {
  38556. c.ServeSuccessJSON(map[string]interface{}{
  38557. "failed_code": -10,
  38558. "msg": res.ErrMsg,
  38559. })
  38560. return
  38561. }
  38562. }
  38563. }
  38564. func (c *HisApiController) PsnPutNCDSOnRecord() {
  38565. patient_id, _ := c.GetInt64("patient_id")
  38566. insutype_two := c.GetString("insutype")
  38567. psn_no := c.GetString("psn_no")
  38568. doctor_id, _ := c.GetInt64("doctor_id")
  38569. sick_id, _ := c.GetInt64("sick_id")
  38570. department_id, _ := c.GetInt64("department_id")
  38571. start_time := c.GetString("start_time")
  38572. end_time := c.GetString("end_time")
  38573. check_time := c.GetString("check_time")
  38574. hospital_code := c.GetString("hospital_code")
  38575. hospital_name := c.GetString("hospital_name")
  38576. adminUser := c.GetAdminUserInfo()
  38577. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38578. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38579. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38580. sick, _ := service.FindSickById(sick_id)
  38581. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38582. if len(hospital_code) == 0 {
  38583. hospital_code = miConfig.Code
  38584. }
  38585. if len(hospital_name) == 0 {
  38586. hospital_name = miConfig.OrgName
  38587. }
  38588. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38589. var res ResultTwo
  38590. var res10265 ResultTwo10265
  38591. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38592. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  38593. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  38594. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38595. "&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
  38596. resp, requestErr := http.Get(api)
  38597. if requestErr != nil {
  38598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38599. return
  38600. }
  38601. body, ioErr := ioutil.ReadAll(resp.Body)
  38602. if ioErr != nil {
  38603. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38605. return
  38606. }
  38607. var respJSON map[string]interface{}
  38608. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38611. return
  38612. }
  38613. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38614. result, _ := json.Marshal(respJSON)
  38615. fmt.Println("log")
  38616. fmt.Println(string(result))
  38617. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38618. utils.ErrorLog("解析失败:%v", err)
  38619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38620. return
  38621. }
  38622. res.ErrMsg = res10265.ErrMsg
  38623. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38624. res.Infcode = infocode
  38625. res.Output = res10265.Output
  38626. res.InfRefmsgid = res10265.InfRefmsgid
  38627. } else {
  38628. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38629. if miConfig.Code == "H15049901371" {
  38630. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38631. utils.ErrorLog("解析失败:%v", err)
  38632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38633. return
  38634. }
  38635. res.ErrMsg = res10265.ErrMsg
  38636. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38637. res.Infcode = infocode
  38638. res.Output = res10265.Output
  38639. res.InfRefmsgid = res10265.InfRefmsgid
  38640. } else {
  38641. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38642. utils.ErrorLog("解析失败:%v", err)
  38643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38644. return
  38645. }
  38646. }
  38647. }
  38648. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38649. infoStr := string(Iinfos)
  38650. var rf []*ResultFive
  38651. json.Unmarshal([]byte(infoStr), &rf)
  38652. var insuplc_admdvs string
  38653. var insutype string
  38654. var is390 int = 0
  38655. var is310 int = 0
  38656. var insutypes []*ResultFive
  38657. for _, item := range rf {
  38658. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38659. insutypes = append(insutypes, item)
  38660. }
  38661. }
  38662. if len(insutypes) == 1 {
  38663. insutype = insutypes[0].Insutype
  38664. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38665. } else {
  38666. for _, i := range insutypes {
  38667. if i.Insutype == "390" {
  38668. is390 = 1
  38669. }
  38670. if i.Insutype == "310" {
  38671. is310 = 1
  38672. }
  38673. }
  38674. }
  38675. if is390 == 1 {
  38676. insutype = "390"
  38677. }
  38678. if is310 == 1 {
  38679. insutype = "310"
  38680. }
  38681. if len(insutypes) == 2 {
  38682. insutype = insutype_two
  38683. }
  38684. if len(insutypes) == 0 {
  38685. insutype = "310"
  38686. }
  38687. insutype = insutype_two
  38688. fmt.Println(insutype)
  38689. for _, item := range rf {
  38690. fmt.Println(item.Insutype)
  38691. fmt.Println(insutype)
  38692. if item.Insutype == insutype {
  38693. fmt.Println(item.Insutype)
  38694. fmt.Println(insutype)
  38695. insuplc_admdvs = item.InsuplcAdmdvs
  38696. }
  38697. }
  38698. fmt.Println(insuplc_admdvs)
  38699. var res2 ResultThirteen
  38700. var res10265_2 ResultThirteen10265
  38701. if config.IsOpen == 1 {
  38702. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38703. } else {
  38704. if miConfig.MdtrtareaAdmvs == "150499" {
  38705. //
  38706. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  38707. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38708. // "&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
  38709. //resp, requestErr := http.Get(api)
  38710. //if requestErr != nil {
  38711. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38712. // return
  38713. //}
  38714. //
  38715. //body, ioErr := ioutil.ReadAll(resp.Body)
  38716. //if ioErr != nil {
  38717. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38718. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38719. // return
  38720. //}
  38721. //var respJSON map[string]interface{}
  38722. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38723. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38724. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38725. // return
  38726. //}
  38727. //
  38728. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38729. //result, _ := json.Marshal(respJSON)
  38730. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  38731. // utils.ErrorLog("解析失败:%v", err)
  38732. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38733. // return
  38734. //}
  38735. //infocode = resThree.Infcode
  38736. //result, _ := json.Marshal(respJSON)
  38737. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  38738. // utils.ErrorLog("解析失败:%v", err)
  38739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38740. // return
  38741. //}
  38742. //
  38743. //resThree.ErrMsg = resThree10265.ErrMsg
  38744. //
  38745. //resThree.Output = resThree10265.Output
  38746. //
  38747. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  38748. //
  38749. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  38750. //
  38751. } else {
  38752. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, doctor.DoctorNumber, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time, hospital_code, hospital_name)
  38753. var dat map[string]interface{}
  38754. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38755. fmt.Println(dat)
  38756. } else {
  38757. fmt.Println(err)
  38758. }
  38759. userJSONBytes, _ := json.Marshal(dat)
  38760. if miConfig.Code == "H15049901371" {
  38761. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  38762. utils.ErrorLog("解析失败:%v", err)
  38763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38764. return
  38765. }
  38766. res2.ErrMsg = res10265_2.ErrMsg
  38767. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  38768. res2.Infcode = infocode
  38769. res2.Output = res10265_2.Output
  38770. res2.InfRefmsgid = res10265_2.InfRefmsgid
  38771. } else {
  38772. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38773. utils.ErrorLog("解析失败:%v", err)
  38774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38775. return
  38776. }
  38777. }
  38778. }
  38779. }
  38780. if res2.Infcode == 0 {
  38781. psnResult := &models.GdybPsnNcdsRecord{
  38782. UserOrgId: adminUser.CurrentOrgId,
  38783. PatientId: patient.ID,
  38784. PsnNo: psn_no,
  38785. DoctorId: doctor.AdminUserId,
  38786. DepartmentId: department_id,
  38787. SickType: sick_id,
  38788. Insutype: insutype,
  38789. Ctime: time.Now().Unix(),
  38790. Mtime: time.Now().Unix(),
  38791. Status: 1,
  38792. IsCancel: 1,
  38793. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38794. }
  38795. service.CreatePsnNCDSRecord(psnResult)
  38796. c.ServeSuccessJSON(map[string]interface{}{
  38797. "failed_code": 0,
  38798. "msg": "备案成功",
  38799. "result": psnResult,
  38800. })
  38801. } else {
  38802. c.ServeSuccessJSON(map[string]interface{}{
  38803. "failed_code": -10,
  38804. "msg": res2.ErrMsg,
  38805. })
  38806. return
  38807. }
  38808. }
  38809. }
  38810. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  38811. id, _ := c.GetInt64("id")
  38812. admin_user_id, _ := c.GetInt64("admin_user_id")
  38813. adminUser := c.GetAdminUserInfo()
  38814. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38815. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38816. //config, _ := service.Ge(adminUser.CurrentOrgId)
  38817. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  38818. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38819. //var user_name string
  38820. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38821. //if role.ID == 0 {
  38822. // user_name = "xxx"
  38823. //} else {
  38824. // user_name = role.UserName
  38825. //}
  38826. psn_record, _ := service.GetPsnNCDSRecordById(id)
  38827. if psn_record.ID == 0 {
  38828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38829. return
  38830. }
  38831. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38832. var res ResultTwo
  38833. var res10265 ResultTwo10265
  38834. if miConfig.Code == "H15049901371" {
  38835. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38836. utils.ErrorLog("解析失败:%v", err)
  38837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38838. return
  38839. }
  38840. res.ErrMsg = res10265.ErrMsg
  38841. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38842. res.Infcode = infocode
  38843. res.Output = res10265.Output
  38844. res.InfRefmsgid = res10265.InfRefmsgid
  38845. } else {
  38846. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38847. utils.ErrorLog("解析失败:%v", err)
  38848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38849. return
  38850. }
  38851. }
  38852. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38853. infoStr := string(Iinfos)
  38854. var rf []*ResultFive
  38855. json.Unmarshal([]byte(infoStr), &rf)
  38856. var insuplc_admdvs string
  38857. var insutype string
  38858. var is390 int = 0
  38859. var is310 int = 0
  38860. var insutypes []*ResultFive
  38861. for _, item := range rf {
  38862. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38863. insutypes = append(insutypes, item)
  38864. }
  38865. }
  38866. if len(insutypes) == 1 {
  38867. insutype = insutypes[0].Insutype
  38868. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38869. } else {
  38870. for _, i := range insutypes {
  38871. if i.Insutype == "390" {
  38872. is390 = 1
  38873. }
  38874. if i.Insutype == "310" {
  38875. is310 = 1
  38876. }
  38877. }
  38878. }
  38879. if is390 == 1 {
  38880. insutype = "390"
  38881. }
  38882. if is310 == 1 {
  38883. insutype = "310"
  38884. }
  38885. if len(insutypes) == 0 {
  38886. insutype = "310"
  38887. }
  38888. insutype = psn_record.Insutype
  38889. for _, item := range rf {
  38890. if item.Insutype == insutype {
  38891. insuplc_admdvs = item.InsuplcAdmdvs
  38892. }
  38893. }
  38894. if config.IsOpen == 1 {
  38895. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38896. var dat map[string]interface{}
  38897. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38898. fmt.Println(dat)
  38899. } else {
  38900. fmt.Println(err)
  38901. }
  38902. userJSONBytes, _ := json.Marshal(dat)
  38903. var res ResultFourteen
  38904. var res10265 ResultFourteen10265
  38905. if miConfig.Code == "H15049901371" {
  38906. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38907. utils.ErrorLog("解析失败:%v", err)
  38908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38909. return
  38910. }
  38911. res.ErrMsg = res10265.ErrMsg
  38912. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38913. res.Infcode = infocode
  38914. res.Output = res10265.Output
  38915. res.InfRefmsgid = res10265.InfRefmsgid
  38916. } else {
  38917. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38918. utils.ErrorLog("解析失败:%v", err)
  38919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38920. return
  38921. }
  38922. }
  38923. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38924. // utils.ErrorLog("解析失败:%v", err)
  38925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38926. // return
  38927. //}
  38928. if res.Infcode == 0 {
  38929. psn_record.IsCancel = 2
  38930. service.CreatePsnNCDSRecord(&psn_record)
  38931. c.ServeSuccessJSON(map[string]interface{}{
  38932. "failed_code": 0,
  38933. "msg": "撤销备案成功",
  38934. })
  38935. } else {
  38936. c.ServeSuccessJSON(map[string]interface{}{
  38937. "failed_code": -10,
  38938. "msg": res.ErrMsg,
  38939. })
  38940. return
  38941. }
  38942. }
  38943. }
  38944. func (c *HisApiController) TestTest() {
  38945. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  38946. fmt.Println(patient.Iinfo)
  38947. }
  38948. type CustomData struct {
  38949. MsgId string
  38950. PsnNo string
  38951. Info string
  38952. }
  38953. func (c *HisApiController) ReversalData() {
  38954. var customData []*CustomData
  38955. custom := &CustomData{
  38956. MsgId: "H44022900158202103301714472004",
  38957. PsnNo: "44020000001101329945",
  38958. Info: "2207",
  38959. }
  38960. customData = append(customData, custom)
  38961. custom1 := &CustomData{
  38962. MsgId: "H4402290015820210330172057803",
  38963. PsnNo: "44020000001101161813",
  38964. Info: "2207",
  38965. }
  38966. customData = append(customData, custom1)
  38967. custom2 := &CustomData{
  38968. MsgId: "H44022900158202103301705198813",
  38969. PsnNo: "44190000133097375417",
  38970. Info: "2207",
  38971. }
  38972. customData = append(customData, custom2)
  38973. custom3 := &CustomData{
  38974. MsgId: "H44022900158202103301715524756",
  38975. PsnNo: "44020000001100187221",
  38976. Info: "2207",
  38977. }
  38978. customData = append(customData, custom3)
  38979. custom4 := &CustomData{
  38980. MsgId: "H44022900158202103301730376224",
  38981. PsnNo: "44020000001101959155",
  38982. Info: "2207",
  38983. }
  38984. customData = append(customData, custom4)
  38985. custom5 := &CustomData{
  38986. MsgId: "H44022900158202103301748008725",
  38987. PsnNo: "44020000001104246641",
  38988. Info: "2207",
  38989. }
  38990. customData = append(customData, custom5)
  38991. custom6 := &CustomData{
  38992. MsgId: "H44022900158202103301718096755",
  38993. PsnNo: "44020000001102211860",
  38994. Info: "2207",
  38995. }
  38996. customData = append(customData, custom6)
  38997. custom7 := &CustomData{
  38998. MsgId: "H44022900158202103301736551640",
  38999. PsnNo: "44020000001102687718",
  39000. Info: "2207",
  39001. }
  39002. customData = append(customData, custom7)
  39003. custom8 := &CustomData{
  39004. MsgId: "H44022900158202103301743097676",
  39005. PsnNo: "44020000001102127785",
  39006. Info: "2207",
  39007. }
  39008. customData = append(customData, custom8)
  39009. custom9 := &CustomData{
  39010. MsgId: "H44022900158202103301712304203",
  39011. PsnNo: "44020000001101518097",
  39012. Info: "2207",
  39013. }
  39014. customData = append(customData, custom9)
  39015. custom10 := &CustomData{
  39016. MsgId: "H44022900158202103301738448785",
  39017. PsnNo: "44020000001100500813",
  39018. Info: "2207",
  39019. }
  39020. customData = append(customData, custom10)
  39021. custom11 := &CustomData{
  39022. MsgId: "H44022900158202103301732455843",
  39023. PsnNo: "44020000001102690557",
  39024. Info: "2207",
  39025. }
  39026. customData = append(customData, custom11)
  39027. custom12 := &CustomData{
  39028. MsgId: "H44022900158202103301745421708",
  39029. PsnNo: "44020000001102211928",
  39030. Info: "2207",
  39031. }
  39032. customData = append(customData, custom12)
  39033. custom1212 := &CustomData{
  39034. MsgId: "H440229001582021033017351627",
  39035. PsnNo: "44020000001102481733",
  39036. Info: "2207",
  39037. }
  39038. customData = append(customData, custom1212)
  39039. custom13 := &CustomData{
  39040. MsgId: "H44022900158202103301740327951",
  39041. PsnNo: "44020000001103174866",
  39042. Info: "2207",
  39043. }
  39044. customData = append(customData, custom13)
  39045. custom14 := &CustomData{
  39046. MsgId: "H4402290015820210330174922668",
  39047. PsnNo: "44020000001102927272",
  39048. Info: "2207",
  39049. }
  39050. customData = append(customData, custom14)
  39051. custom15 := &CustomData{
  39052. MsgId: "H44022900158202103301752362273",
  39053. PsnNo: "44020000001102942890",
  39054. Info: "2207",
  39055. }
  39056. customData = append(customData, custom15)
  39057. custom16 := &CustomData{
  39058. MsgId: "H44022900158202103301751082917",
  39059. PsnNo: "44020000001101662162",
  39060. Info: "2207",
  39061. }
  39062. customData = append(customData, custom16)
  39063. custom17 := &CustomData{
  39064. MsgId: "H44022900158202103301754147728",
  39065. PsnNo: "44020000000229014511",
  39066. Info: "2207",
  39067. }
  39068. customData = append(customData, custom17)
  39069. adminUser := c.GetAdminUserInfo()
  39070. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39071. for _, item := range customData {
  39072. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39073. fmt.Println(result)
  39074. }
  39075. }
  39076. func (c *HisApiController) GetAllopatry() {
  39077. year := c.GetString("year")
  39078. month := c.GetString("month")
  39079. admin_user_id, _ := c.GetInt64("admin_user_id")
  39080. adminUser := c.GetAdminUserInfo()
  39081. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39082. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39083. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39084. var dat map[string]interface{}
  39085. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39086. fmt.Println(dat)
  39087. } else {
  39088. fmt.Println(err)
  39089. }
  39090. userJSONBytes, _ := json.Marshal(dat)
  39091. var res models.Result9001
  39092. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39093. utils.ErrorLog("解析失败:%v", err)
  39094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39095. return
  39096. }
  39097. fmt.Println(res.Output.Signinoutb)
  39098. fmt.Println(res.Output.Signinoutb.SignNo)
  39099. fmt.Println(string(userJSONBytes))
  39100. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39101. var dat3 map[string]interface{}
  39102. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  39103. fmt.Println(dat3)
  39104. } else {
  39105. fmt.Println(err)
  39106. }
  39107. userJSONBytes3, _ := json.Marshal(dat3)
  39108. var res3 models.Result3260
  39109. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  39110. utils.ErrorLog("解析失败:%v", err)
  39111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39112. return
  39113. }
  39114. var curpage int
  39115. var pagesize int = 100
  39116. var start int = 1
  39117. //var stop int
  39118. //pagecount := 10
  39119. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  39120. var res22 []models.Result3260
  39121. for curpage = 1; curpage <= pagecount; curpage++ {
  39122. if curpage == 1 {
  39123. start = 0
  39124. } else {
  39125. start = (curpage-1)*pagesize + 1
  39126. }
  39127. fmt.Println(start)
  39128. //stop = curpage * pagesize
  39129. //if stop > int(res3.Output.Totalrow) {
  39130. // stop =int(res3.Output.Totalrow)
  39131. //}
  39132. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  39133. var dat2 map[string]interface{}
  39134. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39135. fmt.Println(dat)
  39136. } else {
  39137. fmt.Println(err)
  39138. }
  39139. userJSONBytes2, _ := json.Marshal(dat2)
  39140. var res2 models.Result3260
  39141. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39142. utils.ErrorLog("解析失败:%v", err)
  39143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39144. return
  39145. }
  39146. if res2.Infcode == 0 {
  39147. res22 = append(res22, res2)
  39148. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39149. //var dat2 map[string]interface{}
  39150. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39151. // fmt.Println(dat)
  39152. //} else {
  39153. // fmt.Println(err)
  39154. //}
  39155. //c.ServeSuccessJSON(map[string]interface{}{
  39156. // "list": res2.Output.Data,
  39157. //})
  39158. //continue
  39159. }
  39160. }
  39161. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39162. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39163. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  39164. //var dat2 map[string]interface{}
  39165. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39166. // fmt.Println(dat)
  39167. //} else {
  39168. // fmt.Println(err)
  39169. //}
  39170. //userJSONBytes2, _ := json.Marshal(dat2)
  39171. //var res2 models.Result3260
  39172. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39173. // utils.ErrorLog("解析失败:%v", err)
  39174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39175. // return
  39176. //}
  39177. //if res2.Infcode == 0 {
  39178. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39179. // var dat2 map[string]interface{}
  39180. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39181. // fmt.Println(dat)
  39182. // } else {
  39183. // fmt.Println(err)
  39184. // }
  39185. // c.ServeSuccessJSON(map[string]interface{}{
  39186. // "list": res2.Output.Data,
  39187. // })
  39188. //}
  39189. }
  39190. func (c *HisApiController) ComfirmAllopatry() {
  39191. year := c.GetString("year")
  39192. month := c.GetString("month")
  39193. admin_user_id, _ := c.GetInt64("admin_user_id")
  39194. adminUser := c.GetAdminUserInfo()
  39195. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39196. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39197. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39198. var dat map[string]interface{}
  39199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39200. fmt.Println(dat)
  39201. } else {
  39202. fmt.Println(err)
  39203. }
  39204. userJSONBytes, _ := json.Marshal(dat)
  39205. var res models.Result9001
  39206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39207. utils.ErrorLog("解析失败:%v", err)
  39208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39209. return
  39210. }
  39211. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39212. var dat2 map[string]interface{}
  39213. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39214. fmt.Println(dat)
  39215. } else {
  39216. fmt.Println(err)
  39217. }
  39218. userJSONBytes2, _ := json.Marshal(dat2)
  39219. var res2 models.Result3260
  39220. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39221. utils.ErrorLog("解析失败:%v", err)
  39222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39223. return
  39224. }
  39225. //if res2.Infcode == 0 {
  39226. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39227. // var dat map[string]interface{}
  39228. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39229. // fmt.Println(dat)
  39230. // } else {
  39231. // fmt.Println(err)
  39232. // }
  39233. // userJSONBytes, _ := json.Marshal(dat)
  39234. // var res3 models.Result3261
  39235. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  39236. // utils.ErrorLog("解析失败:%v", err)
  39237. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39238. // return
  39239. // }
  39240. //
  39241. // if res3.Infcode == 0 {
  39242. // record := &models.HisYidiClearRecord{
  39243. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39244. // Ctime: time.Now().Unix(),
  39245. // Mtime: time.Now().Unix(),
  39246. // Status: 1,
  39247. // MsgId: msgId,
  39248. // }
  39249. // service.SaveClearRecord(record)
  39250. // c.ServeSuccessJSON(map[string]interface{}{
  39251. // "msg": "提取成功",
  39252. // })
  39253. // }
  39254. //}
  39255. }
  39256. func (c *HisApiController) RefundAllopatry() {
  39257. year := c.GetString("year")
  39258. month := c.GetString("month")
  39259. //id, _ := c.GetInt64("id")
  39260. admin_user_id, _ := c.GetInt64("admin_user_id")
  39261. adminUser := c.GetAdminUserInfo()
  39262. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39263. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39264. //record, _ := service.GetClearRecordById(id)
  39265. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39266. var dat map[string]interface{}
  39267. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  39268. fmt.Println(dat)
  39269. } else {
  39270. fmt.Println(err)
  39271. }
  39272. userJSONBytes, _ := json.Marshal(dat)
  39273. var res models.Result9001
  39274. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39275. utils.ErrorLog("解析失败:%v", err)
  39276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39277. return
  39278. }
  39279. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  39280. var dat2 map[string]interface{}
  39281. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  39282. fmt.Println(dat)
  39283. } else {
  39284. fmt.Println(err)
  39285. }
  39286. userJSONBytes2, _ := json.Marshal(dat2)
  39287. var empty ResultFourteen
  39288. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  39289. utils.ErrorLog("解析失败:%v", err)
  39290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39291. return
  39292. }
  39293. if empty.Infcode == 0 {
  39294. c.ServeSuccessJSON(map[string]interface{}{
  39295. "msg": "撤销成功",
  39296. })
  39297. return
  39298. }
  39299. }
  39300. func (c *HisApiController) ReversalOtherData() {
  39301. var customData []*CustomData
  39302. custom := &CustomData{
  39303. MsgId: "H44022900158202103301714472004",
  39304. PsnNo: "44020000001101329945",
  39305. Info: "2208",
  39306. }
  39307. customData = append(customData, custom)
  39308. custom1 := &CustomData{
  39309. MsgId: "H4402290015820210330172057803",
  39310. PsnNo: "44020000001101161813",
  39311. Info: "2208",
  39312. }
  39313. customData = append(customData, custom1)
  39314. custom2 := &CustomData{
  39315. MsgId: "H44022900158202103301705198813",
  39316. PsnNo: "44190000133097375417",
  39317. Info: "2208",
  39318. }
  39319. customData = append(customData, custom2)
  39320. custom3 := &CustomData{
  39321. MsgId: "H44022900158202103301715524756",
  39322. PsnNo: "44020000001100187221",
  39323. Info: "2208",
  39324. }
  39325. customData = append(customData, custom3)
  39326. custom4 := &CustomData{
  39327. MsgId: "H44022900158202103301730376224",
  39328. PsnNo: "44020000001101959155",
  39329. Info: "2208",
  39330. }
  39331. customData = append(customData, custom4)
  39332. custom5 := &CustomData{
  39333. MsgId: "H44022900158202103301748008725",
  39334. PsnNo: "44020000001104246641",
  39335. Info: "2208",
  39336. }
  39337. customData = append(customData, custom5)
  39338. custom6 := &CustomData{
  39339. MsgId: "H44022900158202103301718096755",
  39340. PsnNo: "44020000001102211860",
  39341. Info: "2208",
  39342. }
  39343. customData = append(customData, custom6)
  39344. custom7 := &CustomData{
  39345. MsgId: "H44022900158202103301736551640",
  39346. PsnNo: "44020000001102687718",
  39347. Info: "2208",
  39348. }
  39349. customData = append(customData, custom7)
  39350. custom8 := &CustomData{
  39351. MsgId: "H44022900158202103301743097676",
  39352. PsnNo: "44020000001102127785",
  39353. Info: "2208",
  39354. }
  39355. customData = append(customData, custom8)
  39356. custom9 := &CustomData{
  39357. MsgId: "H44022900158202103301712304203",
  39358. PsnNo: "44020000001101518097",
  39359. Info: "2208",
  39360. }
  39361. customData = append(customData, custom9)
  39362. custom10 := &CustomData{
  39363. MsgId: "H44022900158202103301738448785",
  39364. PsnNo: "44020000001100500813",
  39365. Info: "2208",
  39366. }
  39367. customData = append(customData, custom10)
  39368. custom11 := &CustomData{
  39369. MsgId: "H44022900158202103301732455843",
  39370. PsnNo: "44020000001102690557",
  39371. Info: "2208",
  39372. }
  39373. customData = append(customData, custom11)
  39374. custom12 := &CustomData{
  39375. MsgId: "H44022900158202103301745421708",
  39376. PsnNo: "44020000001102211928",
  39377. Info: "2208",
  39378. }
  39379. customData = append(customData, custom12)
  39380. custom1212 := &CustomData{
  39381. MsgId: "H440229001582021033017351627",
  39382. PsnNo: "44020000001102481733",
  39383. Info: "2208",
  39384. }
  39385. customData = append(customData, custom1212)
  39386. custom13 := &CustomData{
  39387. MsgId: "H44022900158202103301740327951",
  39388. PsnNo: "44020000001103174866",
  39389. Info: "2208",
  39390. }
  39391. customData = append(customData, custom13)
  39392. custom14 := &CustomData{
  39393. MsgId: "H4402290015820210330174922668",
  39394. PsnNo: "44020000001102927272",
  39395. Info: "2208",
  39396. }
  39397. customData = append(customData, custom14)
  39398. custom15 := &CustomData{
  39399. MsgId: "H44022900158202103301752362273",
  39400. PsnNo: "44020000001102942890",
  39401. Info: "2208",
  39402. }
  39403. customData = append(customData, custom15)
  39404. custom16 := &CustomData{
  39405. MsgId: "H44022900158202103301751082917",
  39406. PsnNo: "44020000001101662162",
  39407. Info: "2208",
  39408. }
  39409. customData = append(customData, custom16)
  39410. custom17 := &CustomData{
  39411. MsgId: "H44022900158202103301754147728",
  39412. PsnNo: "44020000000229014511",
  39413. Info: "2208",
  39414. }
  39415. customData = append(customData, custom17)
  39416. adminUser := c.GetAdminUserInfo()
  39417. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39418. for _, item := range customData {
  39419. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39420. fmt.Println(result)
  39421. }
  39422. }
  39423. func PathExists(path string) (bool, error) {
  39424. _, err := os.Stat(path)
  39425. if err == nil {
  39426. return true, nil
  39427. }
  39428. if os.IsNotExist(err) {
  39429. return false, nil
  39430. }
  39431. return false, err
  39432. }
  39433. // 创建文件夹
  39434. func Mkdir(dir string) {
  39435. // 创建文件夹
  39436. exist, err := PathExists(dir)
  39437. if err != nil {
  39438. fmt.Println(err.Error())
  39439. } else {
  39440. if exist {
  39441. fmt.Println(dir + "文件夹已存在!")
  39442. } else {
  39443. // 文件夹名称,权限
  39444. err := os.Mkdir(dir, os.ModePerm)
  39445. if err != nil {
  39446. fmt.Println(dir+"文件夹创建失败:", err.Error())
  39447. } else {
  39448. fmt.Println(dir + "文件夹创建成功!")
  39449. }
  39450. }
  39451. }
  39452. }
  39453. // 压缩文件
  39454. func Zip(srcFile string, destZip string) error {
  39455. zipfile, err := os.Create(destZip)
  39456. if err != nil {
  39457. return err
  39458. }
  39459. defer zipfile.Close()
  39460. archive := zip.NewWriter(zipfile)
  39461. defer archive.Close()
  39462. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  39463. if err != nil {
  39464. return err
  39465. }
  39466. header, err := zip.FileInfoHeader(info)
  39467. if err != nil {
  39468. return err
  39469. }
  39470. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  39471. // header.Name = path
  39472. if info.IsDir() {
  39473. header.Name += "/"
  39474. } else {
  39475. header.Method = zip.Deflate
  39476. }
  39477. writer, err := archive.CreateHeader(header)
  39478. if err != nil {
  39479. return err
  39480. }
  39481. if !info.IsDir() {
  39482. file, err := os.Open(path)
  39483. if err != nil {
  39484. return err
  39485. }
  39486. defer file.Close()
  39487. _, err = io.Copy(writer, file)
  39488. }
  39489. return err
  39490. })
  39491. return err
  39492. }
  39493. func ReadFile(filePath string) []byte {
  39494. f, err := os.Open(filePath)
  39495. if err != nil {
  39496. fmt.Println("read file fail", err)
  39497. return nil
  39498. }
  39499. defer f.Close()
  39500. fd, err := ioutil.ReadAll(f)
  39501. if err != nil {
  39502. fmt.Println("read to fd fail", err)
  39503. return nil
  39504. }
  39505. return fd
  39506. }
  39507. func saveLogq(result string, request string, infno string, desc string) {
  39508. dir := "日志"
  39509. utils.Mkdir(dir)
  39510. month := time.Unix(1557042972, 0).Format("1")
  39511. year := time.Now().Format("2006")
  39512. month = time.Now().Format("01")
  39513. day := time.Now().Format("02")
  39514. hour := time.Now().Format("15")
  39515. min := time.Now().Format("04")
  39516. sec := time.Now().Format("05")
  39517. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39518. file := year + month + day + "_log"
  39519. file_name := file + ".txt"
  39520. file_path := "日志" + "/" + file_name
  39521. exist, _ := utils.PathExists(file_path)
  39522. if exist { //存在
  39523. fmt.Println("存在")
  39524. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39525. if err != nil {
  39526. fmt.Println("read fail")
  39527. }
  39528. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39529. n, _ := f.Seek(0, 2)
  39530. _, err = f.WriteAt([]byte(content), n)
  39531. } else { //不存在
  39532. fmt.Println("文件不存在,创建文件")
  39533. f, err := os.Create("日志" + "/" + file_name)
  39534. defer f.Close()
  39535. if err != nil {
  39536. } else {
  39537. _, err = f.Write([]byte("记录日志"))
  39538. }
  39539. }
  39540. }
  39541. func saveLog(result string, request string, infno string, desc string) {
  39542. org_id, _ := beego.AppConfig.Int64("org_id")
  39543. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39544. dir := miConfig.OrgName + "日志"
  39545. utils.Mkdir(dir)
  39546. month := time.Unix(1557042972, 0).Format("1")
  39547. year := time.Now().Format("2006")
  39548. month = time.Now().Format("01")
  39549. day := time.Now().Format("02")
  39550. hour := time.Now().Format("15")
  39551. min := time.Now().Format("04")
  39552. sec := time.Now().Format("05")
  39553. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39554. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  39555. file_name := file + ".txt"
  39556. file_path := miConfig.OrgName + "日志" + "/" + file_name
  39557. exist, _ := utils.PathExists(file_path)
  39558. if exist { //存在
  39559. fmt.Println("存在")
  39560. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39561. if err != nil {
  39562. fmt.Println("read fail")
  39563. }
  39564. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39565. n, _ := f.Seek(0, 2)
  39566. _, err = f.WriteAt([]byte(content), n)
  39567. } else { //不存在
  39568. fmt.Println("文件不存在,创建文件")
  39569. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  39570. defer f.Close()
  39571. if err != nil {
  39572. } else {
  39573. _, err = f.Write([]byte("记录日志"))
  39574. }
  39575. }
  39576. }
  39577. type Charset string
  39578. const (
  39579. UTF8 = Charset("UTF-8")
  39580. GB18030 = Charset("GB18030")
  39581. )
  39582. func ConvertToString(src string, srcCode string, tagCode string) string {
  39583. srcCoder := mahonia.NewDecoder(srcCode)
  39584. srcResult := srcCoder.ConvertString(src)
  39585. tagCoder := mahonia.NewDecoder(tagCode)
  39586. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  39587. result := string(cdata)
  39588. return result
  39589. }
  39590. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  39591. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39592. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39593. var token string
  39594. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39595. var api string
  39596. if miConfig.MdtrtareaAdmvs == "320830" {
  39597. api = miConfig.AppSecret + "jsyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39598. "&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
  39599. fmt.Println(api)
  39600. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39601. 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 +
  39602. "&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
  39603. fmt.Println(api)
  39604. } else {
  39605. 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 +
  39606. "&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
  39607. }
  39608. resp, requestErr := http.Get(api)
  39609. if requestErr != nil {
  39610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39611. return ""
  39612. }
  39613. body, ioErr := ioutil.ReadAll(resp.Body)
  39614. if ioErr != nil {
  39615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39617. return ""
  39618. }
  39619. var respJSON map[string]interface{}
  39620. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39623. return ""
  39624. }
  39625. var status string
  39626. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39627. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39628. var res ResultTwo //1101结果
  39629. var res10265 ResultTwo10265 //1101结果
  39630. if status == "0" { //读卡成功
  39631. var card_info string //卡信息
  39632. var busi_card_info string
  39633. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39634. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39635. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39636. fmt.Println(card_info)
  39637. fmt.Println(busi_card_info)
  39638. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39639. result, _ := json.Marshal(respJSON)
  39640. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39641. utils.ErrorLog("解析失败:%v", err)
  39642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39643. return ""
  39644. }
  39645. res.ErrMsg = res10265.ErrMsg
  39646. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39647. res.Infcode = infocode
  39648. res.Output = res10265.Output
  39649. res.InfRefmsgid = res10265.InfRefmsgid
  39650. if res.Infcode == 0 {
  39651. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39652. if err == gorm.ErrRecordNotFound {
  39653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39654. return ""
  39655. } else if err != nil {
  39656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39657. return ""
  39658. } else {
  39659. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39660. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39661. infoStr := string(Iinfos)
  39662. idetinfoStr := string(Idetinfos)
  39663. psn := &models.HisPsn{
  39664. PsnNo: res.Output.Baseinfo.PsnNo,
  39665. PatientId: patient.ID,
  39666. Certno: res.Output.Baseinfo.Certno,
  39667. Gend: res.Output.Baseinfo.Gend,
  39668. Naty: res.Output.Baseinfo.Naty,
  39669. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39670. PsnName: res.Output.Baseinfo.PsnName,
  39671. Idetinfo: idetinfoStr,
  39672. Insuinfo: infoStr,
  39673. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39674. CardInfo: card_info,
  39675. VerifyNumber: token,
  39676. }
  39677. service.CreateHisPsn(psn)
  39678. return token
  39679. }
  39680. }
  39681. } else {
  39682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39683. return ""
  39684. }
  39685. } else { //读卡失败
  39686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39687. return ""
  39688. }
  39689. return token
  39690. }
  39691. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  39692. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39693. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39694. var token string
  39695. var api string
  39696. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39697. "&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
  39698. fmt.Println(api)
  39699. resp, requestErr := http.Get(api)
  39700. if requestErr != nil {
  39701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39702. return ""
  39703. }
  39704. body, ioErr := ioutil.ReadAll(resp.Body)
  39705. if ioErr != nil {
  39706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39708. return ""
  39709. }
  39710. var respJSON map[string]interface{}
  39711. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39714. return ""
  39715. }
  39716. var status string
  39717. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39718. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39719. var res ResultTwo //1101结果
  39720. if status == "1" { //读卡成功
  39721. var card_info string //卡信息
  39722. var busi_card_info string
  39723. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39724. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39725. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39726. fmt.Println(card_info)
  39727. fmt.Println(busi_card_info)
  39728. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39729. result, _ := json.Marshal(respJSON)
  39730. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39731. utils.ErrorLog("解析失败:%v", err)
  39732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39733. return ""
  39734. }
  39735. if res.Infcode == 0 {
  39736. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39737. if err == gorm.ErrRecordNotFound {
  39738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39739. return ""
  39740. } else if err != nil {
  39741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39742. return ""
  39743. } else {
  39744. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39745. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39746. infoStr := string(Iinfos)
  39747. idetinfoStr := string(Idetinfos)
  39748. psn := &models.HisPsn{
  39749. PsnNo: res.Output.Baseinfo.PsnNo,
  39750. PatientId: patient.ID,
  39751. Certno: res.Output.Baseinfo.Certno,
  39752. Gend: res.Output.Baseinfo.Gend,
  39753. Naty: res.Output.Baseinfo.Naty,
  39754. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39755. PsnName: res.Output.Baseinfo.PsnName,
  39756. Idetinfo: idetinfoStr,
  39757. Insuinfo: infoStr,
  39758. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39759. CardInfo: card_info,
  39760. VerifyNumber: token,
  39761. }
  39762. service.CreateHisPsn(psn)
  39763. return token
  39764. }
  39765. }
  39766. } else {
  39767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39768. return ""
  39769. }
  39770. return token
  39771. }
  39772. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  39773. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39774. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39775. var token string
  39776. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39777. var api string
  39778. if miConfig.MdtrtareaAdmvs == "320830" {
  39779. api = miConfig.AppSecret + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39780. "&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
  39781. fmt.Println(api)
  39782. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39783. 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 +
  39784. "&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
  39785. fmt.Println(api)
  39786. } else {
  39787. 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 +
  39788. "&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
  39789. }
  39790. resp, requestErr := http.Get(api)
  39791. if requestErr != nil {
  39792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39793. return ""
  39794. }
  39795. body, ioErr := ioutil.ReadAll(resp.Body)
  39796. if ioErr != nil {
  39797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39799. return ""
  39800. }
  39801. var respJSON map[string]interface{}
  39802. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39805. return ""
  39806. }
  39807. var status string
  39808. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39809. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39810. var res ResultTwo //1101结果
  39811. var res10265 ResultTwo10265 //1101结果
  39812. if status == "0" { //读卡成功
  39813. var card_info string //卡信息
  39814. var busi_card_info string
  39815. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39816. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39817. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39818. fmt.Println(card_info)
  39819. fmt.Println(busi_card_info)
  39820. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39821. result, _ := json.Marshal(respJSON)
  39822. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39823. utils.ErrorLog("解析失败:%v", err)
  39824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39825. return ""
  39826. }
  39827. res.ErrMsg = res10265.ErrMsg
  39828. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39829. res.Infcode = infocode
  39830. res.Output = res10265.Output
  39831. res.InfRefmsgid = res10265.InfRefmsgid
  39832. if res.Infcode == 0 {
  39833. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39834. if err == gorm.ErrRecordNotFound {
  39835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39836. return ""
  39837. } else if err != nil {
  39838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39839. return ""
  39840. } else {
  39841. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39842. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39843. infoStr := string(Iinfos)
  39844. idetinfoStr := string(Idetinfos)
  39845. psn := &models.HisPsn{
  39846. PsnNo: res.Output.Baseinfo.PsnNo,
  39847. PatientId: patient.ID,
  39848. Certno: res.Output.Baseinfo.Certno,
  39849. Gend: res.Output.Baseinfo.Gend,
  39850. Naty: res.Output.Baseinfo.Naty,
  39851. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39852. PsnName: res.Output.Baseinfo.PsnName,
  39853. Idetinfo: idetinfoStr,
  39854. Insuinfo: infoStr,
  39855. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39856. CardInfo: card_info,
  39857. VerifyNumber: token,
  39858. }
  39859. service.CreateHisPsn(psn)
  39860. return token
  39861. }
  39862. }
  39863. } else {
  39864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39865. return ""
  39866. }
  39867. } else { //读卡失败
  39868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39869. return ""
  39870. }
  39871. return token
  39872. }
  39873. func DeleteExtraSpaceTwo(s string) string {
  39874. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39875. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39876. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39877. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39878. s2 := make([]byte, len(s1)) //定义字符数组切片
  39879. copy(s2, s1) //将字符串复制到切片
  39880. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39881. for len(spc_index) > 0 { //找到适配项
  39882. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39883. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39884. }
  39885. return string(s2)
  39886. }
  39887. func Remove0000(s string) string {
  39888. str := make([]rune, 0, len(s))
  39889. for _, v := range []rune(s) {
  39890. if v == 0 {
  39891. continue
  39892. }
  39893. str = append(str, v)
  39894. }
  39895. return string(str)
  39896. }
  39897. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  39898. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  39899. readCard := DllDef.MustFindProc("EcQuery")
  39900. pCardInfo := make([]byte, 8192)
  39901. pBusiCardInfo := make([]byte, 8192)
  39902. data := make(map[string]interface{})
  39903. //pData := make(map[string]interface{})
  39904. inputData := make(map[string]interface{})
  39905. inputData["orgId"] = code
  39906. inputData["businessType"] = "01101"
  39907. inputData["operatorId"] = operator_id
  39908. inputData["operatorName"] = operator_name
  39909. inputData["officeId"] = "001"
  39910. inputData["officeName"] = "血透室"
  39911. //
  39912. data["data"] = inputData
  39913. data["transType"] = "ec.query"
  39914. data["orgId"] = code
  39915. bytesData, _ := json.Marshal(data)
  39916. pCardInfo = bytesData
  39917. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  39918. fmt.Println(ret2)
  39919. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  39920. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  39921. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  39922. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  39923. if ret2 != 0 {
  39924. return "", ""
  39925. }
  39926. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  39927. }
  39928. func DeleteExtraSpace(s string) string {
  39929. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39930. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39931. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39932. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39933. s2 := make([]byte, len(s1)) //定义字符数组切片
  39934. copy(s2, s1) //将字符串复制到切片
  39935. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39936. for len(spc_index) > 0 { //找到适配项
  39937. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39938. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39939. }
  39940. return string(s2)
  39941. }
  39942. // 对账
  39943. func (c *HisApiController) Post3202() {
  39944. start_time := c.GetString("start_time")
  39945. end_time := c.GetString("end_time")
  39946. //insutype := c.GetString("insutype")
  39947. clr_type := c.GetString("clr_type")
  39948. clr_org := c.GetString("clr_optins")
  39949. admin_user_id, _ := c.GetInt64("admin_user_id")
  39950. adminUser := c.GetAdminUserInfo()
  39951. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39952. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39953. if len(clr_org) == 0 {
  39954. clr_org = miConfig.MdtrtareaAdmvs
  39955. }
  39956. timeLayout := "2006-01-02"
  39957. loc, _ := time.LoadLocation("Local")
  39958. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39959. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39960. var orders []*models.HisOrder
  39961. if clr_org == "421300" {
  39962. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39963. } else if clr_org == "420902" {
  39964. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39965. } else {
  39966. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39967. }
  39968. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39969. //fixmedins_setl_cnt := int64(len(orders))
  39970. var medfee_sumamt float64
  39971. var acct_pay float64
  39972. var fund_pay_sumamt float64
  39973. for _, item := range orders {
  39974. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39975. acct_pay = acct_pay + item.AcctPay
  39976. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39977. }
  39978. //var medfee_sumamt_two float64
  39979. //var acct_pay_two float64
  39980. //var fund_pay_sumamt_two float64
  39981. //for _, item := range orders_two {
  39982. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39983. // acct_pay_two = acct_pay_two + item.AcctPay
  39984. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39985. //}
  39986. //var user_name string
  39987. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39988. //if role.ID == 0 {
  39989. // user_name = "xxx"
  39990. //} else {
  39991. // user_name = role.UserName
  39992. //}
  39993. var res ResultSix
  39994. if config.IsOpen == 1 {
  39995. var bps []*models.BusinessParamsTwo
  39996. var bp models.BusinessParamsTwo
  39997. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39998. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39999. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40000. bp.MedfeeSumamt = medfee_sumamt_str
  40001. bp.AcctPay = acct_pay_str
  40002. bp.FundPaySumamt = fund_pay_sumamt_str
  40003. bp.Insutype = ""
  40004. bp.StmtBegndate = start_time
  40005. bp.ClrType = clr_type
  40006. bp.SetlOptins = clr_org
  40007. bp.StmtEnddate = end_time
  40008. bps = append(bps, &bp)
  40009. data := make(map[string]interface{})
  40010. data["bps"] = bps
  40011. data["org_name"] = miConfig.OrgName
  40012. data["doctor"] = role.UserName
  40013. data["fixmedins_code"] = miConfig.Code
  40014. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40015. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40016. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40017. if miConfig.MdtrtareaAdmvs == "421300" {
  40018. client := &http.Client{}
  40019. bytesData, _ := json.Marshal(data)
  40020. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  40021. resp, _ := client.Do(req)
  40022. defer resp.Body.Close()
  40023. body, ioErr := ioutil.ReadAll(resp.Body)
  40024. if ioErr != nil {
  40025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40027. return
  40028. }
  40029. var respJSON map[string]interface{}
  40030. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40033. return
  40034. }
  40035. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40036. userJSONBytes, _ := json.Marshal(respJSON)
  40037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40038. utils.ErrorLog("解析失败:%v", err)
  40039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40040. return
  40041. }
  40042. }
  40043. if miConfig.MdtrtareaAdmvs == "420200" {
  40044. client := &http.Client{}
  40045. bytesData, _ := json.Marshal(data)
  40046. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  40047. resp, _ := client.Do(req)
  40048. defer resp.Body.Close()
  40049. body, ioErr := ioutil.ReadAll(resp.Body)
  40050. if ioErr != nil {
  40051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40053. return
  40054. }
  40055. var respJSON map[string]interface{}
  40056. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40059. return
  40060. }
  40061. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40062. userJSONBytes, _ := json.Marshal(respJSON)
  40063. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40064. utils.ErrorLog("解析失败:%v", err)
  40065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40066. return
  40067. }
  40068. }
  40069. if miConfig.MdtrtareaAdmvs == "421182" {
  40070. client := &http.Client{}
  40071. bytesData, _ := json.Marshal(data)
  40072. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  40073. resp, _ := client.Do(req)
  40074. defer resp.Body.Close()
  40075. body, ioErr := ioutil.ReadAll(resp.Body)
  40076. if ioErr != nil {
  40077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40079. return
  40080. }
  40081. var respJSON map[string]interface{}
  40082. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40085. return
  40086. }
  40087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40088. userJSONBytes, _ := json.Marshal(respJSON)
  40089. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40090. utils.ErrorLog("解析失败:%v", err)
  40091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40092. return
  40093. }
  40094. }
  40095. if miConfig.MdtrtareaAdmvs == "420902" {
  40096. client := &http.Client{}
  40097. bytesData, _ := json.Marshal(data)
  40098. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  40099. resp, _ := client.Do(req)
  40100. defer resp.Body.Close()
  40101. body, ioErr := ioutil.ReadAll(resp.Body)
  40102. if ioErr != nil {
  40103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40105. return
  40106. }
  40107. var respJSON map[string]interface{}
  40108. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40111. return
  40112. }
  40113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40114. userJSONBytes, _ := json.Marshal(respJSON)
  40115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40116. utils.ErrorLog("解析失败:%v", err)
  40117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40118. return
  40119. }
  40120. }
  40121. if res.Infcode == 0 {
  40122. c.ServeSuccessJSON(map[string]interface{}{
  40123. "msg": "发起成功",
  40124. })
  40125. } else {
  40126. c.ServeSuccessJSON(map[string]interface{}{
  40127. "failed_code": -10,
  40128. "msg": res.ErrMsg,
  40129. })
  40130. }
  40131. }
  40132. }
  40133. func (c *HisApiController) Post3204a() {
  40134. start_time := c.GetString("start_time")
  40135. end_time := c.GetString("end_time")
  40136. //insutype := c.GetString("insutype")
  40137. clr_type := c.GetString("clr_type")
  40138. clr_org := c.GetString("clr_optins")
  40139. admin_user_id, _ := c.GetInt64("admin_user_id")
  40140. adminUser := c.GetAdminUserInfo()
  40141. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40142. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40143. if len(clr_org) == 0 {
  40144. clr_org = miConfig.MdtrtareaAdmvs
  40145. }
  40146. timeLayout := "2006-01-02"
  40147. loc, _ := time.LoadLocation("Local")
  40148. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40149. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40150. var orders []*models.HisOrder
  40151. if clr_org == "421300" {
  40152. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40153. } else if clr_org == "420902" {
  40154. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40155. } else {
  40156. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40157. }
  40158. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40159. //fixmedins_setl_cnt := int64(len(orders))
  40160. var medfee_sumamt float64
  40161. var acct_pay float64
  40162. var fund_pay_sumamt float64
  40163. for _, item := range orders {
  40164. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40165. acct_pay = acct_pay + item.AcctPay
  40166. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40167. }
  40168. //var medfee_sumamt_two float64
  40169. //var acct_pay_two float64
  40170. //var fund_pay_sumamt_two float64
  40171. //for _, item := range orders_two {
  40172. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40173. // acct_pay_two = acct_pay_two + item.AcctPay
  40174. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40175. //}
  40176. //var user_name string
  40177. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40178. //if role.ID == 0 {
  40179. // user_name = "xxx"
  40180. //} else {
  40181. // user_name = role.UserName
  40182. //}
  40183. var res ResultSix
  40184. if config.IsOpen == 1 {
  40185. var bps []*models.BusinessParamsTwo
  40186. var bp models.BusinessParamsTwo
  40187. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40188. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40189. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40190. bp.MedfeeSumamt = medfee_sumamt_str
  40191. bp.AcctPay = acct_pay_str
  40192. bp.FundPaySumamt = fund_pay_sumamt_str
  40193. bp.Insutype = ""
  40194. bp.StmtBegndate = start_time
  40195. bp.ClrType = clr_type
  40196. bp.SetlOptins = clr_org
  40197. bp.StmtEnddate = end_time
  40198. bps = append(bps, &bp)
  40199. data := make(map[string]interface{})
  40200. data["bps"] = bps
  40201. data["org_name"] = miConfig.OrgName
  40202. data["doctor"] = role.UserName
  40203. data["fixmedins_code"] = miConfig.Code
  40204. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40205. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40206. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40207. if miConfig.MdtrtareaAdmvs == "421300" {
  40208. client := &http.Client{}
  40209. bytesData, _ := json.Marshal(data)
  40210. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40211. resp, _ := client.Do(req)
  40212. defer resp.Body.Close()
  40213. body, ioErr := ioutil.ReadAll(resp.Body)
  40214. if ioErr != nil {
  40215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40217. return
  40218. }
  40219. var respJSON map[string]interface{}
  40220. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40223. return
  40224. }
  40225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40226. userJSONBytes, _ := json.Marshal(respJSON)
  40227. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40228. utils.ErrorLog("解析失败:%v", err)
  40229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40230. return
  40231. }
  40232. }
  40233. if miConfig.MdtrtareaAdmvs == "420200" {
  40234. client := &http.Client{}
  40235. bytesData, _ := json.Marshal(data)
  40236. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40237. resp, _ := client.Do(req)
  40238. defer resp.Body.Close()
  40239. body, ioErr := ioutil.ReadAll(resp.Body)
  40240. if ioErr != nil {
  40241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40243. return
  40244. }
  40245. var respJSON map[string]interface{}
  40246. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40249. return
  40250. }
  40251. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40252. userJSONBytes, _ := json.Marshal(respJSON)
  40253. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40254. utils.ErrorLog("解析失败:%v", err)
  40255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40256. return
  40257. }
  40258. }
  40259. if miConfig.MdtrtareaAdmvs == "421182" {
  40260. client := &http.Client{}
  40261. bytesData, _ := json.Marshal(data)
  40262. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40263. resp, _ := client.Do(req)
  40264. defer resp.Body.Close()
  40265. body, ioErr := ioutil.ReadAll(resp.Body)
  40266. if ioErr != nil {
  40267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40269. return
  40270. }
  40271. var respJSON map[string]interface{}
  40272. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40275. return
  40276. }
  40277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40278. userJSONBytes, _ := json.Marshal(respJSON)
  40279. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40280. utils.ErrorLog("解析失败:%v", err)
  40281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40282. return
  40283. }
  40284. }
  40285. if miConfig.MdtrtareaAdmvs == "420902" {
  40286. client := &http.Client{}
  40287. bytesData, _ := json.Marshal(data)
  40288. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40289. resp, _ := client.Do(req)
  40290. defer resp.Body.Close()
  40291. body, ioErr := ioutil.ReadAll(resp.Body)
  40292. if ioErr != nil {
  40293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40295. return
  40296. }
  40297. var respJSON map[string]interface{}
  40298. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40301. return
  40302. }
  40303. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40304. userJSONBytes, _ := json.Marshal(respJSON)
  40305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40306. utils.ErrorLog("解析失败:%v", err)
  40307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40308. return
  40309. }
  40310. }
  40311. if res.Infcode == 0 {
  40312. c.ServeSuccessJSON(map[string]interface{}{
  40313. "msg": "撤销成功",
  40314. })
  40315. } else {
  40316. c.ServeSuccessJSON(map[string]interface{}{
  40317. "failed_code": -10,
  40318. "msg": res.ErrMsg,
  40319. })
  40320. }
  40321. }
  40322. }
  40323. func (c *HisApiController) Post3204() {
  40324. admin_user_id, _ := c.GetInt64("admin_user_id")
  40325. id := c.GetString("id")
  40326. adminUser := c.GetAdminUserInfo()
  40327. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40328. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40329. //clr_org := miConfig.MdtrtareaAdmvs
  40330. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40331. var res ResultSix
  40332. if config.IsOpen == 1 {
  40333. data := make(map[string]interface{})
  40334. data["id"] = id
  40335. data["org_name"] = miConfig.OrgName
  40336. data["doctor"] = role.UserName
  40337. data["fixmedins_code"] = miConfig.Code
  40338. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40339. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40340. client := &http.Client{}
  40341. bytesData, _ := json.Marshal(data)
  40342. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  40343. resp, _ := client.Do(req)
  40344. defer resp.Body.Close()
  40345. body, ioErr := ioutil.ReadAll(resp.Body)
  40346. if ioErr != nil {
  40347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40349. return
  40350. }
  40351. var respJSON map[string]interface{}
  40352. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40355. return
  40356. }
  40357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40358. userJSONBytes, _ := json.Marshal(respJSON)
  40359. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40360. utils.ErrorLog("解析失败:%v", err)
  40361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40362. return
  40363. }
  40364. if res.Infcode == 0 {
  40365. c.ServeSuccessJSON(map[string]interface{}{
  40366. "msg": "发起成功",
  40367. })
  40368. } else {
  40369. c.ServeSuccessJSON(map[string]interface{}{
  40370. "failed_code": -10,
  40371. "msg": res.ErrMsg,
  40372. })
  40373. }
  40374. }
  40375. }
  40376. func (c *HisApiController) Post8404() {
  40377. admin_user_id, _ := c.GetInt64("admin_user_id")
  40378. month := c.GetString("month")
  40379. adminUser := c.GetAdminUserInfo()
  40380. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40381. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40382. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40383. var res ResultSix
  40384. if config.IsOpen == 1 {
  40385. data := make(map[string]interface{})
  40386. data["month"] = month
  40387. data["org_name"] = miConfig.OrgName
  40388. data["doctor"] = role.UserName
  40389. data["fixmedins_code"] = miConfig.Code
  40390. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40391. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40392. client := &http.Client{}
  40393. bytesData, _ := json.Marshal(data)
  40394. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  40395. resp, _ := client.Do(req)
  40396. defer resp.Body.Close()
  40397. body, ioErr := ioutil.ReadAll(resp.Body)
  40398. if ioErr != nil {
  40399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40401. return
  40402. }
  40403. var respJSON map[string]interface{}
  40404. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40407. return
  40408. }
  40409. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40410. userJSONBytes, _ := json.Marshal(respJSON)
  40411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40412. utils.ErrorLog("解析失败:%v", err)
  40413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40414. return
  40415. }
  40416. if res.Infcode == 0 {
  40417. c.ServeSuccessJSON(map[string]interface{}{
  40418. "msg": "查询成功",
  40419. })
  40420. } else {
  40421. c.ServeSuccessJSON(map[string]interface{}{
  40422. "failed_code": -10,
  40423. "msg": res.ErrMsg,
  40424. })
  40425. }
  40426. }
  40427. }
  40428. func (c *HisApiController) Post3202b() {
  40429. start_time := c.GetString("start_time")
  40430. end_time := c.GetString("end_time")
  40431. //insutype := c.GetString("insutype")
  40432. clr_type := c.GetString("clr_type")
  40433. clr_org := c.GetString("clr_optins")
  40434. admin_user_id, _ := c.GetInt64("admin_user_id")
  40435. adminUser := c.GetAdminUserInfo()
  40436. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40437. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40438. if len(clr_org) == 0 {
  40439. clr_org = miConfig.MdtrtareaAdmvs
  40440. }
  40441. timeLayout := "2006-01-02"
  40442. loc, _ := time.LoadLocation("Local")
  40443. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40444. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40445. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40446. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40447. //fixmedins_setl_cnt := int64(len(orders))
  40448. var medfee_sumamt float64
  40449. var acct_pay float64
  40450. var fund_pay_sumamt float64
  40451. for _, item := range orders {
  40452. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40453. acct_pay = acct_pay + item.AcctPay
  40454. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40455. }
  40456. //var medfee_sumamt_two float64
  40457. //var acct_pay_two float64
  40458. //var fund_pay_sumamt_two float64
  40459. //for _, item := range orders_two {
  40460. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40461. // acct_pay_two = acct_pay_two + item.AcctPay
  40462. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40463. //}
  40464. //var user_name string
  40465. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40466. //if role.ID == 0 {
  40467. // user_name = "xxx"
  40468. //} else {
  40469. // user_name = role.UserName
  40470. //}
  40471. var res ResultSix
  40472. if config.IsOpen == 1 {
  40473. var bps []*models.BusinessParamsTwo
  40474. var bp models.BusinessParamsTwo
  40475. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40476. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40477. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40478. bp.MedfeeSumamt = medfee_sumamt_str
  40479. bp.AcctPay = acct_pay_str
  40480. bp.FundPaySumamt = fund_pay_sumamt_str
  40481. bp.Insutype = "390"
  40482. bp.StmtBegndate = start_time
  40483. bp.ClrType = clr_type
  40484. bp.SetlOptins = clr_org
  40485. bp.StmtEnddate = end_time
  40486. bps = append(bps, &bp)
  40487. data := make(map[string]interface{})
  40488. data["bps"] = bps
  40489. data["org_name"] = miConfig.OrgName
  40490. data["doctor"] = role.UserName
  40491. data["fixmedins_code"] = miConfig.Code
  40492. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40493. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40494. if miConfig.MdtrtareaAdmvs == "421300" {
  40495. client := &http.Client{}
  40496. bytesData, _ := json.Marshal(data)
  40497. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40498. resp, _ := client.Do(req)
  40499. defer resp.Body.Close()
  40500. body, ioErr := ioutil.ReadAll(resp.Body)
  40501. if ioErr != nil {
  40502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40504. return
  40505. }
  40506. var respJSON map[string]interface{}
  40507. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40510. return
  40511. }
  40512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40513. userJSONBytes, _ := json.Marshal(respJSON)
  40514. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40515. utils.ErrorLog("解析失败:%v", err)
  40516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40517. return
  40518. }
  40519. }
  40520. if miConfig.MdtrtareaAdmvs == "420200" {
  40521. client := &http.Client{}
  40522. bytesData, _ := json.Marshal(data)
  40523. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40524. resp, _ := client.Do(req)
  40525. defer resp.Body.Close()
  40526. body, ioErr := ioutil.ReadAll(resp.Body)
  40527. if ioErr != nil {
  40528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40530. return
  40531. }
  40532. var respJSON map[string]interface{}
  40533. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40536. return
  40537. }
  40538. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40539. userJSONBytes, _ := json.Marshal(respJSON)
  40540. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40541. utils.ErrorLog("解析失败:%v", err)
  40542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40543. return
  40544. }
  40545. }
  40546. if miConfig.MdtrtareaAdmvs == "421182" {
  40547. client := &http.Client{}
  40548. bytesData, _ := json.Marshal(data)
  40549. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  40550. resp, _ := client.Do(req)
  40551. defer resp.Body.Close()
  40552. body, ioErr := ioutil.ReadAll(resp.Body)
  40553. if ioErr != nil {
  40554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40556. return
  40557. }
  40558. var respJSON map[string]interface{}
  40559. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40562. return
  40563. }
  40564. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40565. userJSONBytes, _ := json.Marshal(respJSON)
  40566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40567. utils.ErrorLog("解析失败:%v", err)
  40568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40569. return
  40570. }
  40571. }
  40572. if res.Infcode == 0 {
  40573. c.ServeSuccessJSON(map[string]interface{}{
  40574. "msg": "发起成功",
  40575. })
  40576. } else {
  40577. c.ServeSuccessJSON(map[string]interface{}{
  40578. "failed_code": -10,
  40579. "msg": res.ErrMsg,
  40580. })
  40581. }
  40582. }
  40583. }
  40584. func (c *HisApiController) Post1608() {
  40585. start_time := c.GetString("start_time")
  40586. end_time := c.GetString("end_time")
  40587. admin_user_id, _ := c.GetInt64("admin_user_id")
  40588. adminUser := c.GetAdminUserInfo()
  40589. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40590. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40591. timeLayout := "2006-01-02"
  40592. loc, _ := time.LoadLocation("Local")
  40593. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40594. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40595. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40596. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40597. fixmedins_setl_cnt := int64(len(orders))
  40598. var medfee_sumamt float64
  40599. var func_smamt float64
  40600. for _, item := range orders {
  40601. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40602. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  40603. }
  40604. times := strings.Split(start_time, "-")
  40605. time_tows := strings.Split(end_time, "-")
  40606. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40607. var res ResultSix
  40608. if config.IsOpen == 1 {
  40609. //var bps []*models.BusinessParamsTwo
  40610. //var bp models.BusinessParamsTwo
  40611. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40612. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  40613. data := make(map[string]interface{})
  40614. data["org_name"] = miConfig.OrgName
  40615. data["doctor"] = role.UserName
  40616. data["func_smamt"] = func_smamt_str
  40617. data["fixmedins_code"] = miConfig.Code
  40618. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40619. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40620. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  40621. data["medfee_sumamt"] = medfee_sumamt_str
  40622. data["start_time"] = times[0] + times[1] + times[2]
  40623. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  40624. if miConfig.MdtrtareaAdmvs == "421300" {
  40625. client := &http.Client{}
  40626. bytesData, _ := json.Marshal(data)
  40627. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40628. resp, _ := client.Do(req)
  40629. defer resp.Body.Close()
  40630. body, ioErr := ioutil.ReadAll(resp.Body)
  40631. if ioErr != nil {
  40632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40634. return
  40635. }
  40636. var respJSON map[string]interface{}
  40637. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40640. return
  40641. }
  40642. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40643. userJSONBytes, _ := json.Marshal(respJSON)
  40644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40645. utils.ErrorLog("解析失败:%v", err)
  40646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40647. return
  40648. }
  40649. }
  40650. if miConfig.MdtrtareaAdmvs == "420200" {
  40651. client := &http.Client{}
  40652. bytesData, _ := json.Marshal(data)
  40653. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40654. resp, _ := client.Do(req)
  40655. defer resp.Body.Close()
  40656. body, ioErr := ioutil.ReadAll(resp.Body)
  40657. if ioErr != nil {
  40658. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40660. return
  40661. }
  40662. var respJSON map[string]interface{}
  40663. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40664. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40666. return
  40667. }
  40668. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40669. userJSONBytes, _ := json.Marshal(respJSON)
  40670. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40671. utils.ErrorLog("解析失败:%v", err)
  40672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40673. return
  40674. }
  40675. }
  40676. if miConfig.MdtrtareaAdmvs == "421182" {
  40677. client := &http.Client{}
  40678. bytesData, _ := json.Marshal(data)
  40679. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  40680. resp, _ := client.Do(req)
  40681. defer resp.Body.Close()
  40682. body, ioErr := ioutil.ReadAll(resp.Body)
  40683. if ioErr != nil {
  40684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40686. return
  40687. }
  40688. var respJSON map[string]interface{}
  40689. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40692. return
  40693. }
  40694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40695. userJSONBytes, _ := json.Marshal(respJSON)
  40696. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40697. utils.ErrorLog("解析失败:%v", err)
  40698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40699. return
  40700. }
  40701. }
  40702. if res.Infcode == 0 {
  40703. c.ServeSuccessJSON(map[string]interface{}{
  40704. "msg": "发起成功",
  40705. })
  40706. } else {
  40707. c.ServeSuccessJSON(map[string]interface{}{
  40708. "failed_code": -10,
  40709. "msg": res.ErrMsg,
  40710. })
  40711. }
  40712. }
  40713. }
  40714. // 5.11.1.1【5262】结算信息按时间段查询
  40715. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40716. admin_user_id, _ := c.GetInt64("admin_user_id")
  40717. adminUser := c.GetAdminUserInfo()
  40718. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40719. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40720. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40721. var res Result5262
  40722. if config.IsOpen == 1 {
  40723. if miConfig.MdtrtareaAdmvs == "421300" {
  40724. data := make(map[string]interface{})
  40725. data["bps"] = bp
  40726. data["org_name"] = miConfig.OrgName
  40727. data["doctor"] = role.UserName
  40728. data["fixmedins_code"] = miConfig.Code
  40729. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40730. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40731. data["page"] = strconv.FormatInt(page, 10)
  40732. data["limit"] = strconv.FormatInt(limit, 10)
  40733. fmt.Println(data)
  40734. client := &http.Client{}
  40735. bytesData, _ := json.Marshal(data)
  40736. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40737. resp, _ := client.Do(req)
  40738. defer resp.Body.Close()
  40739. body, ioErr := ioutil.ReadAll(resp.Body)
  40740. if ioErr != nil {
  40741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40743. return
  40744. }
  40745. var respJSON map[string]interface{}
  40746. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40749. return
  40750. }
  40751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40752. userJSONBytes, _ := json.Marshal(respJSON)
  40753. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40754. utils.ErrorLog("解析失败:%v", err)
  40755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40756. return
  40757. }
  40758. }
  40759. if miConfig.MdtrtareaAdmvs == "420200" {
  40760. data := make(map[string]interface{})
  40761. data["bps"] = bp
  40762. data["org_name"] = miConfig.OrgName
  40763. data["doctor"] = role.UserName
  40764. data["fixmedins_code"] = miConfig.Code
  40765. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40766. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40767. data["page"] = strconv.FormatInt(page, 10)
  40768. data["limit"] = strconv.FormatInt(limit, 10)
  40769. fmt.Println(data)
  40770. client := &http.Client{}
  40771. bytesData, _ := json.Marshal(data)
  40772. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40773. resp, _ := client.Do(req)
  40774. defer resp.Body.Close()
  40775. body, ioErr := ioutil.ReadAll(resp.Body)
  40776. if ioErr != nil {
  40777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40779. return
  40780. }
  40781. var respJSON map[string]interface{}
  40782. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40785. return
  40786. }
  40787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40788. userJSONBytes, _ := json.Marshal(respJSON)
  40789. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40790. utils.ErrorLog("解析失败:%v", err)
  40791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40792. return
  40793. }
  40794. }
  40795. if miConfig.MdtrtareaAdmvs == "421182" {
  40796. data := make(map[string]interface{})
  40797. data["bps"] = bp
  40798. data["org_name"] = miConfig.OrgName
  40799. data["doctor"] = role.UserName
  40800. data["fixmedins_code"] = miConfig.Code
  40801. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40802. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40803. data["page"] = strconv.FormatInt(page, 10)
  40804. data["limit"] = strconv.FormatInt(limit, 10)
  40805. fmt.Println(data)
  40806. client := &http.Client{}
  40807. bytesData, _ := json.Marshal(data)
  40808. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40809. resp, _ := client.Do(req)
  40810. defer resp.Body.Close()
  40811. body, ioErr := ioutil.ReadAll(resp.Body)
  40812. if ioErr != nil {
  40813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40815. return
  40816. }
  40817. var respJSON map[string]interface{}
  40818. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40821. return
  40822. }
  40823. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40824. userJSONBytes, _ := json.Marshal(respJSON)
  40825. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40826. utils.ErrorLog("解析失败:%v", err)
  40827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40828. return
  40829. }
  40830. }
  40831. if miConfig.MdtrtareaAdmvs == "420902" {
  40832. data := make(map[string]interface{})
  40833. data["bps"] = bp
  40834. data["org_name"] = miConfig.OrgName
  40835. data["doctor"] = role.UserName
  40836. data["fixmedins_code"] = miConfig.Code
  40837. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40838. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40839. data["page"] = strconv.FormatInt(page, 10)
  40840. data["limit"] = strconv.FormatInt(limit, 10)
  40841. fmt.Println(data)
  40842. client := &http.Client{}
  40843. bytesData, _ := json.Marshal(data)
  40844. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40845. resp, _ := client.Do(req)
  40846. defer resp.Body.Close()
  40847. body, ioErr := ioutil.ReadAll(resp.Body)
  40848. if ioErr != nil {
  40849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40851. return
  40852. }
  40853. var respJSON map[string]interface{}
  40854. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40857. return
  40858. }
  40859. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40860. userJSONBytes, _ := json.Marshal(respJSON)
  40861. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40862. utils.ErrorLog("解析失败:%v", err)
  40863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40864. return
  40865. }
  40866. }
  40867. if res.Infcode == 0 {
  40868. c.ServeSuccessJSON(map[string]interface{}{
  40869. "order": res.Output.Result,
  40870. "total": res.Output.PageInfo.RecordCounts,
  40871. })
  40872. } else {
  40873. c.ServeSuccessJSON(map[string]interface{}{
  40874. "failed_code": -10,
  40875. "msg": res.ErrMsg,
  40876. })
  40877. }
  40878. }
  40879. }
  40880. // 5.11.1.2【5267】异地结算信息时间段查询
  40881. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40882. admin_user_id, _ := c.GetInt64("admin_user_id")
  40883. adminUser := c.GetAdminUserInfo()
  40884. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40885. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40886. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40887. var res Result5267
  40888. if config.IsOpen == 1 {
  40889. if miConfig.MdtrtareaAdmvs == "421300" {
  40890. data := make(map[string]interface{})
  40891. data["bps"] = bp
  40892. data["org_name"] = miConfig.OrgName
  40893. data["doctor"] = role.UserName
  40894. data["fixmedins_code"] = miConfig.Code
  40895. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40896. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40897. data["page"] = page
  40898. data["limit"] = limit
  40899. fmt.Println(data)
  40900. client := &http.Client{}
  40901. bytesData, _ := json.Marshal(data)
  40902. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40903. resp, _ := client.Do(req)
  40904. defer resp.Body.Close()
  40905. body, ioErr := ioutil.ReadAll(resp.Body)
  40906. if ioErr != nil {
  40907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40909. return
  40910. }
  40911. var respJSON map[string]interface{}
  40912. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40915. return
  40916. }
  40917. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40918. userJSONBytes, _ := json.Marshal(respJSON)
  40919. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40920. utils.ErrorLog("解析失败:%v", err)
  40921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40922. return
  40923. }
  40924. }
  40925. if miConfig.MdtrtareaAdmvs == "420200" {
  40926. data := make(map[string]interface{})
  40927. data["bps"] = bp
  40928. data["org_name"] = miConfig.OrgName
  40929. data["doctor"] = role.UserName
  40930. data["fixmedins_code"] = miConfig.Code
  40931. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40932. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40933. data["page"] = page
  40934. data["limit"] = limit
  40935. fmt.Println(data)
  40936. client := &http.Client{}
  40937. bytesData, _ := json.Marshal(data)
  40938. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40939. resp, _ := client.Do(req)
  40940. defer resp.Body.Close()
  40941. body, ioErr := ioutil.ReadAll(resp.Body)
  40942. if ioErr != nil {
  40943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40945. return
  40946. }
  40947. var respJSON map[string]interface{}
  40948. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40951. return
  40952. }
  40953. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40954. userJSONBytes, _ := json.Marshal(respJSON)
  40955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40956. utils.ErrorLog("解析失败:%v", err)
  40957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40958. return
  40959. }
  40960. }
  40961. if miConfig.MdtrtareaAdmvs == "421182" {
  40962. data := make(map[string]interface{})
  40963. data["bps"] = bp
  40964. data["org_name"] = miConfig.OrgName
  40965. data["doctor"] = role.UserName
  40966. data["fixmedins_code"] = miConfig.Code
  40967. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40968. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40969. data["page"] = page
  40970. data["limit"] = limit
  40971. fmt.Println(data)
  40972. client := &http.Client{}
  40973. bytesData, _ := json.Marshal(data)
  40974. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  40975. resp, _ := client.Do(req)
  40976. defer resp.Body.Close()
  40977. body, ioErr := ioutil.ReadAll(resp.Body)
  40978. if ioErr != nil {
  40979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40981. return
  40982. }
  40983. var respJSON map[string]interface{}
  40984. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40987. return
  40988. }
  40989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40990. userJSONBytes, _ := json.Marshal(respJSON)
  40991. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40992. utils.ErrorLog("解析失败:%v", err)
  40993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40994. return
  40995. }
  40996. }
  40997. if res.Infcode == 0 {
  40998. c.ServeSuccessJSON(map[string]interface{}{
  40999. "order": res.Output.Result,
  41000. "total": res.Output.PageInfo.RecordCounts,
  41001. })
  41002. } else {
  41003. c.ServeSuccessJSON(map[string]interface{}{
  41004. "failed_code": -10,
  41005. "msg": res.ErrMsg,
  41006. })
  41007. }
  41008. }
  41009. }
  41010. func (c *HisApiController) Post3501() {
  41011. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41012. data := make(map[string]interface{})
  41013. var struct3501s []models.Struct3501
  41014. var struct3501 models.Struct3501
  41015. struct3501.OrgName = miConfig.OrgName
  41016. struct3501.AccessKey = miConfig.AccessKey
  41017. struct3501.RequestUrl = miConfig.Url
  41018. struct3501.SecretKey = miConfig.SecretKey
  41019. struct3501.ManuDate = "2022-08-17"
  41020. struct3501.FixmedinsBchno = ""
  41021. struct3501.ManuLotnum = ""
  41022. struct3501.RxFlag = "0"
  41023. struct3501.ExpyEnd = "2022-08-17"
  41024. struct3501.Invdate = "2022-08-17"
  41025. struct3501.InvCnt = "20.25"
  41026. struct3501.Memo = ""
  41027. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41028. struct3501.FixmedinsHilistId = miConfig.Code
  41029. struct3501.FixmedinsHilistName = miConfig.OrgName
  41030. struct3501s = append(struct3501s, struct3501)
  41031. data["struct_3501s"] = struct3501s
  41032. client := &http.Client{}
  41033. bytesData, _ := json.Marshal(data)
  41034. var req *http.Request
  41035. if miConfig.MdtrtareaAdmvs == "320830" {
  41036. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  41037. } else if miConfig.MdtrtareaAdmvs == "320921" {
  41038. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41039. } else {
  41040. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41041. }
  41042. resp, _ := client.Do(req)
  41043. defer resp.Body.Close()
  41044. body, ioErr := ioutil.ReadAll(resp.Body)
  41045. if ioErr != nil {
  41046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41048. return
  41049. }
  41050. var respJSON map[string]interface{}
  41051. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41054. return
  41055. }
  41056. var res ResultSix
  41057. var resSix10265 ResultSix10265 //1101结果
  41058. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41059. result, _ := json.Marshal(respJSON)
  41060. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41061. utils.ErrorLog("解析失败:%v", err)
  41062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41063. return
  41064. }
  41065. res.InfRefmsgid = resSix10265.InfRefmsgid
  41066. res.Output = resSix10265.Output
  41067. res.ErrMsg = resSix10265.ErrMsg
  41068. res.Cainfo = resSix10265.Cainfo
  41069. res.WarnMsg = resSix10265.WarnMsg
  41070. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41071. res.Infcode = infocode
  41072. if infocode == 0 {
  41073. c.ServeSuccessJSON(map[string]interface{}{
  41074. "msg": "上传成功",
  41075. })
  41076. return
  41077. } else {
  41078. c.ServeSuccessJSON(map[string]interface{}{
  41079. "failed_code": -10,
  41080. "msg": res.ErrMsg,
  41081. })
  41082. return
  41083. }
  41084. }
  41085. func (c *HisApiController) Post3502() {
  41086. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41087. data := make(map[string]interface{})
  41088. var struct3502s []models.Struct3502
  41089. var struct3502 models.Struct3502
  41090. struct3502.OrgName = miConfig.OrgName
  41091. struct3502.AccessKey = miConfig.AccessKey
  41092. struct3502.RequestUrl = miConfig.Url
  41093. struct3502.SecretKey = miConfig.SecretKey
  41094. struct3502.ManuDate = "2022-08-15"
  41095. struct3502.FixmedinsBchno = ""
  41096. struct3502.ManuLotnum = ""
  41097. struct3502.RxFlag = "0"
  41098. struct3502.ExpyEnd = "2022-08-15"
  41099. struct3502.Invdate = "2022-08-15"
  41100. struct3502.InvCnt = "20.25"
  41101. struct3502.Memo = ""
  41102. struct3502.MedListCodg = "XB01ABD056B002020200517"
  41103. struct3502.FixmedinsHilistId = miConfig.Code
  41104. struct3502.FixmedinsHilistName = miConfig.OrgName
  41105. struct3502s = append(struct3502s, struct3502)
  41106. data["struct_3502s"] = struct3502s
  41107. client := &http.Client{}
  41108. bytesData, _ := json.Marshal(data)
  41109. var req *http.Request
  41110. if miConfig.MdtrtareaAdmvs == "320830" {
  41111. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  41112. } else if miConfig.MdtrtareaAdmvs == "320921" {
  41113. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41114. } else {
  41115. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41116. }
  41117. resp, _ := client.Do(req)
  41118. defer resp.Body.Close()
  41119. body, ioErr := ioutil.ReadAll(resp.Body)
  41120. if ioErr != nil {
  41121. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41123. return
  41124. }
  41125. var respJSON map[string]interface{}
  41126. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41129. return
  41130. }
  41131. var res ResultSix
  41132. var resSix10265 ResultSix10265 //1101结果
  41133. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41134. result, _ := json.Marshal(respJSON)
  41135. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41136. utils.ErrorLog("解析失败:%v", err)
  41137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41138. return
  41139. }
  41140. res.InfRefmsgid = resSix10265.InfRefmsgid
  41141. res.Output = resSix10265.Output
  41142. res.ErrMsg = resSix10265.ErrMsg
  41143. res.Cainfo = resSix10265.Cainfo
  41144. res.WarnMsg = resSix10265.WarnMsg
  41145. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41146. res.Infcode = infocode
  41147. if infocode == 0 {
  41148. c.ServeSuccessJSON(map[string]interface{}{
  41149. "msg": "上传成功",
  41150. })
  41151. return
  41152. } else {
  41153. c.ServeSuccessJSON(map[string]interface{}{
  41154. "failed_code": -10,
  41155. "msg": res.ErrMsg,
  41156. })
  41157. return
  41158. }
  41159. }
  41160. func (c *HisApiController) Post3503() {
  41161. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41162. data := make(map[string]interface{})
  41163. var struct3501s []models.Struct3501
  41164. var struct3501 models.Struct3501
  41165. struct3501.OrgName = miConfig.OrgName
  41166. struct3501.AccessKey = miConfig.AccessKey
  41167. struct3501.RequestUrl = miConfig.Url
  41168. struct3501.SecretKey = miConfig.SecretKey
  41169. struct3501.ManuDate = "2022-08-15"
  41170. struct3501.FixmedinsBchno = ""
  41171. struct3501.ManuLotnum = ""
  41172. struct3501.RxFlag = "0"
  41173. struct3501.ExpyEnd = "2022-08-15"
  41174. struct3501.Invdate = "2022-08-15"
  41175. struct3501.InvCnt = "20.25"
  41176. struct3501.Memo = ""
  41177. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41178. struct3501.FixmedinsHilistId = miConfig.Code
  41179. struct3501.FixmedinsHilistName = miConfig.OrgName
  41180. struct3501s = append(struct3501s, struct3501)
  41181. data["struct_3501s"] = struct3501s
  41182. client := &http.Client{}
  41183. bytesData, _ := json.Marshal(data)
  41184. var req *http.Request
  41185. if miConfig.MdtrtareaAdmvs == "320921" {
  41186. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41187. } else {
  41188. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41189. }
  41190. resp, _ := client.Do(req)
  41191. defer resp.Body.Close()
  41192. body, ioErr := ioutil.ReadAll(resp.Body)
  41193. if ioErr != nil {
  41194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41196. return
  41197. }
  41198. var respJSON map[string]interface{}
  41199. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41202. return
  41203. }
  41204. var res ResultSix
  41205. var resSix10265 ResultSix10265 //1101结果
  41206. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41207. result, _ := json.Marshal(respJSON)
  41208. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41209. utils.ErrorLog("解析失败:%v", err)
  41210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41211. return
  41212. }
  41213. res.InfRefmsgid = resSix10265.InfRefmsgid
  41214. res.Output = resSix10265.Output
  41215. res.ErrMsg = resSix10265.ErrMsg
  41216. res.Cainfo = resSix10265.Cainfo
  41217. res.WarnMsg = resSix10265.WarnMsg
  41218. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41219. res.Infcode = infocode
  41220. if infocode == 0 {
  41221. c.ServeSuccessJSON(map[string]interface{}{
  41222. "msg": "上传成功",
  41223. })
  41224. return
  41225. } else {
  41226. c.ServeSuccessJSON(map[string]interface{}{
  41227. "failed_code": -10,
  41228. "msg": res.ErrMsg,
  41229. })
  41230. return
  41231. }
  41232. }
  41233. func (c *HisApiController) Post3504() {
  41234. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41235. data := make(map[string]interface{})
  41236. var struct3501s []models.Struct3501
  41237. var struct3501 models.Struct3501
  41238. struct3501.OrgName = miConfig.OrgName
  41239. struct3501.AccessKey = miConfig.AccessKey
  41240. struct3501.RequestUrl = miConfig.Url
  41241. struct3501.SecretKey = miConfig.SecretKey
  41242. struct3501.ManuDate = "2022-08-15"
  41243. struct3501.FixmedinsBchno = ""
  41244. struct3501.ManuLotnum = ""
  41245. struct3501.RxFlag = "0"
  41246. struct3501.ExpyEnd = "2022-08-15"
  41247. struct3501.Invdate = "2022-08-15"
  41248. struct3501.InvCnt = "20.25"
  41249. struct3501.Memo = ""
  41250. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41251. struct3501.FixmedinsHilistId = miConfig.Code
  41252. struct3501.FixmedinsHilistName = miConfig.OrgName
  41253. struct3501s = append(struct3501s, struct3501)
  41254. data["struct_3501s"] = struct3501s
  41255. client := &http.Client{}
  41256. bytesData, _ := json.Marshal(data)
  41257. var req *http.Request
  41258. if miConfig.MdtrtareaAdmvs == "320921" {
  41259. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41260. } else {
  41261. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41262. }
  41263. resp, _ := client.Do(req)
  41264. defer resp.Body.Close()
  41265. body, ioErr := ioutil.ReadAll(resp.Body)
  41266. if ioErr != nil {
  41267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41269. return
  41270. }
  41271. var respJSON map[string]interface{}
  41272. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41275. return
  41276. }
  41277. var res ResultSix
  41278. var resSix10265 ResultSix10265 //1101结果
  41279. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41280. result, _ := json.Marshal(respJSON)
  41281. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41282. utils.ErrorLog("解析失败:%v", err)
  41283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41284. return
  41285. }
  41286. res.InfRefmsgid = resSix10265.InfRefmsgid
  41287. res.Output = resSix10265.Output
  41288. res.ErrMsg = resSix10265.ErrMsg
  41289. res.Cainfo = resSix10265.Cainfo
  41290. res.WarnMsg = resSix10265.WarnMsg
  41291. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41292. res.Infcode = infocode
  41293. if infocode == 0 {
  41294. c.ServeSuccessJSON(map[string]interface{}{
  41295. "msg": "上传成功",
  41296. })
  41297. return
  41298. } else {
  41299. c.ServeSuccessJSON(map[string]interface{}{
  41300. "failed_code": -10,
  41301. "msg": res.ErrMsg,
  41302. })
  41303. return
  41304. }
  41305. }
  41306. func (c *HisApiController) Post3505() {
  41307. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41308. data := make(map[string]interface{})
  41309. var struct3501s []models.Struct3501
  41310. var struct3501 models.Struct3501
  41311. struct3501.OrgName = miConfig.OrgName
  41312. struct3501.AccessKey = miConfig.AccessKey
  41313. struct3501.RequestUrl = miConfig.Url
  41314. struct3501.SecretKey = miConfig.SecretKey
  41315. struct3501.ManuDate = "2022-08-15"
  41316. struct3501.FixmedinsBchno = ""
  41317. struct3501.ManuLotnum = ""
  41318. struct3501.RxFlag = "0"
  41319. struct3501.ExpyEnd = "2022-08-15"
  41320. struct3501.Invdate = "2022-08-15"
  41321. struct3501.InvCnt = "20.25"
  41322. struct3501.Memo = ""
  41323. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41324. struct3501.FixmedinsHilistId = miConfig.Code
  41325. struct3501.FixmedinsHilistName = miConfig.OrgName
  41326. struct3501s = append(struct3501s, struct3501)
  41327. data["struct_3501s"] = struct3501s
  41328. client := &http.Client{}
  41329. bytesData, _ := json.Marshal(data)
  41330. var req *http.Request
  41331. if miConfig.MdtrtareaAdmvs == "320921" {
  41332. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41333. } else {
  41334. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41335. }
  41336. resp, _ := client.Do(req)
  41337. defer resp.Body.Close()
  41338. body, ioErr := ioutil.ReadAll(resp.Body)
  41339. if ioErr != nil {
  41340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41342. return
  41343. }
  41344. var respJSON map[string]interface{}
  41345. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41348. return
  41349. }
  41350. var res ResultSix
  41351. var resSix10265 ResultSix10265 //1101结果
  41352. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41353. result, _ := json.Marshal(respJSON)
  41354. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41355. utils.ErrorLog("解析失败:%v", err)
  41356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41357. return
  41358. }
  41359. res.InfRefmsgid = resSix10265.InfRefmsgid
  41360. res.Output = resSix10265.Output
  41361. res.ErrMsg = resSix10265.ErrMsg
  41362. res.Cainfo = resSix10265.Cainfo
  41363. res.WarnMsg = resSix10265.WarnMsg
  41364. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41365. res.Infcode = infocode
  41366. if infocode == 0 {
  41367. c.ServeSuccessJSON(map[string]interface{}{
  41368. "msg": "上传成功",
  41369. })
  41370. return
  41371. } else {
  41372. c.ServeSuccessJSON(map[string]interface{}{
  41373. "failed_code": -10,
  41374. "msg": res.ErrMsg,
  41375. })
  41376. return
  41377. }
  41378. }
  41379. func (c *HisApiController) Post3506() {
  41380. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41381. data := make(map[string]interface{})
  41382. var struct3501s []models.Struct3501
  41383. var struct3501 models.Struct3501
  41384. struct3501.OrgName = miConfig.OrgName
  41385. struct3501.AccessKey = miConfig.AccessKey
  41386. struct3501.RequestUrl = miConfig.Url
  41387. struct3501.SecretKey = miConfig.SecretKey
  41388. struct3501.ManuDate = "2022-08-15"
  41389. struct3501.FixmedinsBchno = ""
  41390. struct3501.ManuLotnum = ""
  41391. struct3501.RxFlag = "0"
  41392. struct3501.ExpyEnd = "2022-08-15"
  41393. struct3501.Invdate = "2022-08-15"
  41394. struct3501.InvCnt = "20.25"
  41395. struct3501.Memo = ""
  41396. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41397. struct3501.FixmedinsHilistId = miConfig.Code
  41398. struct3501.FixmedinsHilistName = miConfig.OrgName
  41399. struct3501s = append(struct3501s, struct3501)
  41400. data["struct_3501s"] = struct3501s
  41401. client := &http.Client{}
  41402. bytesData, _ := json.Marshal(data)
  41403. var req *http.Request
  41404. if miConfig.MdtrtareaAdmvs == "320921" {
  41405. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41406. } else {
  41407. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41408. }
  41409. resp, _ := client.Do(req)
  41410. defer resp.Body.Close()
  41411. body, ioErr := ioutil.ReadAll(resp.Body)
  41412. if ioErr != nil {
  41413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41415. return
  41416. }
  41417. var respJSON map[string]interface{}
  41418. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41421. return
  41422. }
  41423. var res ResultSix
  41424. var resSix10265 ResultSix10265 //1101结果
  41425. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41426. result, _ := json.Marshal(respJSON)
  41427. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41428. utils.ErrorLog("解析失败:%v", err)
  41429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41430. return
  41431. }
  41432. res.InfRefmsgid = resSix10265.InfRefmsgid
  41433. res.Output = resSix10265.Output
  41434. res.ErrMsg = resSix10265.ErrMsg
  41435. res.Cainfo = resSix10265.Cainfo
  41436. res.WarnMsg = resSix10265.WarnMsg
  41437. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41438. res.Infcode = infocode
  41439. if infocode == 0 {
  41440. c.ServeSuccessJSON(map[string]interface{}{
  41441. "msg": "上传成功",
  41442. })
  41443. return
  41444. } else {
  41445. c.ServeSuccessJSON(map[string]interface{}{
  41446. "failed_code": -10,
  41447. "msg": res.ErrMsg,
  41448. })
  41449. return
  41450. }
  41451. }
  41452. func (c *HisApiController) Post3507() {
  41453. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41454. data := make(map[string]interface{})
  41455. var struct3501s []models.Struct3501
  41456. var struct3501 models.Struct3501
  41457. struct3501.OrgName = miConfig.OrgName
  41458. struct3501.AccessKey = miConfig.AccessKey
  41459. struct3501.RequestUrl = miConfig.Url
  41460. struct3501.SecretKey = miConfig.SecretKey
  41461. struct3501.ManuDate = "2022-08-15"
  41462. struct3501.FixmedinsBchno = ""
  41463. struct3501.ManuLotnum = ""
  41464. struct3501.RxFlag = "0"
  41465. struct3501.ExpyEnd = "2022-08-15"
  41466. struct3501.Invdate = "2022-08-15"
  41467. struct3501.InvCnt = "20.25"
  41468. struct3501.Memo = ""
  41469. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41470. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  41471. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  41472. struct3501s = append(struct3501s, struct3501)
  41473. data["struct_3501s"] = struct3501s
  41474. client := &http.Client{}
  41475. bytesData, _ := json.Marshal(data)
  41476. var req *http.Request
  41477. if miConfig.MdtrtareaAdmvs == "320921" {
  41478. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41479. } else {
  41480. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41481. }
  41482. resp, _ := client.Do(req)
  41483. defer resp.Body.Close()
  41484. body, ioErr := ioutil.ReadAll(resp.Body)
  41485. if ioErr != nil {
  41486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41488. return
  41489. }
  41490. var respJSON map[string]interface{}
  41491. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41494. return
  41495. }
  41496. var res ResultSix
  41497. var resSix10265 ResultSix10265 //1101结果
  41498. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41499. result, _ := json.Marshal(respJSON)
  41500. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41501. utils.ErrorLog("解析失败:%v", err)
  41502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41503. return
  41504. }
  41505. res.InfRefmsgid = resSix10265.InfRefmsgid
  41506. res.Output = resSix10265.Output
  41507. res.ErrMsg = resSix10265.ErrMsg
  41508. res.Cainfo = resSix10265.Cainfo
  41509. res.WarnMsg = resSix10265.WarnMsg
  41510. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41511. res.Infcode = infocode
  41512. if infocode == 0 {
  41513. c.ServeSuccessJSON(map[string]interface{}{
  41514. "msg": "上传成功",
  41515. })
  41516. return
  41517. } else {
  41518. c.ServeSuccessJSON(map[string]interface{}{
  41519. "failed_code": -10,
  41520. "msg": res.ErrMsg,
  41521. })
  41522. return
  41523. }
  41524. }
  41525. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41526. // WebSocket服务器地址
  41527. serverURL := "ws://127.0.0.1:8899"
  41528. // 解析WebSocket服务器地址
  41529. u, err := url.Parse(serverURL)
  41530. if err != nil {
  41531. }
  41532. // 建立WebSocket连接
  41533. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41534. if err != nil {
  41535. }
  41536. defer conn.Close()
  41537. input2 := make(map[string]interface{})
  41538. input := make(map[string]interface{})
  41539. inputData := make(map[string]interface{})
  41540. inputData["orgId"] = code
  41541. inputData["businessType"] = "01101"
  41542. inputData["operatorId"] = operator_id
  41543. inputData["operatorName"] = operator_name
  41544. inputData["officeId"] = "001"
  41545. inputData["officeName"] = "血透室"
  41546. inputData["deviceType"] = ""
  41547. input["data"] = inputData
  41548. input["orgId"] = code
  41549. input["transType"] = "ec.query"
  41550. //if md == ""
  41551. if md[:4] == "4403" {
  41552. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41553. } else if md[:4] == "4401" {
  41554. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41555. } else {
  41556. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41557. }
  41558. input2["indata"] = input
  41559. fmt.Println(input2)
  41560. bytesData, _ := json.Marshal(input2)
  41561. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41562. if err != nil {
  41563. fmt.Println(err)
  41564. }
  41565. // 接收消息
  41566. _, receivedMessage, err := conn.ReadMessage()
  41567. if err != nil {
  41568. fmt.Println(err)
  41569. }
  41570. return "", string(receivedMessage)
  41571. }
  41572. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  41573. // WebSocket服务器地址
  41574. serverURL := "ws://127.0.0.1:8899"
  41575. // 解析WebSocket服务器地址
  41576. u, err := url.Parse(serverURL)
  41577. if err != nil {
  41578. }
  41579. // 建立WebSocket连接
  41580. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41581. if err != nil {
  41582. }
  41583. defer conn.Close()
  41584. input2 := make(map[string]interface{})
  41585. input := make(map[string]interface{})
  41586. inputData := make(map[string]interface{})
  41587. inputData["orgId"] = code
  41588. inputData["businessType"] = "01101"
  41589. inputData["operatorId"] = operator_id
  41590. inputData["operatorName"] = operator_name
  41591. inputData["officeId"] = "001"
  41592. inputData["officeName"] = "血透室"
  41593. inputData["deviceType"] = ""
  41594. input["data"] = inputData
  41595. input["orgId"] = code
  41596. input["transType"] = "ec.query"
  41597. //if md == ""
  41598. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41599. input2["indata"] = input
  41600. fmt.Println(input2)
  41601. bytesData, _ := json.Marshal(input2)
  41602. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41603. if err != nil {
  41604. fmt.Println(err)
  41605. }
  41606. // 接收消息
  41607. _, receivedMessage, err := conn.ReadMessage()
  41608. if err != nil {
  41609. fmt.Println(err)
  41610. }
  41611. return "", string(receivedMessage)
  41612. }
  41613. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  41614. // WebSocket服务器地址
  41615. serverURL := "ws://127.0.0.1:8899"
  41616. // 解析WebSocket服务器地址
  41617. u, err := url.Parse(serverURL)
  41618. if err != nil {
  41619. }
  41620. // 建立WebSocket连接
  41621. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41622. if err != nil {
  41623. }
  41624. defer conn.Close()
  41625. input2 := make(map[string]interface{})
  41626. input := make(map[string]interface{})
  41627. inputData := make(map[string]interface{})
  41628. inputData["orgId"] = code
  41629. inputData["businessType"] = "01301"
  41630. inputData["operatorId"] = operator_id
  41631. inputData["operatorName"] = operator_name
  41632. inputData["officeId"] = "001"
  41633. inputData["officeName"] = "血透室"
  41634. inputData["deviceType"] = ""
  41635. input["data"] = inputData
  41636. input["orgId"] = code
  41637. input["transType"] = "ec.query"
  41638. //if md == ""
  41639. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41640. input2["indata"] = input
  41641. fmt.Println(input2)
  41642. bytesData, _ := json.Marshal(input2)
  41643. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41644. if err != nil {
  41645. fmt.Println(err)
  41646. }
  41647. // 接收消息
  41648. _, receivedMessage, err := conn.ReadMessage()
  41649. if err != nil {
  41650. fmt.Println(err)
  41651. }
  41652. return "", string(receivedMessage)
  41653. }
  41654. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  41655. // WebSocket服务器地址
  41656. serverURL := "ws://127.0.0.1:8899"
  41657. // 解析WebSocket服务器地址
  41658. u, err := url.Parse(serverURL)
  41659. if err != nil {
  41660. }
  41661. // 建立WebSocket连接
  41662. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41663. if err != nil {
  41664. }
  41665. defer conn.Close()
  41666. input2 := make(map[string]interface{})
  41667. input := make(map[string]interface{})
  41668. inputData := make(map[string]interface{})
  41669. inputData["orgId"] = code
  41670. inputData["businessType"] = "01103"
  41671. inputData["operatorId"] = operator_id
  41672. inputData["operatorName"] = operator_name
  41673. inputData["officeId"] = "001"
  41674. inputData["officeName"] = "血透室"
  41675. inputData["deviceType"] = ""
  41676. input["data"] = inputData
  41677. input["orgId"] = code
  41678. input["transType"] = "ec.query"
  41679. //if md ==
  41680. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  41681. input2["indata"] = input
  41682. fmt.Println(input2)
  41683. bytesData, _ := json.Marshal(input2)
  41684. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41685. if err != nil {
  41686. fmt.Println(err)
  41687. }
  41688. // 接收消息
  41689. _, receivedMessage, err := conn.ReadMessage()
  41690. if err != nil {
  41691. fmt.Println(err)
  41692. }
  41693. return "", string(receivedMessage)
  41694. }
  41695. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41696. // WebSocket服务器地址
  41697. serverURL := "ws://127.0.0.1:8899"
  41698. // 解析WebSocket服务器地址
  41699. u, err := url.Parse(serverURL)
  41700. if err != nil {
  41701. }
  41702. // 建立WebSocket连接
  41703. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41704. if err != nil {
  41705. }
  41706. defer conn.Close()
  41707. input2 := make(map[string]interface{})
  41708. input := make(map[string]interface{})
  41709. inputData := make(map[string]interface{})
  41710. inputData["orgId"] = code
  41711. inputData["businessType"] = "01101"
  41712. inputData["operatorId"] = operator_id
  41713. inputData["operatorName"] = operator_name
  41714. inputData["officeId"] = "001"
  41715. inputData["officeName"] = "血透室"
  41716. inputData["deviceType"] = ""
  41717. input["data"] = inputData
  41718. input["orgId"] = code
  41719. input["transType"] = "ec.query"
  41720. //if md == ""
  41721. if md[:4] == "4403" {
  41722. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41723. } else if md[:4] == "4401" {
  41724. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41725. } else {
  41726. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41727. }
  41728. input2["indata"] = input
  41729. fmt.Println(input2)
  41730. bytesData, _ := json.Marshal(input2)
  41731. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41732. if err != nil {
  41733. fmt.Println(err)
  41734. }
  41735. // 接收消息
  41736. _, receivedMessage, err := conn.ReadMessage()
  41737. if err != nil {
  41738. fmt.Println(err)
  41739. }
  41740. return "", string(receivedMessage)
  41741. }
  41742. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  41743. // WebSocket服务器地址
  41744. serverURL := "ws://127.0.0.1:8899"
  41745. // 解析WebSocket服务器地址
  41746. u, err := url.Parse(serverURL)
  41747. if err != nil {
  41748. }
  41749. // 建立WebSocket连接
  41750. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41751. if err != nil {
  41752. }
  41753. defer conn.Close()
  41754. input2 := make(map[string]interface{})
  41755. input := make(map[string]interface{})
  41756. inputData := make(map[string]interface{})
  41757. inputData["orgId"] = code
  41758. inputData["businessType"] = "01301"
  41759. inputData["operatorId"] = operator_id
  41760. inputData["operatorName"] = operator_name
  41761. inputData["officeId"] = "001"
  41762. inputData["officeName"] = "血透室"
  41763. inputData["deviceType"] = ""
  41764. input["data"] = inputData
  41765. input["orgId"] = code
  41766. input["transType"] = "ec.query"
  41767. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41768. input2["indata"] = input
  41769. bytesData, _ := json.Marshal(input2)
  41770. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41771. if err != nil {
  41772. fmt.Println(err)
  41773. }
  41774. // 接收消息
  41775. _, receivedMessage, err := conn.ReadMessage()
  41776. if err != nil {
  41777. fmt.Println(err)
  41778. }
  41779. return "", string(receivedMessage)
  41780. }
  41781. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  41782. newArr = make([]string, 0)
  41783. for i := 0; i < len(arr); i++ {
  41784. repeat := false
  41785. for j := i + 1; j < len(arr); j++ {
  41786. if arr[i] == arr[j] {
  41787. repeat = true
  41788. break
  41789. }
  41790. }
  41791. if !repeat {
  41792. newArr = append(newArr, arr[i])
  41793. }
  41794. }
  41795. return
  41796. }
  41797. func getBirthdateAndAge(idNumber string) (string, int, error) {
  41798. if len(idNumber) != 18 {
  41799. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  41800. }
  41801. // 提取出生日期
  41802. year, err := strconv.Atoi(idNumber[6:10])
  41803. if err != nil {
  41804. return "", 0, err
  41805. }
  41806. month, err := strconv.Atoi(idNumber[10:12])
  41807. if err != nil {
  41808. return "", 0, err
  41809. }
  41810. day, err := strconv.Atoi(idNumber[12:14])
  41811. if err != nil {
  41812. return "", 0, err
  41813. }
  41814. // 格式化生日字符串
  41815. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  41816. birthdateFormatted := birthdate.Format("2006-01-02")
  41817. // 计算年龄
  41818. today := time.Now()
  41819. age := today.Year() - birthdate.Year()
  41820. if today.YearDay() < birthdate.YearDay() {
  41821. age--
  41822. }
  41823. return birthdateFormatted, age, nil
  41824. }
  41825. // 从身份证号码中提取出生年月日
  41826. func getBirthDateFromIDCard(idCard string) (string, error) {
  41827. // 身份证号码长度应为18位
  41828. if len(idCard) != 18 {
  41829. return "", fmt.Errorf("身份证号码长度应为18位")
  41830. }
  41831. // 提取出生日期部分 (YYYYMMDD)
  41832. birthDateStr := idCard[6:14]
  41833. // 解析出生日期
  41834. birthDate, err := time.Parse("20060102", birthDateStr)
  41835. if err != nil {
  41836. return "", fmt.Errorf("解析出生日期失败: %v", err)
  41837. }
  41838. // 格式化出生日期为 YYYY-MM-DD
  41839. formattedDate := birthDate.Format("2006-01-02")
  41840. return formattedDate, nil
  41841. }