his_api_controller.go 1.7MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938
  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. )
  35. type HisApiController struct {
  36. controllers.BaseAuthAPIController
  37. }
  38. func HisManagerApiRegistRouters() {
  39. //挂号
  40. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  77. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  78. beego.Router("/api/check", &HisApiController{}, "get:Check")
  79. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  80. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  81. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  82. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  83. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  84. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  85. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  86. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  87. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  88. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  89. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  90. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  91. //beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  92. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  93. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  94. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  95. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  96. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  97. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  98. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  99. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  100. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  101. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  102. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  103. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  106. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  107. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  108. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  109. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  110. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  111. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  112. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  113. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  114. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  115. beego.Router("/api/CFYLJG012", &HisApiController{}, "get:GetCFYLJG12")
  116. beego.Router("/api/CFYLJG013", &HisApiController{}, "get:GetCFYLJG13")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  136. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  137. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  138. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  139. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  140. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  141. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  142. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  143. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  144. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  145. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  146. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  147. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  148. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  149. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  150. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  151. //库盘和变更
  152. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  153. //删除库盘和变更
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  155. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  156. //药品变更
  157. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  158. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  159. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  160. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  161. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  162. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  163. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  164. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  165. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  166. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  167. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  168. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  169. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  170. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  171. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  172. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  173. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  174. beego.Router("/api/5101", &HisApiController{}, "get:Get5101")
  175. beego.Router("/api/5102", &HisApiController{}, "get:Get5102")
  176. }
  177. func (c *HisApiController) Get5101() {
  178. adminUser := c.GetAdminUserInfo()
  179. admin_user_id, _ := c.GetInt64("admin_user_id")
  180. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  181. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  182. if miConfig.MdtrtareaAdmvs == "341203" {
  183. fmt.Println(miConfig.SecretKey)
  184. var res models.Result9001Two
  185. 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 +
  186. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  187. resp, requestErr := http.Get(api)
  188. if requestErr != nil {
  189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  190. return
  191. }
  192. body, ioErr := ioutil.ReadAll(resp.Body)
  193. if ioErr != nil {
  194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  196. return
  197. }
  198. var respJSON map[string]interface{}
  199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  202. return
  203. }
  204. status := respJSON["data"].(map[string]interface{})["status"].(string)
  205. if status == "0" {
  206. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  207. c.ServeSuccessJSON(map[string]interface{}{
  208. "failed_code": -10,
  209. "msg": err_msg,
  210. })
  211. return
  212. }
  213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  214. result, _ := json.Marshal(respJSON)
  215. fmt.Println("log")
  216. fmt.Println(string(result))
  217. if err := json.Unmarshal([]byte(result), &res); err != nil {
  218. utils.ErrorLog("解析失败:%v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. if res.Infcode == 0 {
  223. sign := models.HisSignIn{
  224. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  225. SignNo: res.Output.Signinoutb.SignNo,
  226. SignTime: "",
  227. Ctime: time.Now().Unix(),
  228. Mtime: time.Now().Unix(),
  229. Status: 1,
  230. InputLog: "",
  231. OutputLog: "",
  232. FixmedinsCode: miConfig.Code,
  233. }
  234. err := service.CreateSignIn(&sign)
  235. if err == nil {
  236. c.ServeSuccessJSON(map[string]interface{}{
  237. "msg": "签到成功",
  238. })
  239. }
  240. } else {
  241. c.ServeSuccessJSON(map[string]interface{}{
  242. "failed_code": -10,
  243. "msg": res.ErrMsg,
  244. })
  245. return
  246. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  247. //return
  248. }
  249. } else if miConfig.MdtrtareaAdmvs == "340699" {
  250. fmt.Println(miConfig.SecretKey)
  251. var res models.Result9001Two
  252. 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 +
  253. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  254. resp, requestErr := http.Get(api)
  255. if requestErr != nil {
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  257. return
  258. }
  259. body, ioErr := ioutil.ReadAll(resp.Body)
  260. if ioErr != nil {
  261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  263. return
  264. }
  265. var respJSON map[string]interface{}
  266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  269. return
  270. }
  271. status := respJSON["data"].(map[string]interface{})["status"].(string)
  272. if status == "0" {
  273. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  274. c.ServeSuccessJSON(map[string]interface{}{
  275. "failed_code": -10,
  276. "msg": err_msg,
  277. })
  278. return
  279. }
  280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  281. result, _ := json.Marshal(respJSON)
  282. fmt.Println("log")
  283. fmt.Println(string(result))
  284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  285. utils.ErrorLog("解析失败:%v", err)
  286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  287. return
  288. }
  289. if res.Infcode == 0 {
  290. sign := models.HisSignIn{
  291. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  292. SignNo: res.Output.Signinoutb.SignNo,
  293. SignTime: "",
  294. Ctime: time.Now().Unix(),
  295. Mtime: time.Now().Unix(),
  296. Status: 1,
  297. InputLog: "",
  298. OutputLog: "",
  299. FixmedinsCode: miConfig.Code,
  300. }
  301. err := service.CreateSignIn(&sign)
  302. if err == nil {
  303. c.ServeSuccessJSON(map[string]interface{}{
  304. "msg": "查询成功",
  305. })
  306. }
  307. } else {
  308. c.ServeSuccessJSON(map[string]interface{}{
  309. "failed_code": -10,
  310. "msg": res.ErrMsg,
  311. })
  312. return
  313. }
  314. }
  315. }
  316. func (c *HisApiController) Get5102() {
  317. adminUser := c.GetAdminUserInfo()
  318. admin_user_id, _ := c.GetInt64("admin_user_id")
  319. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  320. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  321. if miConfig.MdtrtareaAdmvs == "341203" {
  322. fmt.Println(miConfig.SecretKey)
  323. var res models.Result9001Two
  324. 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 +
  325. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  326. resp, requestErr := http.Get(api)
  327. if requestErr != nil {
  328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  329. return
  330. }
  331. body, ioErr := ioutil.ReadAll(resp.Body)
  332. if ioErr != nil {
  333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  335. return
  336. }
  337. var respJSON map[string]interface{}
  338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  341. return
  342. }
  343. status := respJSON["data"].(map[string]interface{})["status"].(string)
  344. if status == "0" {
  345. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  346. c.ServeSuccessJSON(map[string]interface{}{
  347. "failed_code": -10,
  348. "msg": err_msg,
  349. })
  350. return
  351. }
  352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  353. result, _ := json.Marshal(respJSON)
  354. fmt.Println("log")
  355. fmt.Println(string(result))
  356. if err := json.Unmarshal([]byte(result), &res); err != nil {
  357. utils.ErrorLog("解析失败:%v", err)
  358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  359. return
  360. }
  361. if res.Infcode == 0 {
  362. sign := models.HisSignIn{
  363. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  364. SignNo: res.Output.Signinoutb.SignNo,
  365. SignTime: "",
  366. Ctime: time.Now().Unix(),
  367. Mtime: time.Now().Unix(),
  368. Status: 1,
  369. InputLog: "",
  370. OutputLog: "",
  371. FixmedinsCode: miConfig.Code,
  372. }
  373. err := service.CreateSignIn(&sign)
  374. if err == nil {
  375. c.ServeSuccessJSON(map[string]interface{}{
  376. "msg": "签到成功",
  377. })
  378. }
  379. } else {
  380. c.ServeSuccessJSON(map[string]interface{}{
  381. "failed_code": -10,
  382. "msg": res.ErrMsg,
  383. })
  384. return
  385. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  386. //return
  387. }
  388. } else if miConfig.MdtrtareaAdmvs == "340699" {
  389. fmt.Println(miConfig.SecretKey)
  390. var res models.Result9001Two
  391. 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 +
  392. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  393. resp, requestErr := http.Get(api)
  394. if requestErr != nil {
  395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  396. return
  397. }
  398. body, ioErr := ioutil.ReadAll(resp.Body)
  399. if ioErr != nil {
  400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  402. return
  403. }
  404. var respJSON map[string]interface{}
  405. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  408. return
  409. }
  410. status := respJSON["data"].(map[string]interface{})["status"].(string)
  411. if status == "0" {
  412. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  413. c.ServeSuccessJSON(map[string]interface{}{
  414. "failed_code": -10,
  415. "msg": err_msg,
  416. })
  417. return
  418. }
  419. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  420. result, _ := json.Marshal(respJSON)
  421. fmt.Println("log")
  422. fmt.Println(string(result))
  423. if err := json.Unmarshal([]byte(result), &res); err != nil {
  424. utils.ErrorLog("解析失败:%v", err)
  425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  426. return
  427. }
  428. if res.Infcode == 0 {
  429. sign := models.HisSignIn{
  430. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  431. SignNo: res.Output.Signinoutb.SignNo,
  432. SignTime: "",
  433. Ctime: time.Now().Unix(),
  434. Mtime: time.Now().Unix(),
  435. Status: 1,
  436. InputLog: "",
  437. OutputLog: "",
  438. FixmedinsCode: miConfig.Code,
  439. }
  440. err := service.CreateSignIn(&sign)
  441. if err == nil {
  442. c.ServeSuccessJSON(map[string]interface{}{
  443. "msg": "查询成功",
  444. })
  445. }
  446. } else {
  447. c.ServeSuccessJSON(map[string]interface{}{
  448. "failed_code": -10,
  449. "msg": res.ErrMsg,
  450. })
  451. return
  452. }
  453. }
  454. }
  455. func (c *HisApiController) Get3201() {
  456. adminUser := c.GetAdminUserInfo()
  457. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  458. 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)
  459. var response Response
  460. if err := json.Unmarshal([]byte(result), &response); err != nil {
  461. fmt.Println("Error decoding JSON:", err)
  462. return
  463. }
  464. }
  465. func (c *HisApiController) TestNet() {
  466. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  467. //return
  468. c.ServeSuccessJSON(map[string]interface{}{
  469. "msg": "成功",
  470. })
  471. }
  472. func (c *HisApiController) Get3508() {
  473. admin_user_id, _ := c.GetInt64("admin_user_id")
  474. drug_id, _ := c.GetInt64("id")
  475. start_time := c.GetString("start_time")
  476. end_time := c.GetString("end_time")
  477. adminUser := c.GetAdminUserInfo()
  478. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  479. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  480. drug, _ := service.GetDrugByID(drug_id)
  481. var struct3508 models.Struct3508
  482. struct3508.OrgName = miConfig.OrgName
  483. struct3508.FixmedinsCode = miConfig.Code
  484. struct3508.AccessKey = miConfig.AccessKey
  485. struct3508.Opter = curRoles.UserName
  486. struct3508.RequestUrl = miConfig.Url
  487. struct3508.Url = miConfig.Url
  488. struct3508.AppId = miConfig.Cainfo
  489. struct3508.AppSecret = miConfig.AppSecret
  490. struct3508.Enckey = miConfig.EncKey
  491. struct3508.SignKey = miConfig.SignKey
  492. struct3508.SecretKey = miConfig.SecretKey
  493. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  494. struct3508.Begndate = start_time
  495. struct3508.Enddate = end_time
  496. result1, result2, _ := service.FJyb3508(struct3508)
  497. saveLog(result1, result2, "3508", "3508")
  498. var res models.Result3508
  499. var respJSON2 map[string]interface{}
  500. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  503. return
  504. }
  505. userJSONBytes2, _ := json.Marshal(respJSON2)
  506. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  507. utils.ErrorLog("解析失败:%v", err)
  508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  509. return
  510. }
  511. if res.Infcode == -1 {
  512. c.ServeSuccessJSON(map[string]interface{}{
  513. "failed_code": -10,
  514. "msg": res.ErrMsg,
  515. })
  516. } else {
  517. c.ServeSuccessJSON(map[string]interface{}{
  518. "info": res.Output,
  519. })
  520. }
  521. }
  522. func (c *HisApiController) Get3509() {
  523. admin_user_id, _ := c.GetInt64("admin_user_id")
  524. drug_id, _ := c.GetInt64("id")
  525. start_time := c.GetString("start_time")
  526. end_time := c.GetString("end_time")
  527. adminUser := c.GetAdminUserInfo()
  528. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  529. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  530. drug, _ := service.GetDrugByID(drug_id)
  531. var struct3508 models.Struct3509
  532. struct3508.OrgName = miConfig.OrgName
  533. struct3508.FixmedinsCode = miConfig.Code
  534. struct3508.AccessKey = miConfig.AccessKey
  535. struct3508.Opter = curRoles.UserName
  536. struct3508.RequestUrl = miConfig.Url
  537. struct3508.Url = miConfig.Url
  538. struct3508.AppId = miConfig.Cainfo
  539. struct3508.AppSecret = miConfig.AppSecret
  540. struct3508.Enckey = miConfig.EncKey
  541. struct3508.SignKey = miConfig.SignKey
  542. struct3508.SecretKey = miConfig.SecretKey
  543. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  544. struct3508.Begndate = start_time
  545. struct3508.Enddate = end_time
  546. result1, result2, _ := service.FJyb3509(struct3508)
  547. saveLog(result1, result2, "3509", "3509")
  548. var res models.Result3509
  549. var respJSON2 map[string]interface{}
  550. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  553. return
  554. }
  555. userJSONBytes2, _ := json.Marshal(respJSON2)
  556. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  557. utils.ErrorLog("解析失败:%v", err)
  558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  559. return
  560. }
  561. if res.Infcode == -1 {
  562. c.ServeSuccessJSON(map[string]interface{}{
  563. "failed_code": -10,
  564. "msg": res.ErrMsg,
  565. })
  566. } else {
  567. c.ServeSuccessJSON(map[string]interface{}{
  568. "info": res.Output,
  569. })
  570. }
  571. }
  572. func (c *HisApiController) Get3510() {
  573. admin_user_id, _ := c.GetInt64("admin_user_id")
  574. drug_id, _ := c.GetInt64("id")
  575. start_time := c.GetString("start_time")
  576. end_time := c.GetString("end_time")
  577. adminUser := c.GetAdminUserInfo()
  578. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  579. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  580. drug, _ := service.GetDrugByID(drug_id)
  581. var struct3508 models.Struct3510
  582. struct3508.FixmedinsCode = miConfig.Code
  583. struct3508.OrgName = miConfig.OrgName
  584. struct3508.AccessKey = miConfig.AccessKey
  585. struct3508.Opter = curRoles.UserName
  586. struct3508.RequestUrl = miConfig.Url
  587. struct3508.Url = miConfig.Url
  588. struct3508.AppId = miConfig.Cainfo
  589. struct3508.AppSecret = miConfig.AppSecret
  590. struct3508.Enckey = miConfig.EncKey
  591. struct3508.SignKey = miConfig.SignKey
  592. struct3508.SecretKey = miConfig.SecretKey
  593. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  594. struct3508.Begndate = start_time
  595. struct3508.Enddate = end_time
  596. result1, result2, _ := service.FJyb3510(struct3508)
  597. saveLog(result1, result2, "3510", "3510")
  598. var res models.Result3510
  599. var respJSON2 map[string]interface{}
  600. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  603. return
  604. }
  605. userJSONBytes2, _ := json.Marshal(respJSON2)
  606. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  607. utils.ErrorLog("解析失败:%v", err)
  608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  609. return
  610. }
  611. if res.Infcode == -1 {
  612. c.ServeSuccessJSON(map[string]interface{}{
  613. "failed_code": -10,
  614. "msg": res.ErrMsg,
  615. })
  616. } else {
  617. c.ServeSuccessJSON(map[string]interface{}{
  618. "info": res.Output,
  619. })
  620. }
  621. }
  622. func (c *HisApiController) Get3511() {
  623. admin_user_id, _ := c.GetInt64("admin_user_id")
  624. drug_id, _ := c.GetInt64("id")
  625. start_time := c.GetString("start_time")
  626. end_time := c.GetString("end_time")
  627. adminUser := c.GetAdminUserInfo()
  628. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  629. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  630. drug, _ := service.GetDrugByID(drug_id)
  631. var struct3508 models.Struct3511
  632. struct3508.FixmedinsCode = miConfig.Code
  633. struct3508.OrgName = miConfig.OrgName
  634. struct3508.AccessKey = miConfig.AccessKey
  635. struct3508.Opter = curRoles.UserName
  636. struct3508.RequestUrl = miConfig.Url
  637. struct3508.Url = miConfig.Url
  638. struct3508.AppId = miConfig.Cainfo
  639. struct3508.AppSecret = miConfig.AppSecret
  640. struct3508.Enckey = miConfig.EncKey
  641. struct3508.SignKey = miConfig.SignKey
  642. struct3508.SecretKey = miConfig.SecretKey
  643. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  644. struct3508.Begndate = start_time
  645. struct3508.Enddate = end_time
  646. result1, result2, _ := service.FJyb3511(struct3508)
  647. saveLog(result1, result2, "3511", "3511")
  648. var res models.Result3511
  649. var respJSON2 map[string]interface{}
  650. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  653. return
  654. }
  655. userJSONBytes2, _ := json.Marshal(respJSON2)
  656. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  657. utils.ErrorLog("解析失败:%v", err)
  658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  659. return
  660. }
  661. if res.Infcode == -1 {
  662. c.ServeSuccessJSON(map[string]interface{}{
  663. "failed_code": -10,
  664. "msg": res.ErrMsg,
  665. })
  666. } else {
  667. c.ServeSuccessJSON(map[string]interface{}{
  668. "info": res.Output,
  669. })
  670. }
  671. }
  672. func (c *HisApiController) Get3512() {
  673. admin_user_id, _ := c.GetInt64("admin_user_id")
  674. drug_id, _ := c.GetInt64("id")
  675. start_time := c.GetString("start_time")
  676. end_time := c.GetString("end_time")
  677. adminUser := c.GetAdminUserInfo()
  678. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  679. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  680. drug, _ := service.GetDrugByID(drug_id)
  681. var struct3508 models.Struct3512
  682. struct3508.FixmedinsCode = miConfig.Code
  683. struct3508.OrgName = miConfig.OrgName
  684. struct3508.AccessKey = miConfig.AccessKey
  685. struct3508.Opter = curRoles.UserName
  686. struct3508.RequestUrl = miConfig.Url
  687. struct3508.Url = miConfig.Url
  688. struct3508.AppId = miConfig.Cainfo
  689. struct3508.AppSecret = miConfig.AppSecret
  690. struct3508.Enckey = miConfig.EncKey
  691. struct3508.SignKey = miConfig.SignKey
  692. struct3508.SecretKey = miConfig.SecretKey
  693. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  694. struct3508.Begndate = start_time
  695. struct3508.Enddate = end_time
  696. result1, result2, _ := service.FJyb3512(struct3508)
  697. saveLog(result1, result2, "3512", "3512")
  698. var res models.Result3512
  699. var respJSON2 map[string]interface{}
  700. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  703. return
  704. }
  705. userJSONBytes2, _ := json.Marshal(respJSON2)
  706. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  707. utils.ErrorLog("解析失败:%v", err)
  708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  709. return
  710. }
  711. if res.Infcode == -1 {
  712. c.ServeSuccessJSON(map[string]interface{}{
  713. "failed_code": -10,
  714. "msg": res.ErrMsg,
  715. })
  716. } else {
  717. c.ServeSuccessJSON(map[string]interface{}{
  718. "info": res.Output,
  719. })
  720. }
  721. }
  722. func (c *HisApiController) Get3513() {
  723. admin_user_id, _ := c.GetInt64("admin_user_id")
  724. drug_id, _ := c.GetInt64("id")
  725. start_time := c.GetString("start_time")
  726. end_time := c.GetString("end_time")
  727. adminUser := c.GetAdminUserInfo()
  728. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  729. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  730. drug, _ := service.GetDrugByID(drug_id)
  731. var struct3508 models.Struct3513
  732. struct3508.FixmedinsCode = miConfig.Code
  733. struct3508.OrgName = miConfig.OrgName
  734. struct3508.AccessKey = miConfig.AccessKey
  735. struct3508.Opter = curRoles.UserName
  736. struct3508.RequestUrl = miConfig.Url
  737. struct3508.Url = miConfig.Url
  738. struct3508.AppId = miConfig.Cainfo
  739. struct3508.AppSecret = miConfig.AppSecret
  740. struct3508.Enckey = miConfig.EncKey
  741. struct3508.SignKey = miConfig.SignKey
  742. struct3508.SecretKey = miConfig.SecretKey
  743. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  744. struct3508.Begndate = start_time
  745. struct3508.Enddate = end_time
  746. result1, result2, _ := service.FJyb3513(struct3508)
  747. saveLog(result1, result2, "3513", "3513")
  748. var res models.Result3513
  749. var respJSON2 map[string]interface{}
  750. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. }
  755. userJSONBytes2, _ := json.Marshal(respJSON2)
  756. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  757. utils.ErrorLog("解析失败:%v", err)
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. if res.Infcode == -1 {
  762. c.ServeSuccessJSON(map[string]interface{}{
  763. "failed_code": -10,
  764. "msg": res.ErrMsg,
  765. })
  766. } else {
  767. c.ServeSuccessJSON(map[string]interface{}{
  768. "info": res.Output,
  769. })
  770. }
  771. }
  772. func (c *HisApiController) Get35081() {
  773. admin_user_id, _ := c.GetInt64("admin_user_id")
  774. drug_id, _ := c.GetInt64("id")
  775. //start_time := c.GetString("start_time")
  776. //end_time := c.GetString("end_time")
  777. page, _ := c.GetInt("page")
  778. adminUser := c.GetAdminUserInfo()
  779. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  780. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  781. drug, _ := service.GetDrugByID(drug_id)
  782. var struct3508 models.Struct35081
  783. struct3508.FixmedinsCode = miConfig.Code
  784. struct3508.OrgName = miConfig.OrgName
  785. struct3508.AccessKey = miConfig.AccessKey
  786. struct3508.Opter = curRoles.UserName
  787. struct3508.RequestUrl = miConfig.Url
  788. struct3508.Url = miConfig.Url
  789. struct3508.AppId = miConfig.Cainfo
  790. struct3508.AppSecret = miConfig.AppSecret
  791. struct3508.Enckey = miConfig.EncKey
  792. struct3508.SignKey = miConfig.SignKey
  793. struct3508.SecretKey = miConfig.SecretKey
  794. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  795. struct3508.PageNum = page
  796. struct3508.PageSize = 10
  797. result1, result2, _ := service.FJyb35081(struct3508)
  798. saveLog(result1, result2, "35081", "35081")
  799. var res models.Result35081
  800. var respJSON2 map[string]interface{}
  801. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  804. return
  805. }
  806. userJSONBytes2, _ := json.Marshal(respJSON2)
  807. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  808. utils.ErrorLog("解析失败:%v", err)
  809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  810. return
  811. }
  812. if res.Infcode == -1 {
  813. c.ServeSuccessJSON(map[string]interface{}{
  814. "failed_code": -10,
  815. "msg": res.ErrMsg,
  816. })
  817. } else {
  818. c.ServeSuccessJSON(map[string]interface{}{
  819. "info": res.Output,
  820. })
  821. }
  822. }
  823. func (c *HisApiController) Get35082() {
  824. admin_user_id, _ := c.GetInt64("admin_user_id")
  825. drug_id, _ := c.GetInt64("id")
  826. //start_time := c.GetString("start_time")
  827. //end_time := c.GetString("end_time")
  828. page, _ := c.GetInt("page")
  829. adminUser := c.GetAdminUserInfo()
  830. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  831. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  832. drug, _ := service.GetDrugByID(drug_id)
  833. var struct3508 models.Struct35082
  834. struct3508.FixmedinsCode = miConfig.Code
  835. struct3508.OrgName = miConfig.OrgName
  836. struct3508.AccessKey = miConfig.AccessKey
  837. struct3508.Opter = curRoles.UserName
  838. struct3508.RequestUrl = miConfig.Url
  839. struct3508.Url = miConfig.Url
  840. struct3508.AppId = miConfig.Cainfo
  841. struct3508.AppSecret = miConfig.AppSecret
  842. struct3508.Enckey = miConfig.EncKey
  843. struct3508.SignKey = miConfig.SignKey
  844. struct3508.SecretKey = miConfig.SecretKey
  845. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  846. struct3508.PageNum = page
  847. struct3508.PageSize = 10
  848. result1, result2, _ := service.FJyb35082(struct3508)
  849. saveLog(result1, result2, "35082", "35082")
  850. var res models.Result35082
  851. var respJSON2 map[string]interface{}
  852. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  855. return
  856. }
  857. userJSONBytes2, _ := json.Marshal(respJSON2)
  858. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  859. utils.ErrorLog("解析失败:%v", err)
  860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  861. return
  862. }
  863. if res.Infcode == -1 {
  864. c.ServeSuccessJSON(map[string]interface{}{
  865. "failed_code": -10,
  866. "msg": res.ErrMsg,
  867. })
  868. } else {
  869. c.ServeSuccessJSON(map[string]interface{}{
  870. "info": res.Output,
  871. })
  872. }
  873. }
  874. func (c *HisApiController) FJ3501AND3502() {
  875. ids := c.GetString("ids")
  876. admin_user_id, _ := c.GetInt64("admin_user_id")
  877. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  878. id_arr := strings.Split(ids, ",")
  879. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  880. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  881. //库盘
  882. var errs []string
  883. for _, drug := range drugs {
  884. if drug.IsPc == 0 {
  885. var res2 ResultSix
  886. var res3 ResultSix
  887. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  888. var struct3501 models.Struct3501
  889. struct3501.Code = miConfig.Code
  890. struct3501.OrgName = miConfig.OrgName
  891. struct3501.AccessKey = miConfig.AccessKey
  892. struct3501.Opter = roles.UserName
  893. struct3501.RequestUrl = miConfig.Url
  894. struct3501.Url = miConfig.Url
  895. struct3501.AppId = miConfig.Cainfo
  896. struct3501.AppSecret = miConfig.AppSecret
  897. struct3501.Enckey = miConfig.EncKey
  898. struct3501.SignKey = miConfig.SignKey
  899. struct3501.SecretKey = miConfig.SecretKey
  900. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  901. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  902. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  903. struct3501.RxFlag = "1"
  904. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  905. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  906. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  907. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  908. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  909. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  910. struct3501.FixmedinsBchno = number
  911. struct3501.DrugTracCodg = drug.DrugCode
  912. memo := make(map[string]interface{})
  913. memo["pric"] = drug.Price
  914. bytesData, _ := json.Marshal(memo)
  915. struct3501.Memo = string(bytesData)
  916. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  917. result1, result2, _ := service.FJyb3501(struct3501)
  918. saveLog(result1, result2, "3501", "3501")
  919. //saveLog(result, requestLog, "2201", "挂号")
  920. var respJSON2 map[string]interface{}
  921. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  924. return
  925. }
  926. userJSONBytes2, _ := json.Marshal(respJSON2)
  927. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  928. utils.ErrorLog("解析失败:%v", err)
  929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  930. return
  931. }
  932. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  933. data := make(map[string]interface{})
  934. data["struct_3501s"] = struct3501
  935. client := &http.Client{}
  936. bytesData, _ := json.Marshal(data)
  937. var req *http.Request
  938. if miConfig.MdtrtareaAdmvs == "320830" {
  939. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  940. } else {
  941. if miConfig.MdtrtareaAdmvs == "320921" {
  942. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  943. } else {
  944. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  945. }
  946. }
  947. resp, _ := client.Do(req)
  948. defer resp.Body.Close()
  949. body, ioErr := ioutil.ReadAll(resp.Body)
  950. if ioErr != nil {
  951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  952. }
  953. var respJSON map[string]interface{}
  954. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  957. return
  958. }
  959. var resSix10265 ResultSix10265 //1101结果
  960. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  961. result, _ := json.Marshal(respJSON)
  962. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  963. utils.ErrorLog("解析失败:%v", err)
  964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  965. return
  966. }
  967. res2.InfRefmsgid = resSix10265.InfRefmsgid
  968. res2.Output = resSix10265.Output
  969. res2.ErrMsg = resSix10265.ErrMsg
  970. res2.Cainfo = resSix10265.Cainfo
  971. res2.WarnMsg = resSix10265.WarnMsg
  972. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  973. res2.Infcode = infocode
  974. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  975. data := make(map[string]interface{})
  976. data["struct_3501s"] = struct3501
  977. client := &http.Client{}
  978. bytesData, _ := json.Marshal(data)
  979. var req *http.Request
  980. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  981. resp, _ := client.Do(req)
  982. defer resp.Body.Close()
  983. body, ioErr := ioutil.ReadAll(resp.Body)
  984. if ioErr != nil {
  985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  986. }
  987. var respJSON map[string]interface{}
  988. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  991. return
  992. }
  993. var resSix10265 ResultSix10265 //1101结果
  994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  995. result, _ := json.Marshal(respJSON)
  996. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  997. utils.ErrorLog("解析失败:%v", err)
  998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  999. return
  1000. }
  1001. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1002. res2.Output = resSix10265.Output
  1003. res2.ErrMsg = resSix10265.ErrMsg
  1004. res2.Cainfo = resSix10265.Cainfo
  1005. res2.WarnMsg = resSix10265.WarnMsg
  1006. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1007. res2.Infcode = infocode
  1008. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  1009. data := make(map[string]interface{})
  1010. data["struct_3501s"] = struct3501
  1011. client := &http.Client{}
  1012. bytesData, _ := json.Marshal(data)
  1013. var req *http.Request
  1014. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  1015. resp, _ := client.Do(req)
  1016. defer resp.Body.Close()
  1017. body, ioErr := ioutil.ReadAll(resp.Body)
  1018. if ioErr != nil {
  1019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1020. }
  1021. var respJSON map[string]interface{}
  1022. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1025. return
  1026. }
  1027. var resSix10265 ResultSix10265 //1101结果
  1028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1029. result, _ := json.Marshal(respJSON)
  1030. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1031. utils.ErrorLog("解析失败:%v", err)
  1032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1033. return
  1034. }
  1035. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1036. res2.Output = resSix10265.Output
  1037. res2.ErrMsg = resSix10265.ErrMsg
  1038. res2.Cainfo = resSix10265.Cainfo
  1039. res2.WarnMsg = resSix10265.WarnMsg
  1040. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1041. res2.Infcode = infocode
  1042. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  1043. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  1044. saveLog(result1, result2, "3501", "3501")
  1045. //saveLog(result, requestLog, "2201", "挂号")
  1046. var respJSON2 map[string]interface{}
  1047. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1050. return
  1051. }
  1052. userJSONBytes2, _ := json.Marshal(respJSON2)
  1053. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1054. utils.ErrorLog("解析失败:%v", err)
  1055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1056. return
  1057. }
  1058. }
  1059. if res2.Infcode != -1 {
  1060. drug.IsPc = 1
  1061. drug.Bchno = number
  1062. drug.PcDate = time.Now().Unix()
  1063. err := service.SaveW(drug)
  1064. if err == nil {
  1065. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  1066. var struct3502 models.Struct3502
  1067. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1068. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1069. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1070. struct3502.FixmedinsCode = miConfig.Code
  1071. struct3502.Code = miConfig.Code
  1072. struct3502.RxFlag = "0"
  1073. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1074. struct3502.OrgName = miConfig.OrgName
  1075. struct3502.Opter = roles.UserName
  1076. struct3502.AccessKey = miConfig.AccessKey
  1077. struct3502.RequestUrl = miConfig.Url
  1078. struct3502.SecretKey = miConfig.SecretKey
  1079. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1080. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1081. struct3502.Url = miConfig.Url
  1082. struct3502.AppId = miConfig.Cainfo
  1083. struct3502.AppSecret = miConfig.AppSecret
  1084. struct3502.Enckey = miConfig.EncKey
  1085. struct3502.SignKey = miConfig.SignKey
  1086. struct3502.SecretKey = miConfig.SecretKey
  1087. struct3502.DrugTracCodg = drug.DrugCode
  1088. struct3502.Memo = ""
  1089. struct3502.InvChgType = "108"
  1090. struct3502.FixmedinsBchno = bg_number
  1091. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  1092. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  1093. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  1094. result11, result22, _ := service.FJyb3502(struct3502)
  1095. saveLog(result11, result22, "3502", "3502")
  1096. var respJSON3 map[string]interface{}
  1097. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1100. return
  1101. }
  1102. userJSONBytes3, _ := json.Marshal(respJSON3)
  1103. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1104. utils.ErrorLog("解析失败:%v", err)
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1106. return
  1107. }
  1108. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1109. data := make(map[string]interface{})
  1110. data["struct_3502s"] = struct3502
  1111. client := &http.Client{}
  1112. bytesData, _ := json.Marshal(data)
  1113. var req *http.Request
  1114. if miConfig.MdtrtareaAdmvs == "320830" {
  1115. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  1116. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1117. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1118. } else {
  1119. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1120. }
  1121. resp, _ := client.Do(req)
  1122. defer resp.Body.Close()
  1123. body, ioErr := ioutil.ReadAll(resp.Body)
  1124. if ioErr != nil {
  1125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1126. }
  1127. var respJSON map[string]interface{}
  1128. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1131. return
  1132. }
  1133. var resSix10265 ResultSix10265 //1101结果
  1134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1135. result, _ := json.Marshal(respJSON)
  1136. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1137. utils.ErrorLog("解析失败:%v", err)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1142. res3.Output = resSix10265.Output
  1143. res3.ErrMsg = resSix10265.ErrMsg
  1144. res3.Cainfo = resSix10265.Cainfo
  1145. res3.WarnMsg = resSix10265.WarnMsg
  1146. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1147. res3.Infcode = infocode
  1148. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1149. data := make(map[string]interface{})
  1150. data["struct_3502s"] = struct3502
  1151. client := &http.Client{}
  1152. bytesData, _ := json.Marshal(data)
  1153. var req *http.Request
  1154. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  1155. resp, _ := client.Do(req)
  1156. defer resp.Body.Close()
  1157. body, ioErr := ioutil.ReadAll(resp.Body)
  1158. if ioErr != nil {
  1159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1160. }
  1161. var respJSON map[string]interface{}
  1162. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1165. return
  1166. }
  1167. var resSix10265 ResultSix10265 //1101结果
  1168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1169. result, _ := json.Marshal(respJSON)
  1170. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1171. utils.ErrorLog("解析失败:%v", err)
  1172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1173. return
  1174. }
  1175. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1176. res3.Output = resSix10265.Output
  1177. res3.ErrMsg = resSix10265.ErrMsg
  1178. res3.Cainfo = resSix10265.Cainfo
  1179. res3.WarnMsg = resSix10265.WarnMsg
  1180. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1181. res3.Infcode = infocode
  1182. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1183. data := make(map[string]interface{})
  1184. data["struct_3501s"] = struct3501
  1185. client := &http.Client{}
  1186. bytesData, _ := json.Marshal(data)
  1187. var req *http.Request
  1188. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1189. resp, _ := client.Do(req)
  1190. defer resp.Body.Close()
  1191. body, ioErr := ioutil.ReadAll(resp.Body)
  1192. if ioErr != nil {
  1193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1194. }
  1195. var respJSON map[string]interface{}
  1196. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1199. return
  1200. }
  1201. var resSix10265 ResultSix10265 //1101结果
  1202. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1203. result, _ := json.Marshal(respJSON)
  1204. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1205. utils.ErrorLog("解析失败:%v", err)
  1206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1207. return
  1208. }
  1209. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1210. res2.Output = resSix10265.Output
  1211. res2.ErrMsg = resSix10265.ErrMsg
  1212. res2.Cainfo = resSix10265.Cainfo
  1213. res2.WarnMsg = resSix10265.WarnMsg
  1214. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1215. res2.Infcode = infocode
  1216. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1217. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  1218. saveLog(result11, result22, "3502", "3502")
  1219. var respJSON3 map[string]interface{}
  1220. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1223. return
  1224. }
  1225. userJSONBytes3, _ := json.Marshal(respJSON3)
  1226. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1227. utils.ErrorLog("解析失败:%v", err)
  1228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1229. return
  1230. }
  1231. }
  1232. if res3.Infcode == -1 {
  1233. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1234. c.ServeSuccessJSON(map[string]interface{}{
  1235. "failed_code": -10,
  1236. "msg": res3.ErrMsg,
  1237. })
  1238. } else {
  1239. drug.IsBg = 1
  1240. drug.BgBchno = bg_number
  1241. service.SaveW(drug)
  1242. }
  1243. }
  1244. } else {
  1245. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  1246. }
  1247. }
  1248. //变更
  1249. }
  1250. if len(errs) == 0 {
  1251. c.ServeSuccessJSON(map[string]interface{}{
  1252. "msg": "盘存变更成功",
  1253. })
  1254. } else {
  1255. c.ServeSuccessJSON(map[string]interface{}{
  1256. "failed_code": -10,
  1257. "msg": errs,
  1258. })
  1259. }
  1260. }
  1261. func (c *HisApiController) DeletePCandBG() {
  1262. ids := c.GetString("ids")
  1263. id_arr := strings.Split(ids, ",")
  1264. admin_user_id, _ := c.GetInt64("admin_user_id")
  1265. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1266. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1267. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1268. var err []string
  1269. for _, item := range drugs {
  1270. if item.IsPc == 1 && item.IsBg == 1 {
  1271. var res FJ3507Result
  1272. var res2 FJ3507Result
  1273. var struct3507 models.Struct3507
  1274. struct3507.FixmedinsBchno = item.Bchno
  1275. struct3507.InvDataType = "1"
  1276. struct3507.Opter = roles.UserName
  1277. struct3507.OrgName = miConfig.OrgName
  1278. struct3507.AccessKey = miConfig.AccessKey
  1279. struct3507.RequestUrl = miConfig.Url
  1280. struct3507.FixmedinsCode = miConfig.Code
  1281. struct3507.Code = miConfig.Code
  1282. struct3507.SecretKey = miConfig.SecretKey
  1283. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1284. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1285. struct3507.Url = miConfig.Url
  1286. struct3507.AppId = miConfig.Cainfo
  1287. struct3507.AppSecret = miConfig.AppSecret
  1288. struct3507.Enckey = miConfig.EncKey
  1289. struct3507.SignKey = miConfig.SignKey
  1290. struct3507.SecretKey = miConfig.SecretKey
  1291. if miConfig.MdtrtareaAdmvs == "350500" {
  1292. result, result1, _ := service.FJyb3507(struct3507)
  1293. saveLog(result, result1, "3507", "3507")
  1294. var respJSON2 map[string]interface{}
  1295. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1298. return
  1299. }
  1300. userJSONBytes2, _ := json.Marshal(respJSON2)
  1301. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1302. utils.ErrorLog("解析失败:%v", err)
  1303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1304. return
  1305. }
  1306. } else {
  1307. data := make(map[string]interface{})
  1308. data["struct_3507s"] = struct3507
  1309. client := &http.Client{}
  1310. bytesData, _ := json.Marshal(data)
  1311. var req *http.Request
  1312. if miConfig.MdtrtareaAdmvs == "320830" {
  1313. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1314. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1315. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1316. } else {
  1317. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1318. }
  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. res.InfRefmsgid = resSix10265.InfRefmsgid
  1340. //res.Output = resSix10265.Output
  1341. res.ErrMsg = resSix10265.ErrMsg
  1342. res.Cainfo = resSix10265.Cainfo
  1343. res.WarnMsg = resSix10265.WarnMsg
  1344. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1345. res.Infcode = infocode
  1346. }
  1347. if res.Infcode == 0 {
  1348. item.IsPc = 0
  1349. err2 := service.SaveW(item)
  1350. if err2 == nil {
  1351. var struct3507_2 models.Struct3507
  1352. struct3507_2.OrgName = miConfig.OrgName
  1353. struct3507_2.AccessKey = miConfig.AccessKey
  1354. struct3507_2.RequestUrl = miConfig.Url
  1355. struct3507_2.Opter = roles.UserName
  1356. struct3507_2.FixmedinsCode = miConfig.Code
  1357. struct3507_2.Code = miConfig.Code
  1358. struct3507_2.SecretKey = miConfig.SecretKey
  1359. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1360. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1361. struct3507_2.Url = miConfig.Url
  1362. struct3507_2.AppId = miConfig.Cainfo
  1363. struct3507_2.AppSecret = miConfig.AppSecret
  1364. struct3507_2.Enckey = miConfig.EncKey
  1365. struct3507_2.SignKey = miConfig.SignKey
  1366. struct3507_2.SecretKey = miConfig.SecretKey
  1367. struct3507_2.FixmedinsBchno = item.BgBchno
  1368. struct3507_2.InvDataType = "2"
  1369. if miConfig.MdtrtareaAdmvs == "350500" {
  1370. result11, result22, _ := service.FJyb3507(struct3507_2)
  1371. saveLog(result11, result22, "3507", "3507")
  1372. var respJSON3 map[string]interface{}
  1373. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1376. return
  1377. }
  1378. userJSONBytes3, _ := json.Marshal(respJSON3)
  1379. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1380. utils.ErrorLog("解析失败:%v", err)
  1381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1382. return
  1383. }
  1384. } else {
  1385. data := make(map[string]interface{})
  1386. data["struct_3507s"] = struct3507_2
  1387. client := &http.Client{}
  1388. bytesData, _ := json.Marshal(data)
  1389. var req *http.Request
  1390. if miConfig.MdtrtareaAdmvs == "320830" {
  1391. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1392. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1393. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1394. } else {
  1395. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1396. }
  1397. resp, _ := client.Do(req)
  1398. defer resp.Body.Close()
  1399. body, ioErr := ioutil.ReadAll(resp.Body)
  1400. if ioErr != nil {
  1401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1402. }
  1403. var respJSON map[string]interface{}
  1404. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1407. return
  1408. }
  1409. var resSix10265 ResultSix10265 //1101结果
  1410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1411. result, _ := json.Marshal(respJSON)
  1412. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1413. utils.ErrorLog("解析失败:%v", err)
  1414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1415. return
  1416. }
  1417. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1418. //res2.Output = resSix10265.Output
  1419. res2.ErrMsg = resSix10265.ErrMsg
  1420. res2.Cainfo = resSix10265.Cainfo
  1421. res2.WarnMsg = resSix10265.WarnMsg
  1422. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1423. res2.Infcode = infocode
  1424. }
  1425. if res2.Infcode != -1 {
  1426. item.IsBg = 0
  1427. item.Bchno = ""
  1428. item.BgBchno = ""
  1429. item.PcDate = 0
  1430. service.SaveW(item)
  1431. } else {
  1432. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1433. }
  1434. }
  1435. } else {
  1436. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1437. }
  1438. }
  1439. if item.IsPc == 1 && item.IsBg == 0 {
  1440. var res FJ3507Result
  1441. var struct3507 models.Struct3507
  1442. struct3507.FixmedinsBchno = item.Bchno
  1443. struct3507.InvDataType = "1"
  1444. struct3507.Opter = roles.UserName
  1445. struct3507.FixmedinsCode = miConfig.Code
  1446. struct3507.Code = miConfig.Code
  1447. struct3507.OrgName = miConfig.OrgName
  1448. struct3507.AccessKey = miConfig.AccessKey
  1449. struct3507.RequestUrl = miConfig.Url
  1450. struct3507.SecretKey = miConfig.SecretKey
  1451. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1452. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1453. struct3507.Url = miConfig.Url
  1454. struct3507.AppId = miConfig.Cainfo
  1455. struct3507.AppSecret = miConfig.AppSecret
  1456. struct3507.Enckey = miConfig.EncKey
  1457. struct3507.SignKey = miConfig.SignKey
  1458. struct3507.SecretKey = miConfig.SecretKey
  1459. //result, result1, _ := service.FJyb3507(struct3507)
  1460. //saveLog(result, result1, "3507", "3507")
  1461. if miConfig.MdtrtareaAdmvs == "350500" {
  1462. result, result1, _ := service.FJyb3507(struct3507)
  1463. saveLog(result, result1, "3507", "3507")
  1464. var respJSON2 map[string]interface{}
  1465. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1468. return
  1469. }
  1470. userJSONBytes2, _ := json.Marshal(respJSON2)
  1471. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1472. utils.ErrorLog("解析失败:%v", err)
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1474. return
  1475. }
  1476. } else {
  1477. data := make(map[string]interface{})
  1478. data["struct_3507s"] = struct3507
  1479. client := &http.Client{}
  1480. bytesData, _ := json.Marshal(data)
  1481. var req *http.Request
  1482. if miConfig.MdtrtareaAdmvs == "320830" {
  1483. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1484. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1485. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1486. } else {
  1487. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1488. }
  1489. resp, _ := client.Do(req)
  1490. defer resp.Body.Close()
  1491. body, ioErr := ioutil.ReadAll(resp.Body)
  1492. if ioErr != nil {
  1493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1494. }
  1495. var respJSON map[string]interface{}
  1496. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1499. return
  1500. }
  1501. var resSix10265 ResultSix10265 //1101结果
  1502. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1503. result, _ := json.Marshal(respJSON)
  1504. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1505. utils.ErrorLog("解析失败:%v", err)
  1506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1507. return
  1508. }
  1509. res.InfRefmsgid = resSix10265.InfRefmsgid
  1510. //res.Output = resSix10265.Output
  1511. res.ErrMsg = resSix10265.ErrMsg
  1512. res.Cainfo = resSix10265.Cainfo
  1513. res.WarnMsg = resSix10265.WarnMsg
  1514. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1515. res.Infcode = infocode
  1516. }
  1517. if res.Infcode == 0 {
  1518. item.IsPc = 0
  1519. item.Bchno = ""
  1520. item.BgBchno = ""
  1521. item.PcDate = 0
  1522. service.SaveW(item)
  1523. } else {
  1524. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1525. }
  1526. }
  1527. if item.IsPc == 0 && item.IsBg == 1 {
  1528. var res FJ3507Result
  1529. var struct3507 models.Struct3507
  1530. struct3507.FixmedinsBchno = item.BgBchno
  1531. struct3507.InvDataType = "2"
  1532. struct3507.Opter = roles.UserName
  1533. struct3507.FixmedinsCode = miConfig.Code
  1534. struct3507.OrgName = miConfig.OrgName
  1535. struct3507.AccessKey = miConfig.AccessKey
  1536. struct3507.RequestUrl = miConfig.Url
  1537. struct3507.SecretKey = miConfig.SecretKey
  1538. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1539. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1540. struct3507.Url = miConfig.Url
  1541. struct3507.AppId = miConfig.Cainfo
  1542. struct3507.AppSecret = miConfig.AppSecret
  1543. struct3507.Enckey = miConfig.EncKey
  1544. struct3507.SignKey = miConfig.SignKey
  1545. struct3507.SecretKey = miConfig.SecretKey
  1546. //result, result1, _ := service.FJyb3507(struct3507)
  1547. //saveLog(result, result1, "3507", "3507")
  1548. if miConfig.MdtrtareaAdmvs == "350500" {
  1549. result, result1, _ := service.FJyb3507(struct3507)
  1550. saveLog(result, result1, "3507", "3507")
  1551. var respJSON2 map[string]interface{}
  1552. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1555. return
  1556. }
  1557. userJSONBytes2, _ := json.Marshal(respJSON2)
  1558. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1559. utils.ErrorLog("解析失败:%v", err)
  1560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1561. return
  1562. }
  1563. } else {
  1564. data := make(map[string]interface{})
  1565. data["struct_3507s"] = struct3507
  1566. client := &http.Client{}
  1567. bytesData, _ := json.Marshal(data)
  1568. var req *http.Request
  1569. if miConfig.MdtrtareaAdmvs == "320830" {
  1570. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1571. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1572. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1573. } else {
  1574. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1575. }
  1576. resp, _ := client.Do(req)
  1577. defer resp.Body.Close()
  1578. body, ioErr := ioutil.ReadAll(resp.Body)
  1579. if ioErr != nil {
  1580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1581. }
  1582. var respJSON map[string]interface{}
  1583. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1586. return
  1587. }
  1588. var resSix10265 ResultSix10265 //1101结果
  1589. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1590. result, _ := json.Marshal(respJSON)
  1591. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1592. utils.ErrorLog("解析失败:%v", err)
  1593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1594. return
  1595. }
  1596. res.InfRefmsgid = resSix10265.InfRefmsgid
  1597. //res.Output = resSix10265.Output
  1598. res.ErrMsg = resSix10265.ErrMsg
  1599. res.Cainfo = resSix10265.Cainfo
  1600. res.WarnMsg = resSix10265.WarnMsg
  1601. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1602. res.Infcode = infocode
  1603. }
  1604. if res.Infcode == 0 {
  1605. item.IsBg = 0
  1606. item.Bchno = ""
  1607. item.BgBchno = ""
  1608. item.PcDate = 0
  1609. service.SaveW(item)
  1610. } else {
  1611. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1612. }
  1613. }
  1614. }
  1615. if len(err) == 0 {
  1616. c.ServeSuccessJSON(map[string]interface{}{
  1617. "msg": "删除盘存变更成功",
  1618. })
  1619. } else {
  1620. c.ServeSuccessJSON(map[string]interface{}{
  1621. "failed_code": -10,
  1622. "msg": err,
  1623. })
  1624. }
  1625. }
  1626. func (c *HisApiController) DeleteXSandBG() {
  1627. ids := c.GetString("ids")
  1628. id_arr := strings.Split(ids, ",")
  1629. admin_user_id, _ := c.GetInt64("admin_user_id")
  1630. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1631. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1632. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1633. var err []string
  1634. for _, item := range flows {
  1635. if item.IsSale == 1 && item.IsChange == 1 {
  1636. var res FJ3507Result
  1637. var res2 FJ3507Result
  1638. var struct3507 models.Struct3507
  1639. struct3507.FixmedinsBchno = item.Bchno
  1640. struct3507.InvDataType = "4"
  1641. struct3507.Opter = roles.UserName
  1642. struct3507.OrgName = miConfig.OrgName
  1643. struct3507.AccessKey = miConfig.AccessKey
  1644. struct3507.RequestUrl = miConfig.Url
  1645. struct3507.FixmedinsCode = miConfig.Code
  1646. struct3507.SecretKey = miConfig.SecretKey
  1647. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1648. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1649. struct3507.Url = miConfig.Url
  1650. struct3507.AppId = miConfig.Cainfo
  1651. struct3507.AppSecret = miConfig.AppSecret
  1652. struct3507.Enckey = miConfig.EncKey
  1653. struct3507.SignKey = miConfig.SignKey
  1654. struct3507.SecretKey = miConfig.SecretKey
  1655. //result, result1, _ := service.FJyb3507(struct3507)
  1656. //saveLog(result, result1, "3507", "3507")
  1657. if miConfig.MdtrtareaAdmvs == "350500" {
  1658. result, result1, _ := service.FJyb3507(struct3507)
  1659. saveLog(result, result1, "3507", "3507")
  1660. var respJSON2 map[string]interface{}
  1661. if err := json.Unmarshal([]byte(string(result)), &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.IsSale = 0
  1715. item.SaleDate = ""
  1716. item.Bchno = ""
  1717. err2 := service.SaveDF(item)
  1718. if err2 == nil {
  1719. var struct3507_2 models.Struct3507
  1720. struct3507_2.OrgName = miConfig.OrgName
  1721. struct3507_2.AccessKey = miConfig.AccessKey
  1722. struct3507_2.RequestUrl = miConfig.Url
  1723. struct3507_2.Opter = roles.UserName
  1724. struct3507_2.FixmedinsCode = miConfig.Code
  1725. struct3507_2.Code = miConfig.Code
  1726. struct3507_2.SecretKey = miConfig.SecretKey
  1727. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1728. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1729. struct3507_2.Url = miConfig.Url
  1730. struct3507_2.AppId = miConfig.Cainfo
  1731. struct3507_2.AppSecret = miConfig.AppSecret
  1732. struct3507_2.Enckey = miConfig.EncKey
  1733. struct3507_2.SignKey = miConfig.SignKey
  1734. struct3507_2.SecretKey = miConfig.SecretKey
  1735. struct3507_2.FixmedinsBchno = item.BgBchno
  1736. struct3507_2.InvDataType = "2"
  1737. if miConfig.MdtrtareaAdmvs == "350500" {
  1738. result11, result22, _ := service.FJyb3507(struct3507_2)
  1739. saveLog(result11, result22, "3507", "3507")
  1740. var respJSON3 map[string]interface{}
  1741. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1744. return
  1745. }
  1746. userJSONBytes3, _ := json.Marshal(respJSON3)
  1747. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1748. utils.ErrorLog("解析失败:%v", err)
  1749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1750. return
  1751. }
  1752. } else {
  1753. data := make(map[string]interface{})
  1754. data["struct_3507s"] = struct3507_2
  1755. client := &http.Client{}
  1756. bytesData, _ := json.Marshal(data)
  1757. var req *http.Request
  1758. if miConfig.MdtrtareaAdmvs == "320830" {
  1759. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1760. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1761. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1762. } else {
  1763. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1764. }
  1765. resp, _ := client.Do(req)
  1766. defer resp.Body.Close()
  1767. body, ioErr := ioutil.ReadAll(resp.Body)
  1768. if ioErr != nil {
  1769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1770. }
  1771. var respJSON map[string]interface{}
  1772. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1775. return
  1776. }
  1777. var resSix10265 ResultSix10265 //1101结果
  1778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1779. result, _ := json.Marshal(respJSON)
  1780. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1781. utils.ErrorLog("解析失败:%v", err)
  1782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1783. return
  1784. }
  1785. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1786. //res.Output = resSix10265.Output
  1787. res2.ErrMsg = resSix10265.ErrMsg
  1788. res2.Cainfo = resSix10265.Cainfo
  1789. res2.WarnMsg = resSix10265.WarnMsg
  1790. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1791. res2.Infcode = infocode
  1792. }
  1793. if res2.Infcode == 0 {
  1794. item.IsChange = 0
  1795. item.BgBchno = ""
  1796. service.SaveDF2(item)
  1797. } else {
  1798. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1799. }
  1800. }
  1801. } else {
  1802. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1803. }
  1804. }
  1805. if item.IsSale == 2 && item.IsChange == 1 {
  1806. var res FJ3507Result
  1807. var res2 FJ3507Result
  1808. var struct3507 models.Struct3507
  1809. struct3507.FixmedinsBchno = item.Bchno
  1810. struct3507.InvDataType = "4"
  1811. struct3507.Opter = roles.UserName
  1812. struct3507.OrgName = miConfig.OrgName
  1813. struct3507.AccessKey = miConfig.AccessKey
  1814. struct3507.RequestUrl = miConfig.Url
  1815. struct3507.FixmedinsCode = miConfig.Code
  1816. struct3507.Code = miConfig.Code
  1817. struct3507.SecretKey = miConfig.SecretKey
  1818. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1819. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1820. struct3507.Url = miConfig.Url
  1821. struct3507.AppId = miConfig.Cainfo
  1822. struct3507.AppSecret = miConfig.AppSecret
  1823. struct3507.Enckey = miConfig.EncKey
  1824. struct3507.SignKey = miConfig.SignKey
  1825. struct3507.SecretKey = miConfig.SecretKey
  1826. //result, result1, _ := service.FJyb3507(struct3507)
  1827. //saveLog(result, result1, "3507", "3507")
  1828. //
  1829. //var respJSON2 map[string]interface{}
  1830. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1831. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1832. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1833. // return
  1834. //}
  1835. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1836. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1837. // utils.ErrorLog("解析失败:%v", err)
  1838. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1839. // return
  1840. //}
  1841. if miConfig.MdtrtareaAdmvs == "350500" {
  1842. result, result1, _ := service.FJyb3507(struct3507)
  1843. saveLog(result, result1, "3507", "3507")
  1844. var respJSON2 map[string]interface{}
  1845. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1848. return
  1849. }
  1850. userJSONBytes2, _ := json.Marshal(respJSON2)
  1851. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1852. utils.ErrorLog("解析失败:%v", err)
  1853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1854. return
  1855. }
  1856. } else {
  1857. data := make(map[string]interface{})
  1858. data["struct_3507s"] = struct3507
  1859. client := &http.Client{}
  1860. bytesData, _ := json.Marshal(data)
  1861. var req *http.Request
  1862. if miConfig.MdtrtareaAdmvs == "320830" {
  1863. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1864. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1865. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1866. } else {
  1867. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1868. }
  1869. resp, _ := client.Do(req)
  1870. defer resp.Body.Close()
  1871. body, ioErr := ioutil.ReadAll(resp.Body)
  1872. if ioErr != nil {
  1873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1874. }
  1875. var respJSON map[string]interface{}
  1876. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1879. return
  1880. }
  1881. var resSix10265 ResultSix10265 //1101结果
  1882. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1883. result, _ := json.Marshal(respJSON)
  1884. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1885. utils.ErrorLog("解析失败:%v", err)
  1886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1887. return
  1888. }
  1889. res.InfRefmsgid = resSix10265.InfRefmsgid
  1890. //res.Output = resSix10265.Output
  1891. res.ErrMsg = resSix10265.ErrMsg
  1892. res.Cainfo = resSix10265.Cainfo
  1893. res.WarnMsg = resSix10265.WarnMsg
  1894. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1895. res.Infcode = infocode
  1896. }
  1897. if res.Infcode == 0 {
  1898. item.IsSale = 0
  1899. item.SaleDate = ""
  1900. item.Bchno = ""
  1901. err2 := service.SaveDF(item)
  1902. if err2 == nil {
  1903. var struct3507_2 models.Struct3507
  1904. struct3507_2.OrgName = miConfig.OrgName
  1905. struct3507_2.AccessKey = miConfig.AccessKey
  1906. struct3507_2.RequestUrl = miConfig.Url
  1907. struct3507_2.Opter = roles.UserName
  1908. struct3507_2.FixmedinsCode = miConfig.Code
  1909. struct3507_2.Code = miConfig.Code
  1910. struct3507_2.SecretKey = miConfig.SecretKey
  1911. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1912. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1913. struct3507_2.Url = miConfig.Url
  1914. struct3507_2.AppId = miConfig.Cainfo
  1915. struct3507_2.AppSecret = miConfig.AppSecret
  1916. struct3507_2.Enckey = miConfig.EncKey
  1917. struct3507_2.SignKey = miConfig.SignKey
  1918. struct3507_2.SecretKey = miConfig.SecretKey
  1919. struct3507_2.FixmedinsBchno = item.BgBchno
  1920. struct3507_2.InvDataType = "2"
  1921. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1922. //saveLog(result11, result22, "3507", "3507")
  1923. //var respJSON3 map[string]interface{}
  1924. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1925. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1927. // return
  1928. //}
  1929. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1930. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1931. // utils.ErrorLog("解析失败:%v", err)
  1932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1933. // return
  1934. //}
  1935. if miConfig.MdtrtareaAdmvs == "350500" {
  1936. result11, result22, _ := service.FJyb3507(struct3507_2)
  1937. saveLog(result11, result22, "3507", "3507")
  1938. var respJSON3 map[string]interface{}
  1939. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1942. return
  1943. }
  1944. userJSONBytes3, _ := json.Marshal(respJSON3)
  1945. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1946. utils.ErrorLog("解析失败:%v", err)
  1947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1948. return
  1949. }
  1950. } else {
  1951. data := make(map[string]interface{})
  1952. data["struct_3507s"] = struct3507_2
  1953. client := &http.Client{}
  1954. bytesData, _ := json.Marshal(data)
  1955. var req *http.Request
  1956. if miConfig.MdtrtareaAdmvs == "320830" {
  1957. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1958. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1959. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1960. } else {
  1961. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1962. }
  1963. resp, _ := client.Do(req)
  1964. defer resp.Body.Close()
  1965. body, ioErr := ioutil.ReadAll(resp.Body)
  1966. if ioErr != nil {
  1967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1968. }
  1969. var respJSON map[string]interface{}
  1970. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1973. return
  1974. }
  1975. var resSix10265 ResultSix10265 //1101结果
  1976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1977. result, _ := json.Marshal(respJSON)
  1978. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1979. utils.ErrorLog("解析失败:%v", err)
  1980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1981. return
  1982. }
  1983. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1984. //res.Output = resSix10265.Output
  1985. res2.ErrMsg = resSix10265.ErrMsg
  1986. res2.Cainfo = resSix10265.Cainfo
  1987. res2.WarnMsg = resSix10265.WarnMsg
  1988. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1989. res2.Infcode = infocode
  1990. }
  1991. if res2.Infcode == 0 {
  1992. item.IsChange = 0
  1993. item.BgBchno = ""
  1994. service.SaveDF2(item)
  1995. } else {
  1996. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1997. }
  1998. }
  1999. } else {
  2000. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2001. }
  2002. }
  2003. if item.IsSale == 1 && item.IsChange == 0 {
  2004. var res FJ3507Result
  2005. var struct3507 models.Struct3507
  2006. struct3507.FixmedinsBchno = item.Bchno
  2007. struct3507.InvDataType = "4"
  2008. struct3507.Opter = roles.UserName
  2009. struct3507.FixmedinsCode = miConfig.Code
  2010. struct3507.Code = miConfig.Code
  2011. struct3507.OrgName = miConfig.OrgName
  2012. struct3507.AccessKey = miConfig.AccessKey
  2013. struct3507.RequestUrl = miConfig.Url
  2014. struct3507.SecretKey = miConfig.SecretKey
  2015. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2016. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2017. struct3507.Url = miConfig.Url
  2018. struct3507.AppId = miConfig.Cainfo
  2019. struct3507.AppSecret = miConfig.AppSecret
  2020. struct3507.Enckey = miConfig.EncKey
  2021. struct3507.SignKey = miConfig.SignKey
  2022. struct3507.SecretKey = miConfig.SecretKey
  2023. //result, result1, _ := service.FJyb3507(struct3507)
  2024. //saveLog(result, result1, "3507", "3507")
  2025. //
  2026. //var respJSON3 map[string]interface{}
  2027. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2028. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2030. // return
  2031. //}
  2032. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2033. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2034. // utils.ErrorLog("解析失败:%v", err)
  2035. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2036. // return
  2037. //}
  2038. if miConfig.MdtrtareaAdmvs == "350500" {
  2039. result, result1, _ := service.FJyb3507(struct3507)
  2040. saveLog(result, result1, "3507", "3507")
  2041. var respJSON2 map[string]interface{}
  2042. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2045. return
  2046. }
  2047. userJSONBytes2, _ := json.Marshal(respJSON2)
  2048. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2049. utils.ErrorLog("解析失败:%v", err)
  2050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2051. return
  2052. }
  2053. } else {
  2054. data := make(map[string]interface{})
  2055. data["struct_3507s"] = struct3507
  2056. client := &http.Client{}
  2057. bytesData, _ := json.Marshal(data)
  2058. var req *http.Request
  2059. if miConfig.MdtrtareaAdmvs == "320830" {
  2060. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2061. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2062. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2063. } else {
  2064. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2065. }
  2066. resp, _ := client.Do(req)
  2067. defer resp.Body.Close()
  2068. body, ioErr := ioutil.ReadAll(resp.Body)
  2069. if ioErr != nil {
  2070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2071. }
  2072. var respJSON map[string]interface{}
  2073. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2076. return
  2077. }
  2078. var resSix10265 ResultSix10265 //1101结果
  2079. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2080. result, _ := json.Marshal(respJSON)
  2081. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2082. utils.ErrorLog("解析失败:%v", err)
  2083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2084. return
  2085. }
  2086. res.InfRefmsgid = resSix10265.InfRefmsgid
  2087. //res.Output = resSix10265.Output
  2088. res.ErrMsg = resSix10265.ErrMsg
  2089. res.Cainfo = resSix10265.Cainfo
  2090. res.WarnMsg = resSix10265.WarnMsg
  2091. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2092. res.Infcode = infocode
  2093. }
  2094. if res.Infcode == 0 {
  2095. item.IsSale = 0
  2096. item.SaleDate = ""
  2097. service.SaveDF(item)
  2098. } else {
  2099. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2100. }
  2101. }
  2102. if item.IsSale == 2 && item.IsChange == 0 {
  2103. var res FJ3507Result
  2104. var struct3507 models.Struct3507
  2105. struct3507.FixmedinsBchno = item.Bchno
  2106. struct3507.InvDataType = "4"
  2107. struct3507.Opter = roles.UserName
  2108. struct3507.FixmedinsCode = miConfig.Code
  2109. struct3507.Code = miConfig.Code
  2110. struct3507.OrgName = miConfig.OrgName
  2111. struct3507.AccessKey = miConfig.AccessKey
  2112. struct3507.RequestUrl = miConfig.Url
  2113. struct3507.SecretKey = miConfig.SecretKey
  2114. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2115. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2116. struct3507.Url = miConfig.Url
  2117. struct3507.AppId = miConfig.Cainfo
  2118. struct3507.AppSecret = miConfig.AppSecret
  2119. struct3507.Enckey = miConfig.EncKey
  2120. struct3507.SignKey = miConfig.SignKey
  2121. struct3507.SecretKey = miConfig.SecretKey
  2122. //result, result1, _ := service.FJyb3507(struct3507)
  2123. //saveLog(result, result1, "3507", "3507")
  2124. //
  2125. //var respJSON3 map[string]interface{}
  2126. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2127. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2128. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2129. // return
  2130. //}
  2131. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2132. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2133. // utils.ErrorLog("解析失败:%v", err)
  2134. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2135. // return
  2136. //}
  2137. if miConfig.MdtrtareaAdmvs == "350500" {
  2138. result, result1, _ := service.FJyb3507(struct3507)
  2139. saveLog(result, result1, "3507", "3507")
  2140. var respJSON2 map[string]interface{}
  2141. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2144. return
  2145. }
  2146. userJSONBytes2, _ := json.Marshal(respJSON2)
  2147. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2148. utils.ErrorLog("解析失败:%v", err)
  2149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2150. return
  2151. }
  2152. } else {
  2153. data := make(map[string]interface{})
  2154. data["struct_3507s"] = struct3507
  2155. client := &http.Client{}
  2156. bytesData, _ := json.Marshal(data)
  2157. var req *http.Request
  2158. if miConfig.MdtrtareaAdmvs == "320830" {
  2159. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2160. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2161. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2162. } else {
  2163. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2164. }
  2165. resp, _ := client.Do(req)
  2166. defer resp.Body.Close()
  2167. body, ioErr := ioutil.ReadAll(resp.Body)
  2168. if ioErr != nil {
  2169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2170. }
  2171. var respJSON map[string]interface{}
  2172. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2175. return
  2176. }
  2177. var resSix10265 ResultSix10265 //1101结果
  2178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2179. result, _ := json.Marshal(respJSON)
  2180. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2181. utils.ErrorLog("解析失败:%v", err)
  2182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2183. return
  2184. }
  2185. res.InfRefmsgid = resSix10265.InfRefmsgid
  2186. //res.Output = resSix10265.Output
  2187. res.ErrMsg = resSix10265.ErrMsg
  2188. res.Cainfo = resSix10265.Cainfo
  2189. res.WarnMsg = resSix10265.WarnMsg
  2190. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2191. res.Infcode = infocode
  2192. }
  2193. if res.Infcode == 0 {
  2194. item.IsSale = 0
  2195. item.SaleDate = ""
  2196. item.Bchno = ""
  2197. service.SaveDF(item)
  2198. } else {
  2199. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2200. }
  2201. }
  2202. if item.IsSale == 0 && item.IsChange == 1 {
  2203. var res FJ3507Result
  2204. var struct3507 models.Struct3507
  2205. struct3507.FixmedinsBchno = item.BgBchno
  2206. struct3507.InvDataType = "2"
  2207. struct3507.Opter = roles.UserName
  2208. struct3507.FixmedinsCode = miConfig.Code
  2209. struct3507.Code = miConfig.Code
  2210. struct3507.OrgName = miConfig.OrgName
  2211. struct3507.AccessKey = miConfig.AccessKey
  2212. struct3507.RequestUrl = miConfig.Url
  2213. struct3507.SecretKey = miConfig.SecretKey
  2214. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2215. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2216. struct3507.Url = miConfig.Url
  2217. struct3507.AppId = miConfig.Cainfo
  2218. struct3507.AppSecret = miConfig.AppSecret
  2219. struct3507.Enckey = miConfig.EncKey
  2220. struct3507.SignKey = miConfig.SignKey
  2221. struct3507.SecretKey = miConfig.SecretKey
  2222. //result, result1, _ := service.FJyb3507(struct3507)
  2223. //saveLog(result, result1, "3507", "3507")
  2224. //
  2225. //var respJSON3 map[string]interface{}
  2226. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2227. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2228. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2229. // return
  2230. //}
  2231. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2232. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2233. // utils.ErrorLog("解析失败:%v", err)
  2234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2235. // return
  2236. //}
  2237. if miConfig.MdtrtareaAdmvs == "350500" {
  2238. result, result1, _ := service.FJyb3507(struct3507)
  2239. saveLog(result, result1, "3507", "3507")
  2240. var respJSON2 map[string]interface{}
  2241. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2244. return
  2245. }
  2246. userJSONBytes2, _ := json.Marshal(respJSON2)
  2247. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2248. utils.ErrorLog("解析失败:%v", err)
  2249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2250. return
  2251. }
  2252. } else {
  2253. data := make(map[string]interface{})
  2254. data["struct_3507s"] = struct3507
  2255. client := &http.Client{}
  2256. bytesData, _ := json.Marshal(data)
  2257. var req *http.Request
  2258. if miConfig.MdtrtareaAdmvs == "320830" {
  2259. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2260. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2261. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2262. } else {
  2263. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2264. }
  2265. resp, _ := client.Do(req)
  2266. defer resp.Body.Close()
  2267. body, ioErr := ioutil.ReadAll(resp.Body)
  2268. if ioErr != nil {
  2269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2270. }
  2271. var respJSON map[string]interface{}
  2272. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2275. return
  2276. }
  2277. var resSix10265 ResultSix10265 //1101结果
  2278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2279. result, _ := json.Marshal(respJSON)
  2280. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2281. utils.ErrorLog("解析失败:%v", err)
  2282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2283. return
  2284. }
  2285. res.InfRefmsgid = resSix10265.InfRefmsgid
  2286. //res.Output = resSix10265.Output
  2287. res.ErrMsg = resSix10265.ErrMsg
  2288. res.Cainfo = resSix10265.Cainfo
  2289. res.WarnMsg = resSix10265.WarnMsg
  2290. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2291. res.Infcode = infocode
  2292. }
  2293. if res.Infcode == 0 {
  2294. item.IsChange = 0
  2295. item.BgBchno = ""
  2296. service.SaveDF2(item)
  2297. } else {
  2298. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2299. }
  2300. }
  2301. }
  2302. if len(err) == 0 {
  2303. c.ServeSuccessJSON(map[string]interface{}{
  2304. "msg": "删除销售变更成功",
  2305. })
  2306. } else {
  2307. c.ServeSuccessJSON(map[string]interface{}{
  2308. "failed_code": -10,
  2309. "msg": err,
  2310. })
  2311. }
  2312. }
  2313. //func (c *HisApiController) BatchFJ3501AND3502() {
  2314. // //ids := c.GetString("ids")
  2315. // start_time := c.GetString("start_time")
  2316. // end_time := c.GetString("end_time")
  2317. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2318. //
  2319. //
  2320. // timeLayout := "2006-01-02"
  2321. // loc, _ := time.LoadLocation("Local")
  2322. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2323. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2324. //
  2325. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2326. // //id_arr := strings.Split(ids, ",")
  2327. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2328. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2329. // //库盘
  2330. // var errs []string
  2331. // for _, drug := range drugs {
  2332. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2333. // var res2 ResultSix
  2334. // var res3 ResultSix
  2335. //
  2336. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2337. // var struct3501 models.Struct3501
  2338. // struct3501.Code = miConfig.Code
  2339. // struct3501.OrgName = miConfig.OrgName
  2340. // struct3501.AccessKey = miConfig.AccessKey
  2341. // struct3501.Opter = roles.UserName
  2342. // struct3501.RequestUrl = miConfig.Url
  2343. // struct3501.Url = miConfig.Url
  2344. // struct3501.AppId = miConfig.Cainfo
  2345. // struct3501.AppSecret = miConfig.AppSecret
  2346. // struct3501.Enckey = miConfig.EncKey
  2347. // struct3501.SignKey = miConfig.SignKey
  2348. // struct3501.SecretKey = miConfig.SecretKey
  2349. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2350. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2351. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2352. // struct3501.RxFlag = "1"
  2353. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2354. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2355. //
  2356. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2357. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2358. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2359. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2360. // struct3501.FixmedinsBchno = number
  2361. // struct3501.DrugTracCodg = drug.DrugCode
  2362. // memo := make(map[string]interface{})
  2363. // memo["pric"] = drug.Price
  2364. // bytesData, _ := json.Marshal(memo)
  2365. // struct3501.Memo = string(bytesData)
  2366. //
  2367. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2368. //
  2369. // result1, result2, _ := service.FJyb3501(struct3501)
  2370. // saveLog(result1, result2, "3501", "3501")
  2371. // //saveLog(result, requestLog, "2201", "挂号")
  2372. //
  2373. // var respJSON2 map[string]interface{}
  2374. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2375. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2376. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2377. // return
  2378. // }
  2379. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2380. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2381. // utils.ErrorLog("解析失败:%v", err)
  2382. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2383. // return
  2384. // }
  2385. //
  2386. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2387. // data := make(map[string]interface{})
  2388. // data["struct_3501s"] = struct3501
  2389. // client := &http.Client{}
  2390. // bytesData, _ := json.Marshal(data)
  2391. // var req *http.Request
  2392. // if miConfig.MdtrtareaAdmvs == "320921" {
  2393. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2394. // } else {
  2395. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2396. // }
  2397. //
  2398. // resp, _ := client.Do(req)
  2399. // defer resp.Body.Close()
  2400. // body, ioErr := ioutil.ReadAll(resp.Body)
  2401. // if ioErr != nil {
  2402. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2403. // }
  2404. // var respJSON map[string]interface{}
  2405. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2406. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2408. // return
  2409. // }
  2410. // var resSix10265 ResultSix10265 //1101结果
  2411. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2412. // result, _ := json.Marshal(respJSON)
  2413. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2414. // utils.ErrorLog("解析失败:%v", err)
  2415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2416. // return
  2417. // }
  2418. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2419. // res2.Output = resSix10265.Output
  2420. // res2.ErrMsg = resSix10265.ErrMsg
  2421. // res2.Cainfo = resSix10265.Cainfo
  2422. // res2.WarnMsg = resSix10265.WarnMsg
  2423. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2424. // res2.Infcode = infocode
  2425. //
  2426. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2427. // data := make(map[string]interface{})
  2428. // data["struct_3501s"] = struct3501
  2429. // client := &http.Client{}
  2430. // bytesData, _ := json.Marshal(data)
  2431. // var req *http.Request
  2432. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2433. // resp, _ := client.Do(req)
  2434. // defer resp.Body.Close()
  2435. // body, ioErr := ioutil.ReadAll(resp.Body)
  2436. // if ioErr != nil {
  2437. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2438. // }
  2439. // var respJSON map[string]interface{}
  2440. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2441. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2442. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2443. // return
  2444. // }
  2445. // var resSix10265 ResultSix10265 //1101结果
  2446. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2447. // result, _ := json.Marshal(respJSON)
  2448. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2449. // utils.ErrorLog("解析失败:%v", err)
  2450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2451. // return
  2452. // }
  2453. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2454. // res2.Output = resSix10265.Output
  2455. // res2.ErrMsg = resSix10265.ErrMsg
  2456. // res2.Cainfo = resSix10265.Cainfo
  2457. // res2.WarnMsg = resSix10265.WarnMsg
  2458. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2459. // res2.Infcode = infocode
  2460. //
  2461. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2462. // data := make(map[string]interface{})
  2463. // data["struct_3501s"] = struct3501
  2464. // client := &http.Client{}
  2465. // bytesData, _ := json.Marshal(data)
  2466. // var req *http.Request
  2467. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2468. // resp, _ := client.Do(req)
  2469. // defer resp.Body.Close()
  2470. // body, ioErr := ioutil.ReadAll(resp.Body)
  2471. // if ioErr != nil {
  2472. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2473. // }
  2474. // var respJSON map[string]interface{}
  2475. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2476. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2478. // return
  2479. // }
  2480. // var resSix10265 ResultSix10265 //1101结果
  2481. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2482. // result, _ := json.Marshal(respJSON)
  2483. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2484. // utils.ErrorLog("解析失败:%v", err)
  2485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2486. // return
  2487. // }
  2488. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2489. // res2.Output = resSix10265.Output
  2490. // res2.ErrMsg = resSix10265.ErrMsg
  2491. // res2.Cainfo = resSix10265.Cainfo
  2492. // res2.WarnMsg = resSix10265.WarnMsg
  2493. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2494. // res2.Infcode = infocode
  2495. //
  2496. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2497. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2498. // saveLog(result1, result2, "3501", "3501")
  2499. // //saveLog(result, requestLog, "2201", "挂号")
  2500. //
  2501. // var respJSON2 map[string]interface{}
  2502. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2503. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2504. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2505. // return
  2506. // }
  2507. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2508. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2509. // utils.ErrorLog("解析失败:%v", err)
  2510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2511. // return
  2512. // }
  2513. //
  2514. // }
  2515. //
  2516. // if res2.Infcode != -1 {
  2517. // drug.IsPc = 1
  2518. // drug.Bchno = number
  2519. // drug.PcDate = time.Now().Unix()
  2520. // err := service.SaveW(drug)
  2521. // if err == nil {
  2522. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2523. // var struct3502 models.Struct3502
  2524. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2525. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2526. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2527. // struct3502.FixmedinsCode = miConfig.Code
  2528. // struct3502.Code = miConfig.Code
  2529. //
  2530. // struct3502.RxFlag = "0"
  2531. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2532. // struct3502.OrgName = miConfig.OrgName
  2533. // struct3502.Opter = roles.UserName
  2534. // struct3502.AccessKey = miConfig.AccessKey
  2535. // struct3502.RequestUrl = miConfig.Url
  2536. // struct3502.SecretKey = miConfig.SecretKey
  2537. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2538. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2539. // struct3502.Url = miConfig.Url
  2540. // struct3502.AppId = miConfig.Cainfo
  2541. // struct3502.AppSecret = miConfig.AppSecret
  2542. // struct3502.Enckey = miConfig.EncKey
  2543. // struct3502.SignKey = miConfig.SignKey
  2544. // struct3502.SecretKey = miConfig.SecretKey
  2545. // struct3502.DrugTracCodg = drug.DrugCode
  2546. //
  2547. // struct3502.Memo = ""
  2548. // struct3502.InvChgType = "108"
  2549. // struct3502.FixmedinsBchno = bg_number
  2550. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2551. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2552. //
  2553. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2554. // result11, result22, _ := service.FJyb3502(struct3502)
  2555. // saveLog(result11, result22, "3502", "3502")
  2556. //
  2557. // var respJSON3 map[string]interface{}
  2558. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2559. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2560. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2561. // return
  2562. // }
  2563. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2564. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2565. // utils.ErrorLog("解析失败:%v", err)
  2566. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2567. // return
  2568. // }
  2569. //
  2570. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2571. // data := make(map[string]interface{})
  2572. // data["struct_3502s"] = struct3502
  2573. // client := &http.Client{}
  2574. // bytesData, _ := json.Marshal(data)
  2575. // var req *http.Request
  2576. // if miConfig.MdtrtareaAdmvs == "320921" {
  2577. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2578. // } else {
  2579. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2580. // }
  2581. //
  2582. // resp, _ := client.Do(req)
  2583. // defer resp.Body.Close()
  2584. // body, ioErr := ioutil.ReadAll(resp.Body)
  2585. // if ioErr != nil {
  2586. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2587. // }
  2588. // var respJSON map[string]interface{}
  2589. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2590. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2592. // return
  2593. // }
  2594. // var resSix10265 ResultSix10265 //1101结果
  2595. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2596. // result, _ := json.Marshal(respJSON)
  2597. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2598. // utils.ErrorLog("解析失败:%v", err)
  2599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2600. // return
  2601. // }
  2602. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2603. // res3.Output = resSix10265.Output
  2604. // res3.ErrMsg = resSix10265.ErrMsg
  2605. // res3.Cainfo = resSix10265.Cainfo
  2606. // res3.WarnMsg = resSix10265.WarnMsg
  2607. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2608. // res3.Infcode = infocode
  2609. //
  2610. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2611. //
  2612. // data := make(map[string]interface{})
  2613. // data["struct_3502s"] = struct3502
  2614. // client := &http.Client{}
  2615. // bytesData, _ := json.Marshal(data)
  2616. // var req *http.Request
  2617. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2618. // resp, _ := client.Do(req)
  2619. // defer resp.Body.Close()
  2620. // body, ioErr := ioutil.ReadAll(resp.Body)
  2621. // if ioErr != nil {
  2622. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2623. // }
  2624. // var respJSON map[string]interface{}
  2625. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2626. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2627. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. // return
  2629. // }
  2630. // var resSix10265 ResultSix10265 //1101结果
  2631. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2632. // result, _ := json.Marshal(respJSON)
  2633. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2634. // utils.ErrorLog("解析失败:%v", err)
  2635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2636. // return
  2637. // }
  2638. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2639. // res3.Output = resSix10265.Output
  2640. // res3.ErrMsg = resSix10265.ErrMsg
  2641. // res3.Cainfo = resSix10265.Cainfo
  2642. // res3.WarnMsg = resSix10265.WarnMsg
  2643. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2644. // res3.Infcode = infocode
  2645. //
  2646. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2647. //
  2648. // data := make(map[string]interface{})
  2649. // data["struct_3501s"] = struct3501
  2650. // client := &http.Client{}
  2651. // bytesData, _ := json.Marshal(data)
  2652. // var req *http.Request
  2653. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2654. // resp, _ := client.Do(req)
  2655. // defer resp.Body.Close()
  2656. // body, ioErr := ioutil.ReadAll(resp.Body)
  2657. // if ioErr != nil {
  2658. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2659. // }
  2660. // var respJSON map[string]interface{}
  2661. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2662. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2663. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2664. // return
  2665. // }
  2666. // var resSix10265 ResultSix10265 //1101结果
  2667. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2668. // result, _ := json.Marshal(respJSON)
  2669. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2670. // utils.ErrorLog("解析失败:%v", err)
  2671. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2672. // return
  2673. // }
  2674. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2675. // res2.Output = resSix10265.Output
  2676. // res2.ErrMsg = resSix10265.ErrMsg
  2677. // res2.Cainfo = resSix10265.Cainfo
  2678. // res2.WarnMsg = resSix10265.WarnMsg
  2679. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2680. // res2.Infcode = infocode
  2681. //
  2682. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2683. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2684. // saveLog(result11, result22, "3502", "3502")
  2685. //
  2686. // var respJSON3 map[string]interface{}
  2687. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2688. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2690. // return
  2691. // }
  2692. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2693. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2694. // utils.ErrorLog("解析失败:%v", err)
  2695. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2696. // return
  2697. // }
  2698. // }
  2699. // if res3.Infcode == -1 {
  2700. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2701. // c.ServeSuccessJSON(map[string]interface{}{
  2702. // "failed_code": -10,
  2703. // "msg": res3.ErrMsg,
  2704. // })
  2705. // } else {
  2706. // drug.IsBg = 1
  2707. // drug.BgBchno = bg_number
  2708. // service.SaveW(drug)
  2709. // }
  2710. // }
  2711. // } else {
  2712. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2713. // }
  2714. // }
  2715. // //变更
  2716. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2717. // var res3 ResultSix
  2718. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2719. //
  2720. // var struct3502 models.Struct3502
  2721. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2722. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2723. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2724. // struct3502.FixmedinsCode = miConfig.Code
  2725. // struct3502.Code = miConfig.Code
  2726. //
  2727. // struct3502.Opter = roles.UserName
  2728. // struct3502.RxFlag = "0"
  2729. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2730. // struct3502.OrgName = miConfig.OrgName
  2731. // struct3502.AccessKey = miConfig.AccessKey
  2732. // struct3502.RequestUrl = miConfig.Url
  2733. // struct3502.SecretKey = miConfig.SecretKey
  2734. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2735. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2736. // struct3502.InvChgType = "108"
  2737. // struct3502.DrugTracCodg = drug.DrugCode
  2738. //
  2739. // struct3502.Url = miConfig.Url
  2740. // struct3502.AppId = miConfig.Cainfo
  2741. // struct3502.AppSecret = miConfig.AppSecret
  2742. // struct3502.Enckey = miConfig.EncKey
  2743. // struct3502.SignKey = miConfig.SignKey
  2744. // struct3502.SecretKey = miConfig.SecretKey
  2745. //
  2746. // struct3502.FixmedinsBchno = bg_number
  2747. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2748. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2749. //
  2750. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2751. // result1, result2, _ := service.FJyb3502(struct3502)
  2752. // saveLog(result1, result2, "3502", "3502")
  2753. // var respJSON3 map[string]interface{}
  2754. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2755. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2756. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2757. // return
  2758. // }
  2759. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2760. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2761. // utils.ErrorLog("解析失败:%v", err)
  2762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2763. // return
  2764. // }
  2765. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2766. // data := make(map[string]interface{})
  2767. // data["struct_3502s"] = struct3502
  2768. // client := &http.Client{}
  2769. // bytesData, _ := json.Marshal(data)
  2770. // var req *http.Request
  2771. // if miConfig.MdtrtareaAdmvs == "320921" {
  2772. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2773. // } else {
  2774. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2775. // }
  2776. // resp, _ := client.Do(req)
  2777. // defer resp.Body.Close()
  2778. // body, ioErr := ioutil.ReadAll(resp.Body)
  2779. // if ioErr != nil {
  2780. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2781. // }
  2782. // var respJSON map[string]interface{}
  2783. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2784. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2786. // return
  2787. // }
  2788. // var resSix10265 ResultSix10265 //1101结果
  2789. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2790. // result, _ := json.Marshal(respJSON)
  2791. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2792. // utils.ErrorLog("解析失败:%v", err)
  2793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2794. // return
  2795. // }
  2796. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2797. // res3.Output = resSix10265.Output
  2798. // res3.ErrMsg = resSix10265.ErrMsg
  2799. // res3.Cainfo = resSix10265.Cainfo
  2800. // res3.WarnMsg = resSix10265.WarnMsg
  2801. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2802. // res3.Infcode = infocode
  2803. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2804. //
  2805. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2806. //
  2807. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2808. //
  2809. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2810. //
  2811. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2812. // saveLog(result1, result2, "3501", "3501")
  2813. // //saveLog(result, requestLog, "2201", "挂号")
  2814. //
  2815. // var respJSON2 map[string]interface{}
  2816. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2817. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2819. // return
  2820. // }
  2821. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2822. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2823. // utils.ErrorLog("解析失败:%v", err)
  2824. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2825. // return
  2826. // }
  2827. //
  2828. // }
  2829. // if res3.Infcode == -1 {
  2830. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2831. // } else {
  2832. // drug.IsBg = 1
  2833. // drug.BgBchno = bg_number
  2834. // service.SaveW(drug)
  2835. // }
  2836. // }
  2837. // }
  2838. //
  2839. // if len(errs) == 0 {
  2840. // c.ServeSuccessJSON(map[string]interface{}{
  2841. // "msg": "盘存变更成功",
  2842. // })
  2843. // } else {
  2844. // c.ServeSuccessJSON(map[string]interface{}{
  2845. // "failed_code": -10,
  2846. // "msg": errs,
  2847. // })
  2848. // }
  2849. //}
  2850. func (c *HisApiController) DeleteXSandBGTwo() {
  2851. patient_id, _ := c.GetInt64("patient_id")
  2852. admin_user_id, _ := c.GetInt64("admin_user_id")
  2853. times := c.GetString("time", "")
  2854. timeLayout := "2006-01-02"
  2855. loc, _ := time.LoadLocation("Local")
  2856. var stime, etime int64
  2857. if times == "" {
  2858. stime, etime = GetNowTime()
  2859. } else {
  2860. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2861. stime = stmp.Unix()
  2862. etime = stime + 86399
  2863. }
  2864. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2865. var flows []*models.DrugFlow
  2866. for _, item := range advicelist {
  2867. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2868. flows = append(flows, flow...)
  2869. }
  2870. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2871. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2872. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2873. var err []string
  2874. for _, item := range flows {
  2875. if item.IsSale == 1 {
  2876. var res FJ3507Result
  2877. var struct3507 models.Struct3507
  2878. struct3507.FixmedinsBchno = item.Bchno
  2879. struct3507.InvDataType = "4"
  2880. struct3507.Opter = roles.UserName
  2881. struct3507.OrgName = miConfig.OrgName
  2882. struct3507.AccessKey = miConfig.AccessKey
  2883. struct3507.RequestUrl = miConfig.Url
  2884. struct3507.FixmedinsCode = miConfig.Code
  2885. struct3507.SecretKey = miConfig.SecretKey
  2886. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2887. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2888. struct3507.Url = miConfig.Url
  2889. struct3507.AppId = miConfig.Cainfo
  2890. struct3507.AppSecret = miConfig.AppSecret
  2891. struct3507.Enckey = miConfig.EncKey
  2892. struct3507.SignKey = miConfig.SignKey
  2893. struct3507.SecretKey = miConfig.SecretKey
  2894. if miConfig.MdtrtareaAdmvs == "350500" {
  2895. result, result1, _ := service.FJyb3507(struct3507)
  2896. saveLog(result, result1, "3507", "3507")
  2897. var respJSON2 map[string]interface{}
  2898. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2901. return
  2902. }
  2903. userJSONBytes2, _ := json.Marshal(respJSON2)
  2904. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2905. utils.ErrorLog("解析失败:%v", err)
  2906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2907. return
  2908. }
  2909. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  2910. data := make(map[string]interface{})
  2911. data["struct_3507s"] = struct3507
  2912. client := &http.Client{}
  2913. bytesData, _ := json.Marshal(data)
  2914. var req *http.Request
  2915. if miConfig.MdtrtareaAdmvs == "320830" {
  2916. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2917. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2918. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2919. } else {
  2920. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2921. }
  2922. resp, _ := client.Do(req)
  2923. defer resp.Body.Close()
  2924. body, ioErr := ioutil.ReadAll(resp.Body)
  2925. if ioErr != nil {
  2926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2927. }
  2928. var respJSON map[string]interface{}
  2929. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2932. return
  2933. }
  2934. var resSix10265 ResultSix10265 //1101结果
  2935. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2936. result, _ := json.Marshal(respJSON)
  2937. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2938. utils.ErrorLog("解析失败:%v", err)
  2939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2940. return
  2941. }
  2942. res.InfRefmsgid = resSix10265.InfRefmsgid
  2943. //res.Output = resSix10265.Output
  2944. res.ErrMsg = resSix10265.ErrMsg
  2945. res.Cainfo = resSix10265.Cainfo
  2946. res.WarnMsg = resSix10265.WarnMsg
  2947. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2948. res.Infcode = infocode
  2949. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2950. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2951. saveLog(result2, result1, "3507", "3507")
  2952. var respJSON2 map[string]interface{}
  2953. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2956. return
  2957. }
  2958. userJSONBytes2, _ := json.Marshal(respJSON2)
  2959. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2960. utils.ErrorLog("解析失败:%v", err)
  2961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2962. return
  2963. }
  2964. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2965. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2966. saveLog(result2, result1, "3507", "3507")
  2967. var respJSON2 map[string]interface{}
  2968. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2971. return
  2972. }
  2973. userJSONBytes2, _ := json.Marshal(respJSON2)
  2974. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2975. utils.ErrorLog("解析失败:%v", err)
  2976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2977. return
  2978. }
  2979. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2980. result1, result2 := service.Jxyb3507(struct3507)
  2981. saveLog(result2, result1, "3507", "3507")
  2982. var respJSON2 map[string]interface{}
  2983. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2986. return
  2987. }
  2988. userJSONBytes2, _ := json.Marshal(respJSON2)
  2989. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2990. utils.ErrorLog("解析失败:%v", err)
  2991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2992. return
  2993. }
  2994. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2995. result1, result2 := service.AHyb3507(struct3507)
  2996. saveLog(result2, result1, "3507", "3507")
  2997. var respJSON2 map[string]interface{}
  2998. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3001. return
  3002. }
  3003. userJSONBytes2, _ := json.Marshal(respJSON2)
  3004. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3005. utils.ErrorLog("解析失败:%v", err)
  3006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3007. return
  3008. }
  3009. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3010. data := make(map[string]interface{})
  3011. data["struct_3507s"] = struct3507
  3012. client := &http.Client{}
  3013. bytesData, _ := json.Marshal(data)
  3014. var req *http.Request
  3015. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3016. resp, _ := client.Do(req)
  3017. defer resp.Body.Close()
  3018. body, ioErr := ioutil.ReadAll(resp.Body)
  3019. if ioErr != nil {
  3020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3021. }
  3022. var respJSON map[string]interface{}
  3023. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3025. }
  3026. var resSix10265 ResultSix10265 //1101结果
  3027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3028. result, _ := json.Marshal(respJSON)
  3029. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3030. utils.ErrorLog("解析失败:%v", err)
  3031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3032. return
  3033. }
  3034. res.InfRefmsgid = resSix10265.InfRefmsgid
  3035. res.ErrMsg = resSix10265.ErrMsg
  3036. res.Cainfo = resSix10265.Cainfo
  3037. res.WarnMsg = resSix10265.WarnMsg
  3038. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3039. res.Infcode = infocode
  3040. }
  3041. if res.Infcode == 0 {
  3042. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3043. item.IsSale = 0
  3044. item.SaleDate = ""
  3045. item.Bchno = ""
  3046. service.SaveDF(item)
  3047. } else {
  3048. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3049. }
  3050. }
  3051. }
  3052. c.ServeSuccessJSON(map[string]interface{}{
  3053. "msg": "删除销售数据成功",
  3054. })
  3055. }
  3056. // 删除
  3057. func (c *HisApiController) DeleteXSandBGThree() {
  3058. id, _ := c.GetInt64("id")
  3059. admin_user_id, _ := c.GetInt64("admin_user_id")
  3060. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3061. var flows []*models.DrugFlow
  3062. for _, item := range advicelist {
  3063. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3064. flows = append(flows, flow...)
  3065. }
  3066. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3067. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3068. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3069. var err []string
  3070. for _, item := range flows {
  3071. if item.IsSale == 1 {
  3072. var res FJ3507Result
  3073. var struct3507 models.Struct3507
  3074. struct3507.FixmedinsBchno = item.Bchno
  3075. struct3507.InvDataType = "4"
  3076. struct3507.Opter = roles.UserName
  3077. struct3507.OrgName = miConfig.OrgName
  3078. struct3507.AccessKey = miConfig.AccessKey
  3079. struct3507.RequestUrl = miConfig.Url
  3080. struct3507.FixmedinsCode = miConfig.Code
  3081. struct3507.SecretKey = miConfig.SecretKey
  3082. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3083. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3084. struct3507.Url = miConfig.Url
  3085. struct3507.AppId = miConfig.Cainfo
  3086. struct3507.AppSecret = miConfig.AppSecret
  3087. struct3507.Enckey = miConfig.EncKey
  3088. struct3507.SignKey = miConfig.SignKey
  3089. struct3507.SecretKey = miConfig.SecretKey
  3090. if miConfig.MdtrtareaAdmvs == "350500" {
  3091. result, result1, _ := service.FJyb3507(struct3507)
  3092. saveLog(result, result1, "3507", "3507")
  3093. var respJSON2 map[string]interface{}
  3094. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3097. return
  3098. }
  3099. userJSONBytes2, _ := json.Marshal(respJSON2)
  3100. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3101. utils.ErrorLog("解析失败:%v", err)
  3102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3103. return
  3104. }
  3105. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  3106. data := make(map[string]interface{})
  3107. data["struct_3507s"] = struct3507
  3108. client := &http.Client{}
  3109. bytesData, _ := json.Marshal(data)
  3110. var req *http.Request
  3111. if miConfig.MdtrtareaAdmvs == "320830" {
  3112. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  3113. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3114. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3115. } else {
  3116. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3117. }
  3118. resp, _ := client.Do(req)
  3119. defer resp.Body.Close()
  3120. body, ioErr := ioutil.ReadAll(resp.Body)
  3121. if ioErr != nil {
  3122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3123. }
  3124. var respJSON map[string]interface{}
  3125. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3128. return
  3129. }
  3130. var resSix10265 ResultSix10265 //1101结果
  3131. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3132. result, _ := json.Marshal(respJSON)
  3133. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3134. utils.ErrorLog("解析失败:%v", err)
  3135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3136. return
  3137. }
  3138. res.InfRefmsgid = resSix10265.InfRefmsgid
  3139. //res.Output = resSix10265.Output
  3140. res.ErrMsg = resSix10265.ErrMsg
  3141. res.Cainfo = resSix10265.Cainfo
  3142. res.WarnMsg = resSix10265.WarnMsg
  3143. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3144. res.Infcode = infocode
  3145. } else if miConfig.MdtrtareaAdmvs == "440100" {
  3146. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3147. saveLog(result2, result1, "3507", "3507")
  3148. var respJSON2 map[string]interface{}
  3149. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3152. return
  3153. }
  3154. userJSONBytes2, _ := json.Marshal(respJSON2)
  3155. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3156. utils.ErrorLog("解析失败:%v", err)
  3157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3158. return
  3159. }
  3160. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3161. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3162. saveLog(result2, result1, "3507", "3507")
  3163. var respJSON2 map[string]interface{}
  3164. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3167. return
  3168. }
  3169. userJSONBytes2, _ := json.Marshal(respJSON2)
  3170. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3171. utils.ErrorLog("解析失败:%v", err)
  3172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3173. return
  3174. }
  3175. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3176. result1, result2 := service.Jxyb3507(struct3507)
  3177. saveLog(result2, result1, "3507", "3507")
  3178. var respJSON2 map[string]interface{}
  3179. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3182. return
  3183. }
  3184. userJSONBytes2, _ := json.Marshal(respJSON2)
  3185. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3186. utils.ErrorLog("解析失败:%v", err)
  3187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3188. return
  3189. }
  3190. } else if miConfig.MdtrtareaAdmvs == "340699" {
  3191. result1, result2 := service.AHyb3507(struct3507)
  3192. saveLog(result2, result1, "3507", "3507")
  3193. var respJSON2 map[string]interface{}
  3194. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3197. return
  3198. }
  3199. userJSONBytes2, _ := json.Marshal(respJSON2)
  3200. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3201. utils.ErrorLog("解析失败:%v", err)
  3202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3203. return
  3204. }
  3205. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3206. data := make(map[string]interface{})
  3207. data["struct_3507s"] = struct3507
  3208. client := &http.Client{}
  3209. bytesData, _ := json.Marshal(data)
  3210. var req *http.Request
  3211. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3212. resp, _ := client.Do(req)
  3213. defer resp.Body.Close()
  3214. body, ioErr := ioutil.ReadAll(resp.Body)
  3215. if ioErr != nil {
  3216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3217. }
  3218. var respJSON map[string]interface{}
  3219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3221. }
  3222. var resSix10265 ResultSix10265 //1101结果
  3223. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3224. result, _ := json.Marshal(respJSON)
  3225. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3226. utils.ErrorLog("解析失败:%v", err)
  3227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3228. return
  3229. }
  3230. res.InfRefmsgid = resSix10265.InfRefmsgid
  3231. res.ErrMsg = resSix10265.ErrMsg
  3232. res.Cainfo = resSix10265.Cainfo
  3233. res.WarnMsg = resSix10265.WarnMsg
  3234. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3235. res.Infcode = infocode
  3236. }
  3237. if res.Infcode == 0 {
  3238. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3239. item.IsSale = 0
  3240. item.SaleDate = ""
  3241. item.Bchno = ""
  3242. service.SaveDF(item)
  3243. } else {
  3244. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3245. }
  3246. }
  3247. }
  3248. c.ServeSuccessJSON(map[string]interface{}{
  3249. "msg": "删除销售数据成功",
  3250. })
  3251. }
  3252. // 获取当天起止时间戳
  3253. func GetNowTime() (int64, int64) {
  3254. t := time.Now()
  3255. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3256. timesamp := addTime.Unix()
  3257. return timesamp, timesamp + 86399
  3258. }
  3259. func (c *HisApiController) ChangeDrugfour() {
  3260. patient_id, _ := c.GetInt64("patient_id")
  3261. admin_user_id, _ := c.GetInt64("admin_user_id")
  3262. times := c.GetString("time", "")
  3263. timeLayout := "2006-01-02"
  3264. loc, _ := time.LoadLocation("Local")
  3265. var stime, etime int64
  3266. if times == "" {
  3267. stime, etime = GetNowTime()
  3268. } else {
  3269. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3270. stime = stmp.Unix()
  3271. etime = stime + 86399
  3272. }
  3273. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3274. var flows []*models.DrugFlow
  3275. for _, item := range advicelist {
  3276. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  3277. flows = append(flows, flow...)
  3278. }
  3279. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3280. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3281. var err []string
  3282. for _, item := range flows {
  3283. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3284. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3285. if prescription.OrderStatus == 2 {
  3286. if item.IsSale == 0 {
  3287. var res FJ3507Result
  3288. var res3507for10188 FJ3507ResultFor10188
  3289. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3290. //进行商品销售接口
  3291. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3292. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3293. var respJSON3 map[string]interface{}
  3294. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3297. return
  3298. }
  3299. userJSONBytes3, _ := json.Marshal(respJSON3)
  3300. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3301. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3302. utils.ErrorLog("解析失败:%v", err)
  3303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3304. return
  3305. }
  3306. //if res3507for10188.Infcode
  3307. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3308. //res.Output = resSix10265.Output
  3309. res.ErrMsg = res3507for10188.ErrMsg
  3310. res.Cainfo = res3507for10188.Cainfo
  3311. res.WarnMsg = res3507for10188.WarnMsg
  3312. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3313. res.Infcode = infocode
  3314. } else {
  3315. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3316. utils.ErrorLog("解析失败:%v", err)
  3317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3318. return
  3319. }
  3320. }
  3321. if res.Infcode == 0 {
  3322. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3323. item.IsSale = 1
  3324. item.Bchno = number
  3325. item.SaleDate = time.Now().Format("2006-01-02")
  3326. service.SaveDF(item)
  3327. } else {
  3328. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3329. }
  3330. }
  3331. } else { //还没结,提示用户去结算,并药品追溯上传
  3332. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3333. }
  3334. }
  3335. }
  3336. str := strings.Join(err, " ")
  3337. saveLog(str, str, "3505", "3505自动上传日志")
  3338. c.ServeSuccessJSON(map[string]interface{}{
  3339. "status": "1",
  3340. "msg": err,
  3341. })
  3342. }
  3343. func (c *HisApiController) ChangeDrugFive() {
  3344. id := c.GetString("id")
  3345. ids := strings.Split(id, ",")
  3346. admin_user_id, _ := c.GetInt64("admin_user_id")
  3347. var err []string
  3348. for _, value := range ids {
  3349. intValue, _ := strconv.ParseInt(value, 10, 64)
  3350. //file := strconv.FormatInt(int64(num), 10)
  3351. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3352. var flows []*models.DrugFlow
  3353. for _, item := range advicelist {
  3354. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3355. flows = append(flows, flow...)
  3356. }
  3357. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3358. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3359. for _, item := range flows {
  3360. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3361. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3362. if prescription.OrderStatus == 2 {
  3363. if item.IsSale == 0 {
  3364. var res FJ3507Result
  3365. var res3507for10188 FJ3507ResultFor10188
  3366. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3367. //进行商品销售接口
  3368. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3369. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3370. var respJSON3 map[string]interface{}
  3371. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3374. return
  3375. }
  3376. userJSONBytes3, _ := json.Marshal(respJSON3)
  3377. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3378. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3379. utils.ErrorLog("解析失败:%v", err)
  3380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3381. return
  3382. }
  3383. //if res3507for10188.Infcode
  3384. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3385. //res.Output = resSix10265.Output
  3386. res.ErrMsg = res3507for10188.ErrMsg
  3387. res.Cainfo = res3507for10188.Cainfo
  3388. res.WarnMsg = res3507for10188.WarnMsg
  3389. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3390. res.Infcode = infocode
  3391. } else {
  3392. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3393. utils.ErrorLog("解析失败:%v", err)
  3394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3395. return
  3396. }
  3397. }
  3398. if res.Infcode == 0 {
  3399. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3400. item.IsSale = 1
  3401. item.Bchno = number
  3402. item.SaleDate = time.Now().Format("2006-01-02")
  3403. service.SaveDF(item)
  3404. } else {
  3405. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3406. }
  3407. }
  3408. } else { //还没结,提示用户去结算,并药品追溯上传
  3409. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3410. }
  3411. }
  3412. }
  3413. str := strings.Join(err, " ")
  3414. saveLog(str, str, "3505", "3505自动上传日志")
  3415. }
  3416. c.ServeSuccessJSON(map[string]interface{}{
  3417. "status": "1",
  3418. "msg": err,
  3419. })
  3420. }
  3421. //func (c *HisApiController) ChangeDrugfour() {
  3422. // patient_id, _ := c.GetInt64("patient_id")
  3423. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3424. // //id_arr := strings.Split(ids, ",")
  3425. // times := c.GetString("time", "")
  3426. // timeLayout := "2006-01-02"
  3427. // loc, _ := time.LoadLocation("Local")
  3428. // var stime, etime int64
  3429. // if times == "" {
  3430. // stime, etime = GetNowTime()
  3431. // } else {
  3432. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3433. // stime = stmp.Unix()
  3434. // etime = stime + 86399
  3435. // }
  3436. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3437. // var flows []*models.DrugFlow
  3438. // for _, item := range advicelist {
  3439. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3440. // flows = append(flows, flow...)
  3441. // }
  3442. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3443. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3444. // var err []string
  3445. //
  3446. // for _, item := range flows {
  3447. // var res3 ResultSix
  3448. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3449. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3450. // if prescription.OrderStatus == 2 {
  3451. // //已经结算
  3452. // //判断是否已经销售
  3453. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3454. // //是否已经变更 1是 0否
  3455. // if item.IsChange == 0 { //没变更,进行变更操作
  3456. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3457. //
  3458. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3459. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3460. // var respJSON3 map[string]interface{}
  3461. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3462. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3463. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3464. // return
  3465. // }
  3466. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3467. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3468. // utils.ErrorLog("解析失败:%v", err)
  3469. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3470. // return
  3471. // }
  3472. // if res3.Infcode == 0 {
  3473. // item.IsChange = 1
  3474. // item.BgBchno = bg_number
  3475. // service.SaveDF2(item)
  3476. // } else {
  3477. //
  3478. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3479. // }
  3480. // }
  3481. // } else { //没销售,
  3482. // var res FJ3507Result
  3483. // var res3507for10188 FJ3507ResultFor10188
  3484. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3485. //
  3486. // //进行商品销售接口
  3487. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3488. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3489. // var respJSON3 map[string]interface{}
  3490. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3491. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3493. // return
  3494. // }
  3495. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3496. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3497. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3498. // utils.ErrorLog("解析失败:%v", err)
  3499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3500. // return
  3501. // }
  3502. // //if res3507for10188.Infcode
  3503. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3504. // //res.Output = resSix10265.Output
  3505. // res.ErrMsg = res3507for10188.ErrMsg
  3506. // res.Cainfo = res3507for10188.Cainfo
  3507. // res.WarnMsg = res3507for10188.WarnMsg
  3508. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3509. // res.Infcode = infocode
  3510. // } else {
  3511. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3512. // utils.ErrorLog("解析失败:%v", err)
  3513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3514. // return
  3515. // }
  3516. //
  3517. // }
  3518. // if res.Infcode == 0 {
  3519. // item.IsSale = 1
  3520. // item.Bchno = number
  3521. // item.SaleDate = time.Now().Format("2006-01-02")
  3522. //
  3523. // err5 := service.SaveDF(item)
  3524. // if err5 == nil {
  3525. // if item.IsChange == 0 { //没变更,进行变更操作
  3526. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3527. //
  3528. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3529. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3530. //
  3531. // var respJSON3 map[string]interface{}
  3532. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3533. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3534. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3535. // return
  3536. // }
  3537. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3538. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3539. // utils.ErrorLog("解析失败:%v", err)
  3540. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3541. // return
  3542. // }
  3543. // //if res3507for10188.Infcode
  3544. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3545. // //res.Output = resSix10265.Output
  3546. // res3.ErrMsg = res3507for10188.ErrMsg
  3547. // res3.Cainfo = res3507for10188.Cainfo
  3548. // res3.WarnMsg = res3507for10188.WarnMsg
  3549. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3550. // res3.Infcode = infocode
  3551. // } else {
  3552. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3553. // utils.ErrorLog("解析失败:%v", err)
  3554. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3555. // return
  3556. // }
  3557. // }
  3558. // if res3.Infcode == 0 {
  3559. // item.IsChange = 1
  3560. // item.BgBchno = bg_number
  3561. // service.SaveDF2(item)
  3562. // } else {
  3563. //
  3564. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3565. // }
  3566. // }
  3567. // }
  3568. // } else {
  3569. //
  3570. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3571. // }
  3572. // }
  3573. //
  3574. // } else { //还没结,提示用户去结算,并药品追溯上传
  3575. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3576. // }
  3577. // }
  3578. // }
  3579. // if len(err) == 0 {
  3580. // c.ServeSuccessJSON(map[string]interface{}{
  3581. // "msg": "销售变更成功",
  3582. // })
  3583. // } else {
  3584. // c.ServeSuccessJSON(map[string]interface{}{
  3585. // "failed_code": -10,
  3586. // "msg": err,
  3587. // })
  3588. // }
  3589. //}
  3590. func (c *HisApiController) ChangeDrug() {
  3591. ids := c.GetString("ids")
  3592. id_arr := strings.Split(ids, ",")
  3593. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3594. admin_user_id, _ := c.GetInt64("admin_user_id")
  3595. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3596. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3597. var err []string
  3598. for _, item := range flows {
  3599. var res3 ResultSix
  3600. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3601. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3602. if prescription.OrderStatus == 2 {
  3603. //已经结算
  3604. //判断是否已经销售
  3605. if item.IsSale == 1 { //是否已经销售,1是 0否
  3606. //是否已经变更 1是 0否
  3607. if item.IsChange == 0 { //没变更,进行变更操作
  3608. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  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. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3629. }
  3630. }
  3631. } else { //没销售,
  3632. var res FJ3507Result
  3633. var res3507for10188 FJ3507ResultFor10188
  3634. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3635. //进行商品销售接口
  3636. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3637. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3638. var respJSON3 map[string]interface{}
  3639. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3642. return
  3643. }
  3644. userJSONBytes3, _ := json.Marshal(respJSON3)
  3645. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3646. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3647. utils.ErrorLog("解析失败:%v", err)
  3648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3649. return
  3650. }
  3651. //if res3507for10188.Infcode
  3652. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3653. //res.Output = resSix10265.Output
  3654. res.ErrMsg = res3507for10188.ErrMsg
  3655. res.Cainfo = res3507for10188.Cainfo
  3656. res.WarnMsg = res3507for10188.WarnMsg
  3657. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3658. res.Infcode = infocode
  3659. } else {
  3660. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3661. utils.ErrorLog("解析失败:%v", err)
  3662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3663. return
  3664. }
  3665. }
  3666. if res.Infcode == 0 {
  3667. item.IsSale = 1
  3668. item.Bchno = number
  3669. item.SaleDate = time.Now().Format("2006-01-02")
  3670. err5 := service.SaveDF(item)
  3671. if err5 == nil {
  3672. if item.IsChange == 0 { //没变更,进行变更操作
  3673. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3674. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3675. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3676. var respJSON3 map[string]interface{}
  3677. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3680. return
  3681. }
  3682. userJSONBytes3, _ := json.Marshal(respJSON3)
  3683. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3684. utils.ErrorLog("解析失败:%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. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3715. }
  3716. }
  3717. }
  3718. } else {
  3719. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3720. }
  3721. }
  3722. } else { //还没结算
  3723. var res3507for10188 FJ3507ResultFor10188
  3724. if item.IsChange == 0 { //没变更,进行变更操作
  3725. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3726. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3727. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3728. var respJSON3 map[string]interface{}
  3729. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3732. return
  3733. }
  3734. userJSONBytes3, _ := json.Marshal(respJSON3)
  3735. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3736. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3737. utils.ErrorLog("解析失败:%v", err)
  3738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3739. return
  3740. }
  3741. //if res3507for10188.Infcode
  3742. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3743. //res.Output = resSix10265.Output
  3744. res3.ErrMsg = res3507for10188.ErrMsg
  3745. res3.Cainfo = res3507for10188.Cainfo
  3746. res3.WarnMsg = res3507for10188.WarnMsg
  3747. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3748. res3.Infcode = infocode
  3749. } else {
  3750. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3751. utils.ErrorLog("解析失败:%v", err)
  3752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3753. return
  3754. }
  3755. }
  3756. if res3.Infcode == 0 {
  3757. item.IsChange = 1
  3758. item.BgBchno = bg_number
  3759. service.SaveDF2(item)
  3760. } else {
  3761. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3762. }
  3763. }
  3764. }
  3765. } else if item.ConsumableType == 7 {
  3766. var res3507for10188 FJ3507ResultFor10188
  3767. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3768. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3769. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3770. //判断是否已经销售
  3771. if item.IsSale == 2 { //是否已经销售,1是 0否
  3772. //是否已经变更 1是 0否
  3773. if item.IsChange == 0 { //没变更,进行变更操作
  3774. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3775. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3776. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3777. var respJSON3 map[string]interface{}
  3778. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3781. return
  3782. }
  3783. userJSONBytes3, _ := json.Marshal(respJSON3)
  3784. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3785. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3786. utils.ErrorLog("解析失败:%v", err)
  3787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3788. return
  3789. }
  3790. //if res3507for10188.Infcode
  3791. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3792. //res.Output = resSix10265.Output
  3793. res3.ErrMsg = res3507for10188.ErrMsg
  3794. res3.Cainfo = res3507for10188.Cainfo
  3795. res3.WarnMsg = res3507for10188.WarnMsg
  3796. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3797. res3.Infcode = infocode
  3798. } else {
  3799. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3800. utils.ErrorLog("解析失败:%v", err)
  3801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3802. return
  3803. }
  3804. }
  3805. if res3.Infcode == 0 {
  3806. item.IsChange = 1
  3807. item.BgBchno = bg_number
  3808. service.SaveDF2(item)
  3809. } else {
  3810. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3811. }
  3812. }
  3813. } else { //没销售,
  3814. //进行商品销售退货接口
  3815. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3816. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3817. saveLog(result111, result222, "3506", "销售退货")
  3818. var res7 FJ3507Result
  3819. //进行商品销售接口
  3820. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3821. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3822. var respJSON3 map[string]interface{}
  3823. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3826. return
  3827. }
  3828. userJSONBytes3, _ := json.Marshal(respJSON3)
  3829. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3830. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3831. utils.ErrorLog("解析失败:%v", err)
  3832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3833. return
  3834. }
  3835. //if res3507for10188.Infcode
  3836. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3837. //res.Output = resSix10265.Output
  3838. res7.ErrMsg = res3507for10188.ErrMsg
  3839. res7.Cainfo = res3507for10188.Cainfo
  3840. res7.WarnMsg = res3507for10188.WarnMsg
  3841. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3842. res7.Infcode = infocode
  3843. } else {
  3844. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3845. utils.ErrorLog("解析失败:%v", err)
  3846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3847. return
  3848. }
  3849. }
  3850. if res7.Infcode == 0 {
  3851. item.IsSale = 2
  3852. item.SaleDate = item.SaleDate
  3853. item.Bchno = number
  3854. service.SaveDF(item)
  3855. if item.IsChange == 0 { //没变更,进行变更操作
  3856. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3857. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3858. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3859. var respJSON3 map[string]interface{}
  3860. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3863. return
  3864. }
  3865. userJSONBytes3, _ := json.Marshal(respJSON3)
  3866. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3867. // utils.ErrorLog("解析失败:%v", err)
  3868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3869. // return
  3870. //}
  3871. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3872. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3873. utils.ErrorLog("解析失败:%v", err)
  3874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3875. return
  3876. }
  3877. //if res3507for10188.Infcode
  3878. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3879. //res.Output = resSix10265.Output
  3880. res3.ErrMsg = res3507for10188.ErrMsg
  3881. res3.Cainfo = res3507for10188.Cainfo
  3882. res3.WarnMsg = res3507for10188.WarnMsg
  3883. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3884. res3.Infcode = infocode
  3885. } else {
  3886. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3887. utils.ErrorLog("解析失败:%v", err)
  3888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3889. return
  3890. }
  3891. }
  3892. if res3.Infcode == 0 {
  3893. item.IsChange = 1
  3894. item.BgBchno = bg_number
  3895. service.SaveDF2(item)
  3896. } else {
  3897. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3898. }
  3899. }
  3900. } else {
  3901. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3902. }
  3903. }
  3904. } else { //还没结算
  3905. if item.IsChange == 0 { //没变更,进行变更操作
  3906. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3907. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3908. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3909. var respJSON3 map[string]interface{}
  3910. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3913. return
  3914. }
  3915. userJSONBytes3, _ := json.Marshal(respJSON3)
  3916. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3917. // utils.ErrorLog("解析失败:%v", err)
  3918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3919. // return
  3920. //}
  3921. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3922. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3923. utils.ErrorLog("解析失败:%v", err)
  3924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3925. return
  3926. }
  3927. //if res3507for10188.Infcode
  3928. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3929. //res.Output = resSix10265.Output
  3930. res3.ErrMsg = res3507for10188.ErrMsg
  3931. res3.Cainfo = res3507for10188.Cainfo
  3932. res3.WarnMsg = res3507for10188.WarnMsg
  3933. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3934. res3.Infcode = infocode
  3935. } else {
  3936. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3937. utils.ErrorLog("解析失败:%v", err)
  3938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. return
  3940. }
  3941. }
  3942. if res3.Infcode == 0 {
  3943. item.IsChange = 1
  3944. item.BgBchno = bg_number
  3945. service.SaveDF2(item)
  3946. } else {
  3947. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3948. }
  3949. }
  3950. }
  3951. }
  3952. }
  3953. if len(err) == 0 {
  3954. c.ServeSuccessJSON(map[string]interface{}{
  3955. "msg": "销售变更成功",
  3956. })
  3957. } else {
  3958. c.ServeSuccessJSON(map[string]interface{}{
  3959. "failed_code": -10,
  3960. "msg": err,
  3961. })
  3962. }
  3963. }
  3964. func (c *HisApiController) ChangeDrugtwo() {
  3965. //ids := c.GetString("ids")
  3966. //id_arr := strings.Split(ids, ",")
  3967. flows, _ := service.GetNewDrugFlowInfothree123()
  3968. admin_user_id, _ := c.GetInt64("admin_user_id")
  3969. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3970. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3971. var err []string
  3972. for _, item := range flows {
  3973. var res3 ResultSix
  3974. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3975. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3976. if prescription.OrderStatus == 2 {
  3977. //已经结算
  3978. //判断是否已经销售
  3979. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3980. // //是否已经变更 1是 0否
  3981. // if item.IsChange == 0 { //没变更,进行变更操作
  3982. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3983. //
  3984. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3985. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3986. // var respJSON3 map[string]interface{}
  3987. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3988. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3989. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3990. // return
  3991. // }
  3992. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3993. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3994. // utils.ErrorLog("解析失败:%v", err)
  3995. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3996. // return
  3997. // }
  3998. // if res3.Infcode == 0 {
  3999. // item.IsChange = 1
  4000. // item.BgBchno = bg_number
  4001. // service.SaveDF2(item)
  4002. // } else {
  4003. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4004. // }
  4005. // }
  4006. //}
  4007. //else
  4008. { //没销售,
  4009. var res FJ3507Result
  4010. var res3507for10188 FJ3507ResultFor10188
  4011. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4012. //进行商品销售接口
  4013. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4014. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4015. var respJSON3 map[string]interface{}
  4016. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4019. return
  4020. }
  4021. userJSONBytes3, _ := json.Marshal(respJSON3)
  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. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4030. //res.Output = resSix10265.Output
  4031. res.ErrMsg = res3507for10188.ErrMsg
  4032. res.Cainfo = res3507for10188.Cainfo
  4033. res.WarnMsg = res3507for10188.WarnMsg
  4034. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4035. res.Infcode = infocode
  4036. } else {
  4037. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4038. utils.ErrorLog("解析失败:%v", err)
  4039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4040. return
  4041. }
  4042. }
  4043. if res.Infcode == 0 {
  4044. item.IsSale = 1
  4045. item.Bchno = number
  4046. item.SaleDate = time.Now().Format("2006-01-02")
  4047. service.SaveDF(item)
  4048. //if err5 == nil {
  4049. // if item.IsChange == 0 { //没变更,进行变更操作
  4050. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4051. //
  4052. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4053. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4054. //
  4055. // var respJSON3 map[string]interface{}
  4056. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4057. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4059. // return
  4060. // }
  4061. //
  4062. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4063. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4064. // utils.ErrorLog("解析失败:%v", err)
  4065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4066. // return
  4067. // }
  4068. // //if res3507for10188.Infcode
  4069. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4070. // //res.Output = resSix10265.Output
  4071. // res3.ErrMsg = res3507for10188.ErrMsg
  4072. // res3.Cainfo = res3507for10188.Cainfo
  4073. // res3.WarnMsg = res3507for10188.WarnMsg
  4074. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4075. // res3.Infcode = infocode
  4076. // } else {
  4077. //
  4078. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4079. // utils.ErrorLog("解析失败:%v", err)
  4080. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4081. // return
  4082. // }
  4083. //
  4084. // }
  4085. //
  4086. // if res3.Infcode == 0 {
  4087. // item.IsChange = 1
  4088. // item.BgBchno = bg_number
  4089. // service.SaveDF2(item)
  4090. // } else {
  4091. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4092. // }
  4093. // }
  4094. //}
  4095. } else {
  4096. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4097. }
  4098. }
  4099. } else { //还没结算
  4100. var res3507for10188 FJ3507ResultFor10188
  4101. if item.IsChange == 0 { //没变更,进行变更操作
  4102. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4103. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4104. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4105. var respJSON3 map[string]interface{}
  4106. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4109. return
  4110. }
  4111. userJSONBytes3, _ := json.Marshal(respJSON3)
  4112. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4113. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4114. utils.ErrorLog("解析失败:%v", err)
  4115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4116. return
  4117. }
  4118. //if res3507for10188.Infcode
  4119. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4120. //res.Output = resSix10265.Output
  4121. res3.ErrMsg = res3507for10188.ErrMsg
  4122. res3.Cainfo = res3507for10188.Cainfo
  4123. res3.WarnMsg = res3507for10188.WarnMsg
  4124. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4125. res3.Infcode = infocode
  4126. } else {
  4127. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4128. utils.ErrorLog("解析失败:%v", err)
  4129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4130. return
  4131. }
  4132. }
  4133. if res3.Infcode == 0 {
  4134. item.IsChange = 1
  4135. item.BgBchno = bg_number
  4136. service.SaveDF2(item)
  4137. } else {
  4138. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4139. }
  4140. }
  4141. }
  4142. }
  4143. //if item.ConsumableType == 7 {
  4144. // var res3507for10188 FJ3507ResultFor10188
  4145. //
  4146. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4147. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4148. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4149. // //判断是否已经销售
  4150. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4151. // //是否已经变更 1是 0否
  4152. // if item.IsChange == 0 { //没变更,进行变更操作
  4153. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4154. //
  4155. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4156. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4157. //
  4158. // var respJSON3 map[string]interface{}
  4159. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4160. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4161. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4162. // return
  4163. // }
  4164. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4165. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4166. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4167. // utils.ErrorLog("解析失败:%v", err)
  4168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4169. // return
  4170. // }
  4171. // //if res3507for10188.Infcode
  4172. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4173. // //res.Output = resSix10265.Output
  4174. // res3.ErrMsg = res3507for10188.ErrMsg
  4175. // res3.Cainfo = res3507for10188.Cainfo
  4176. // res3.WarnMsg = res3507for10188.WarnMsg
  4177. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4178. // res3.Infcode = infocode
  4179. // } else {
  4180. //
  4181. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4182. // utils.ErrorLog("解析失败:%v", err)
  4183. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4184. // return
  4185. // }
  4186. //
  4187. // }
  4188. // if res3.Infcode == 0 {
  4189. // item.IsChange = 1
  4190. // item.BgBchno = bg_number
  4191. // service.SaveDF2(item)
  4192. // } else {
  4193. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4194. // }
  4195. // }
  4196. // } else { //没销售,
  4197. // //进行商品销售退货接口
  4198. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4199. //
  4200. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4201. // saveLog(result111, result222, "3506", "销售退货")
  4202. // var res7 FJ3507Result
  4203. //
  4204. // //进行商品销售接口
  4205. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4206. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4207. // var respJSON3 map[string]interface{}
  4208. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4209. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4210. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4211. // return
  4212. // }
  4213. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4214. //
  4215. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4216. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4217. // utils.ErrorLog("解析失败:%v", err)
  4218. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4219. // return
  4220. // }
  4221. // //if res3507for10188.Infcode
  4222. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4223. // //res.Output = resSix10265.Output
  4224. // res7.ErrMsg = res3507for10188.ErrMsg
  4225. // res7.Cainfo = res3507for10188.Cainfo
  4226. // res7.WarnMsg = res3507for10188.WarnMsg
  4227. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4228. // res7.Infcode = infocode
  4229. // } else {
  4230. //
  4231. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4232. // utils.ErrorLog("解析失败:%v", err)
  4233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4234. // return
  4235. // }
  4236. //
  4237. // }
  4238. // if res7.Infcode == 0 {
  4239. // item.IsSale = 2
  4240. // item.SaleDate = item.SaleDate
  4241. // item.Bchno = number
  4242. // service.SaveDF(item)
  4243. // if item.IsChange == 0 { //没变更,进行变更操作
  4244. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4245. //
  4246. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4247. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4248. //
  4249. // var respJSON3 map[string]interface{}
  4250. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4251. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4253. // return
  4254. // }
  4255. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4256. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4257. // // utils.ErrorLog("解析失败:%v", err)
  4258. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4259. // // return
  4260. // //}
  4261. //
  4262. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4263. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4264. // utils.ErrorLog("解析失败:%v", err)
  4265. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4266. // return
  4267. // }
  4268. // //if res3507for10188.Infcode
  4269. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4270. // //res.Output = resSix10265.Output
  4271. // res3.ErrMsg = res3507for10188.ErrMsg
  4272. // res3.Cainfo = res3507for10188.Cainfo
  4273. // res3.WarnMsg = res3507for10188.WarnMsg
  4274. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4275. // res3.Infcode = infocode
  4276. // } else {
  4277. //
  4278. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4279. // utils.ErrorLog("解析失败:%v", err)
  4280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4281. // return
  4282. // }
  4283. //
  4284. // }
  4285. // if res3.Infcode == 0 {
  4286. // item.IsChange = 1
  4287. // item.BgBchno = bg_number
  4288. // service.SaveDF2(item)
  4289. // } else {
  4290. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4291. // }
  4292. // }
  4293. // } else {
  4294. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4295. // }
  4296. // }
  4297. // } else { //还没结算
  4298. // if item.IsChange == 0 { //没变更,进行变更操作
  4299. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4300. //
  4301. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4302. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4303. //
  4304. // var respJSON3 map[string]interface{}
  4305. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4306. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4307. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4308. // return
  4309. // }
  4310. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4311. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4312. // // utils.ErrorLog("解析失败:%v", err)
  4313. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4314. // // return
  4315. // //}
  4316. //
  4317. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4318. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4319. // utils.ErrorLog("解析失败:%v", err)
  4320. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4321. // return
  4322. // }
  4323. // //if res3507for10188.Infcode
  4324. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4325. // //res.Output = resSix10265.Output
  4326. // res3.ErrMsg = res3507for10188.ErrMsg
  4327. // res3.Cainfo = res3507for10188.Cainfo
  4328. // res3.WarnMsg = res3507for10188.WarnMsg
  4329. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4330. // res3.Infcode = infocode
  4331. // } else {
  4332. //
  4333. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4334. // utils.ErrorLog("解析失败:%v", err)
  4335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4336. // return
  4337. // }
  4338. //
  4339. // }
  4340. // if res3.Infcode == 0 {
  4341. // item.IsChange = 1
  4342. // item.BgBchno = bg_number
  4343. // service.SaveDF2(item)
  4344. // } else {
  4345. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4346. // }
  4347. // }
  4348. // }
  4349. //}
  4350. }
  4351. if len(err) == 0 {
  4352. c.ServeSuccessJSON(map[string]interface{}{
  4353. "msg": "销售变更成功",
  4354. })
  4355. } else {
  4356. c.ServeSuccessJSON(map[string]interface{}{
  4357. "failed_code": -10,
  4358. "msg": err,
  4359. })
  4360. }
  4361. }
  4362. func (c *HisApiController) ChangeDrugthree() {
  4363. //ids := c.GetString("ids")
  4364. //id_arr := strings.Split(ids, ",")
  4365. flows, _ := service.GetNewDrugFlowInfothree()
  4366. admin_user_id, _ := c.GetInt64("admin_user_id")
  4367. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4368. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4369. var err []string
  4370. for _, item := range flows {
  4371. var res3 ResultSix
  4372. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4373. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4374. if prescription.OrderStatus == 2 {
  4375. //已经结算
  4376. //判断是否已经销售
  4377. if item.IsSale == 1 { //是否已经销售,1是 0否
  4378. //是否已经变更 1是 0否
  4379. if item.IsChange == 0 { //没变更,进行变更操作
  4380. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4381. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4382. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4383. var respJSON3 map[string]interface{}
  4384. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4387. return
  4388. }
  4389. userJSONBytes3, _ := json.Marshal(respJSON3)
  4390. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4391. utils.ErrorLog("解析失败:%v", err)
  4392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4393. return
  4394. }
  4395. if res3.Infcode == 0 {
  4396. item.IsChange = 1
  4397. item.BgBchno = bg_number
  4398. service.SaveDF2(item)
  4399. } else {
  4400. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4401. }
  4402. }
  4403. } else { //没销售,
  4404. var res FJ3507Result
  4405. var res3507for10188 FJ3507ResultFor10188
  4406. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4407. //进行商品销售接口
  4408. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4409. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4410. var respJSON3 map[string]interface{}
  4411. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4414. return
  4415. }
  4416. userJSONBytes3, _ := json.Marshal(respJSON3)
  4417. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4418. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4419. utils.ErrorLog("解析失败:%v", err)
  4420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4421. return
  4422. }
  4423. //if res3507for10188.Infcode
  4424. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4425. //res.Output = resSix10265.Output
  4426. res.ErrMsg = res3507for10188.ErrMsg
  4427. res.Cainfo = res3507for10188.Cainfo
  4428. res.WarnMsg = res3507for10188.WarnMsg
  4429. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4430. res.Infcode = infocode
  4431. } else {
  4432. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4433. utils.ErrorLog("解析失败:%v", err)
  4434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4435. return
  4436. }
  4437. }
  4438. if res.Infcode == 0 {
  4439. item.IsSale = 1
  4440. item.Bchno = number
  4441. item.SaleDate = time.Now().Format("2006-01-02")
  4442. err5 := service.SaveDF(item)
  4443. if err5 == nil {
  4444. if item.IsChange == 0 { //没变更,进行变更操作
  4445. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4446. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4447. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4448. var respJSON3 map[string]interface{}
  4449. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4452. return
  4453. }
  4454. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4455. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4456. utils.ErrorLog("解析失败:%v", err)
  4457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4458. return
  4459. }
  4460. //if res3507for10188.Infcode
  4461. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4462. //res.Output = resSix10265.Output
  4463. res3.ErrMsg = res3507for10188.ErrMsg
  4464. res3.Cainfo = res3507for10188.Cainfo
  4465. res3.WarnMsg = res3507for10188.WarnMsg
  4466. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4467. res3.Infcode = infocode
  4468. } else if 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. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4484. utils.ErrorLog("解析失败:%v", err)
  4485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4486. return
  4487. }
  4488. }
  4489. if res3.Infcode == 0 {
  4490. item.IsChange = 1
  4491. item.BgBchno = bg_number
  4492. service.SaveDF2(item)
  4493. } else {
  4494. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4495. }
  4496. }
  4497. }
  4498. } else {
  4499. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4500. }
  4501. }
  4502. } else { //还没结算
  4503. var res3507for10188 FJ3507ResultFor10188
  4504. if item.IsChange == 0 { //没变更,进行变更操作
  4505. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4506. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4507. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4508. var respJSON3 map[string]interface{}
  4509. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4512. return
  4513. }
  4514. userJSONBytes3, _ := json.Marshal(respJSON3)
  4515. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4516. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4517. utils.ErrorLog("解析失败:%v", err)
  4518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4519. return
  4520. }
  4521. //if res3507for10188.Infcode
  4522. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4523. //res.Output = resSix10265.Output
  4524. res3.ErrMsg = res3507for10188.ErrMsg
  4525. res3.Cainfo = res3507for10188.Cainfo
  4526. res3.WarnMsg = res3507for10188.WarnMsg
  4527. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4528. res3.Infcode = infocode
  4529. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4530. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4531. utils.ErrorLog("解析失败:%v", err)
  4532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4533. return
  4534. }
  4535. //if res3507for10188.Infcode
  4536. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4537. //res.Output = resSix10265.Output
  4538. res3.ErrMsg = res3507for10188.ErrMsg
  4539. res3.Cainfo = res3507for10188.Cainfo
  4540. res3.WarnMsg = res3507for10188.WarnMsg
  4541. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4542. res3.Infcode = infocode
  4543. } else {
  4544. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4545. utils.ErrorLog("解析失败:%v", err)
  4546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4547. return
  4548. }
  4549. }
  4550. if res3.Infcode == 0 {
  4551. item.IsChange = 1
  4552. item.BgBchno = bg_number
  4553. service.SaveDF2(item)
  4554. } else {
  4555. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4556. }
  4557. }
  4558. }
  4559. } else if item.ConsumableType == 7 {
  4560. var res3507for10188 FJ3507ResultFor10188
  4561. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4562. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4563. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4564. //判断是否已经销售
  4565. if item.IsSale == 2 { //是否已经销售,1是 0否
  4566. //是否已经变更 1是 0否
  4567. if item.IsChange == 0 { //没变更,进行变更操作
  4568. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4569. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4570. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4571. var respJSON3 map[string]interface{}
  4572. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4575. return
  4576. }
  4577. userJSONBytes3, _ := json.Marshal(respJSON3)
  4578. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4579. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4580. utils.ErrorLog("解析失败:%v", err)
  4581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4582. return
  4583. }
  4584. //if res3507for10188.Infcode
  4585. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4586. //res.Output = resSix10265.Output
  4587. res3.ErrMsg = res3507for10188.ErrMsg
  4588. res3.Cainfo = res3507for10188.Cainfo
  4589. res3.WarnMsg = res3507for10188.WarnMsg
  4590. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4591. res3.Infcode = infocode
  4592. } else {
  4593. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4594. utils.ErrorLog("解析失败:%v", err)
  4595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4596. return
  4597. }
  4598. }
  4599. if res3.Infcode == 0 {
  4600. item.IsChange = 1
  4601. item.BgBchno = bg_number
  4602. service.SaveDF2(item)
  4603. } else {
  4604. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4605. }
  4606. }
  4607. } else { //没销售,
  4608. //进行商品销售退货接口
  4609. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4610. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4611. saveLog(result111, result222, "3506", "销售退货")
  4612. var res7 FJ3507Result
  4613. //进行商品销售接口
  4614. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4615. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4616. var respJSON3 map[string]interface{}
  4617. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4620. return
  4621. }
  4622. userJSONBytes3, _ := json.Marshal(respJSON3)
  4623. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4624. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4625. utils.ErrorLog("解析失败:%v", err)
  4626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4627. return
  4628. }
  4629. //if res3507for10188.Infcode
  4630. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4631. //res.Output = resSix10265.Output
  4632. res7.ErrMsg = res3507for10188.ErrMsg
  4633. res7.Cainfo = res3507for10188.Cainfo
  4634. res7.WarnMsg = res3507for10188.WarnMsg
  4635. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4636. res7.Infcode = infocode
  4637. } else {
  4638. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4639. utils.ErrorLog("解析失败:%v", err)
  4640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4641. return
  4642. }
  4643. }
  4644. if res7.Infcode == 0 {
  4645. item.IsSale = 2
  4646. item.SaleDate = item.SaleDate
  4647. item.Bchno = number
  4648. service.SaveDF(item)
  4649. if item.IsChange == 0 { //没变更,进行变更操作
  4650. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4651. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4652. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4653. var respJSON3 map[string]interface{}
  4654. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4657. return
  4658. }
  4659. userJSONBytes3, _ := json.Marshal(respJSON3)
  4660. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4661. // utils.ErrorLog("解析失败:%v", err)
  4662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4663. // return
  4664. //}
  4665. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4666. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4667. utils.ErrorLog("解析失败:%v", err)
  4668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4669. return
  4670. }
  4671. //if res3507for10188.Infcode
  4672. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4673. //res.Output = resSix10265.Output
  4674. res3.ErrMsg = res3507for10188.ErrMsg
  4675. res3.Cainfo = res3507for10188.Cainfo
  4676. res3.WarnMsg = res3507for10188.WarnMsg
  4677. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4678. res3.Infcode = infocode
  4679. } else {
  4680. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4681. utils.ErrorLog("解析失败:%v", err)
  4682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4683. return
  4684. }
  4685. }
  4686. if res3.Infcode == 0 {
  4687. item.IsChange = 1
  4688. item.BgBchno = bg_number
  4689. service.SaveDF2(item)
  4690. } else {
  4691. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4692. }
  4693. }
  4694. } else {
  4695. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4696. }
  4697. }
  4698. } else { //还没结算
  4699. if item.IsChange == 0 { //没变更,进行变更操作
  4700. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4701. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4702. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4703. var respJSON3 map[string]interface{}
  4704. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4707. return
  4708. }
  4709. userJSONBytes3, _ := json.Marshal(respJSON3)
  4710. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4711. // utils.ErrorLog("解析失败:%v", err)
  4712. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4713. // return
  4714. //}
  4715. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4716. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4717. utils.ErrorLog("解析失败:%v", err)
  4718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4719. return
  4720. }
  4721. //if res3507for10188.Infcode
  4722. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4723. //res.Output = resSix10265.Output
  4724. res3.ErrMsg = res3507for10188.ErrMsg
  4725. res3.Cainfo = res3507for10188.Cainfo
  4726. res3.WarnMsg = res3507for10188.WarnMsg
  4727. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4728. res3.Infcode = infocode
  4729. } else {
  4730. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4731. utils.ErrorLog("解析失败:%v", err)
  4732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4733. return
  4734. }
  4735. }
  4736. if res3.Infcode == 0 {
  4737. item.IsChange = 1
  4738. item.BgBchno = bg_number
  4739. service.SaveDF2(item)
  4740. } else {
  4741. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4742. }
  4743. }
  4744. }
  4745. }
  4746. }
  4747. if len(err) == 0 {
  4748. c.ServeSuccessJSON(map[string]interface{}{
  4749. "msg": "销售变更成功",
  4750. })
  4751. } else {
  4752. c.ServeSuccessJSON(map[string]interface{}{
  4753. "failed_code": -10,
  4754. "msg": err,
  4755. })
  4756. }
  4757. }
  4758. func (c *HisApiController) ChangeDrugTen() {
  4759. start_time_str := c.GetString("start_time")
  4760. end_time_str := c.GetString("end_time")
  4761. //ids := c.GetString("ids")
  4762. //id_arr := strings.Split(ids, ",")
  4763. timeLayout := "2006-01-02"
  4764. loc, _ := time.LoadLocation("Local")
  4765. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4766. recordStartTime := theStartTime.Unix()
  4767. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4768. recordEndTime := theEndTime.Unix()
  4769. //timestamp := int64(1729612800)
  4770. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4771. admin_user_id, _ := c.GetInt64("admin_user_id")
  4772. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4773. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4774. var err []string
  4775. for _, item := range flows {
  4776. var res3 ResultSix
  4777. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4778. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4779. continue
  4780. }
  4781. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4782. continue
  4783. }
  4784. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4785. if prescription.OrderStatus == 2 {
  4786. //已经结算
  4787. //判断 是否已经销售
  4788. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4789. ////是否已经变更 1是 0否
  4790. //if item.IsChange == 0 { //没变更,进行变更操作
  4791. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4792. //
  4793. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4794. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4795. // var respJSON3 map[string]interface{}
  4796. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4797. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4798. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4799. // return
  4800. // }
  4801. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4802. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4803. // utils.ErrorLog("解析失败:%v", err)
  4804. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4805. // return
  4806. // }
  4807. // if res3.Infcode == 0 {
  4808. // item.IsChange = 1
  4809. // item.BgBchno = bg_number
  4810. // service.SaveDF2(item)
  4811. // } else {
  4812. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4813. // }
  4814. //}
  4815. //} else
  4816. if item.IsSale == 0 { //没销售,
  4817. var res FJ3507Result
  4818. var res3507for10188 FJ3507ResultFor10188
  4819. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4820. //进行商品销售接口
  4821. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4822. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4823. var respJSON3 map[string]interface{}
  4824. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4827. return
  4828. }
  4829. userJSONBytes3, _ := json.Marshal(respJSON3)
  4830. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4831. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4832. utils.ErrorLog("解析失败:%v", err)
  4833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4834. return
  4835. }
  4836. //if res3507for10188.Infcode
  4837. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4838. //res.Output = resSix10265.Output
  4839. res.ErrMsg = res3507for10188.ErrMsg
  4840. res.Cainfo = res3507for10188.Cainfo
  4841. res.WarnMsg = res3507for10188.WarnMsg
  4842. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4843. res.Infcode = infocode
  4844. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4845. } else {
  4846. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4847. utils.ErrorLog("解析失败:%v", err)
  4848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4849. return
  4850. }
  4851. }
  4852. if res.Infcode == 0 {
  4853. item.IsSale = 1
  4854. item.Bchno = number
  4855. item.SaleDate = time.Now().Format("2006-01-02")
  4856. err5 := service.SaveDF(item)
  4857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4858. //if err5 == nil {
  4859. //
  4860. // if item.IsChange == 1 { //没变更,进行变更操作
  4861. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4862. //
  4863. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4864. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4865. //
  4866. // var respJSON3 map[string]interface{}
  4867. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4868. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4870. // return
  4871. // }
  4872. //
  4873. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4874. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4875. // utils.ErrorLog("解析失败:%v", err)
  4876. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4877. // return
  4878. // }
  4879. // //if res3507for10188.Infcode
  4880. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4881. // //res.Output = resSix10265.Output
  4882. // res3.ErrMsg = res3507for10188.ErrMsg
  4883. // res3.Cainfo = res3507for10188.Cainfo
  4884. // res3.WarnMsg = res3507for10188.WarnMsg
  4885. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4886. // res3.Infcode = infocode
  4887. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4888. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4889. // utils.ErrorLog("解析失败:%v", err)
  4890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4891. // return
  4892. // }
  4893. // //if res3507for10188.Infcode
  4894. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4895. // //res.Output = resSix10265.Output
  4896. // res3.ErrMsg = res3507for10188.ErrMsg
  4897. // res3.Cainfo = res3507for10188.Cainfo
  4898. // res3.WarnMsg = res3507for10188.WarnMsg
  4899. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4900. // res3.Infcode = infocode
  4901. //
  4902. // } else {
  4903. //
  4904. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4905. // utils.ErrorLog("解析失败:%v", err)
  4906. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4907. // return
  4908. // }
  4909. //
  4910. // }
  4911. //
  4912. // if res3.Infcode == 0 {
  4913. // item.IsChange = 1
  4914. // item.BgBchno = bg_number
  4915. // service.SaveDF2(item)
  4916. // return
  4917. // } else {
  4918. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4919. // }
  4920. // }
  4921. //}
  4922. } else {
  4923. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4924. }
  4925. }
  4926. }
  4927. } else if item.ConsumableType == 7 {
  4928. var res3507for10188 FJ3507ResultFor10188
  4929. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4930. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4931. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4932. //判断是否已经销售
  4933. if item.IsSale == 2 { //是否已经销售,1是 0否
  4934. //是否已经变更 1是 0否
  4935. if item.IsChange == 0 { //没变更,进行变更操作
  4936. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4937. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4938. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4939. var respJSON3 map[string]interface{}
  4940. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4943. return
  4944. }
  4945. userJSONBytes3, _ := json.Marshal(respJSON3)
  4946. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4947. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4948. utils.ErrorLog("解析失败:%v", err)
  4949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4950. return
  4951. }
  4952. //if res3507for10188.Infcode
  4953. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4954. //res.Output = resSix10265.Output
  4955. res3.ErrMsg = res3507for10188.ErrMsg
  4956. res3.Cainfo = res3507for10188.Cainfo
  4957. res3.WarnMsg = res3507for10188.WarnMsg
  4958. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4959. res3.Infcode = infocode
  4960. } else {
  4961. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4962. utils.ErrorLog("解析失败:%v", err)
  4963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4964. return
  4965. }
  4966. }
  4967. if res3.Infcode == 0 {
  4968. item.IsChange = 1
  4969. item.BgBchno = bg_number
  4970. service.SaveDF2(item)
  4971. } else {
  4972. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4973. }
  4974. }
  4975. } else { //没销售,
  4976. //进行商品销售退货接口
  4977. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4978. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4979. saveLog(result111, result222, "3506", "销售退货")
  4980. var res7 FJ3507Result
  4981. //进行商品销售接口
  4982. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4983. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4984. var respJSON3 map[string]interface{}
  4985. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4988. return
  4989. }
  4990. userJSONBytes3, _ := json.Marshal(respJSON3)
  4991. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4992. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4993. utils.ErrorLog("解析失败:%v", err)
  4994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4995. return
  4996. }
  4997. //if res3507for10188.Infcode
  4998. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4999. //res.Output = resSix10265.Output
  5000. res7.ErrMsg = res3507for10188.ErrMsg
  5001. res7.Cainfo = res3507for10188.Cainfo
  5002. res7.WarnMsg = res3507for10188.WarnMsg
  5003. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5004. res7.Infcode = infocode
  5005. } else {
  5006. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  5007. utils.ErrorLog("解析失败:%v", err)
  5008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5009. return
  5010. }
  5011. }
  5012. if res7.Infcode == 0 {
  5013. item.IsSale = 2
  5014. item.SaleDate = item.SaleDate
  5015. item.Bchno = number
  5016. service.SaveDF(item)
  5017. if item.IsChange == 0 { //没变更,进行变更操作
  5018. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5019. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5020. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5021. var respJSON3 map[string]interface{}
  5022. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5025. return
  5026. }
  5027. userJSONBytes3, _ := json.Marshal(respJSON3)
  5028. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5029. // utils.ErrorLog("解析失败:%v", err)
  5030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5031. // return
  5032. //}
  5033. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5034. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5035. utils.ErrorLog("解析失败:%v", err)
  5036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5037. return
  5038. }
  5039. //if res3507for10188.Infcode
  5040. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5041. //res.Output = resSix10265.Output
  5042. res3.ErrMsg = res3507for10188.ErrMsg
  5043. res3.Cainfo = res3507for10188.Cainfo
  5044. res3.WarnMsg = res3507for10188.WarnMsg
  5045. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5046. res3.Infcode = infocode
  5047. } else {
  5048. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5049. utils.ErrorLog("解析失败:%v", err)
  5050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5051. return
  5052. }
  5053. }
  5054. if res3.Infcode == 0 {
  5055. item.IsChange = 1
  5056. item.BgBchno = bg_number
  5057. service.SaveDF2(item)
  5058. } else {
  5059. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5060. }
  5061. }
  5062. } else {
  5063. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5064. }
  5065. }
  5066. } else { //还没结算
  5067. if item.IsChange == 0 { //没变更,进行变更操作
  5068. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5069. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5070. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5071. var respJSON3 map[string]interface{}
  5072. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5075. return
  5076. }
  5077. userJSONBytes3, _ := json.Marshal(respJSON3)
  5078. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5079. // utils.ErrorLog("解析失败:%v", err)
  5080. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5081. // return
  5082. //}
  5083. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5084. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5085. utils.ErrorLog("解析失败:%v", err)
  5086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5087. return
  5088. }
  5089. //if res3507for10188.Infcode
  5090. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5091. //res.Output = resSix10265.Output
  5092. res3.ErrMsg = res3507for10188.ErrMsg
  5093. res3.Cainfo = res3507for10188.Cainfo
  5094. res3.WarnMsg = res3507for10188.WarnMsg
  5095. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5096. res3.Infcode = infocode
  5097. } else {
  5098. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5099. utils.ErrorLog("解析失败:%v", err)
  5100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5101. return
  5102. }
  5103. }
  5104. if res3.Infcode == 0 {
  5105. item.IsChange = 1
  5106. item.BgBchno = bg_number
  5107. service.SaveDF2(item)
  5108. } else {
  5109. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5110. }
  5111. }
  5112. }
  5113. }
  5114. }
  5115. if len(err) == 0 {
  5116. c.ServeSuccessJSON(map[string]interface{}{
  5117. "msg": "销售变更成功",
  5118. })
  5119. } else {
  5120. c.ServeSuccessJSON(map[string]interface{}{
  5121. "failed_code": -10,
  5122. "msg": err,
  5123. })
  5124. }
  5125. }
  5126. func ChangeDrugTenone() {
  5127. //ids := c.GetString("ids")
  5128. //id_arr := strings.Split(ids, ",")
  5129. now := time.Now()
  5130. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  5131. //timestamp := int64(1729612800)
  5132. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  5133. admin_user_id := int64(2463)
  5134. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  5135. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  5136. var err []string
  5137. for _, item := range flows {
  5138. var res3 ResultSix
  5139. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  5140. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5141. continue
  5142. }
  5143. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5144. continue
  5145. }
  5146. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5147. if prescription.OrderStatus == 2 {
  5148. //已经结算
  5149. //判断是否已经销售
  5150. if item.IsSale == 1 { //是否已经销售,1是 0否
  5151. //是否已经变更 1是 0否
  5152. if item.IsChange == 0 { //没变更,进行变更操作
  5153. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5154. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5155. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  5156. var respJSON3 map[string]interface{}
  5157. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5159. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5160. return
  5161. }
  5162. userJSONBytes3, _ := json.Marshal(respJSON3)
  5163. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5164. utils.ErrorLog("解析失败:%v", err)
  5165. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5166. return
  5167. }
  5168. if res3.Infcode == 0 {
  5169. item.IsChange = 1
  5170. item.BgBchno = bg_number
  5171. service.SaveDF2(item)
  5172. } else {
  5173. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5174. }
  5175. }
  5176. } else { //没销售,
  5177. var res FJ3507Result
  5178. var res3507for10188 FJ3507ResultFor10188
  5179. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  5180. //进行商品销售接口
  5181. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  5182. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  5183. var respJSON3 map[string]interface{}
  5184. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  5185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5186. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5187. return
  5188. }
  5189. userJSONBytes3, _ := json.Marshal(respJSON3)
  5190. {
  5191. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5192. utils.ErrorLog("解析失败:%v", err)
  5193. return
  5194. }
  5195. //if res3507for10188.Infcode
  5196. res.InfRefmsgid = res3507for10188.InfRefmsgid
  5197. //res.Output = resSix10265.Output
  5198. res.ErrMsg = res3507for10188.ErrMsg
  5199. res.Cainfo = res3507for10188.Cainfo
  5200. res.WarnMsg = res3507for10188.WarnMsg
  5201. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5202. res.Infcode = infocode
  5203. }
  5204. if res.Infcode == 0 {
  5205. item.IsSale = 1
  5206. item.Bchno = number
  5207. item.SaleDate = time.Now().Format("2006-01-02")
  5208. err5 := service.SaveDF(item)
  5209. if err5 == nil {
  5210. if item.IsChange == 1 { //没变更,进行变更操作
  5211. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5212. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5213. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5214. var respJSON3 map[string]interface{}
  5215. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5217. return
  5218. }
  5219. {
  5220. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5221. utils.ErrorLog("解析失败:%v", err)
  5222. return
  5223. }
  5224. //if res3507for10188.Infcode
  5225. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5226. //res.Output = resSix10265.Output
  5227. res3.ErrMsg = res3507for10188.ErrMsg
  5228. res3.Cainfo = res3507for10188.Cainfo
  5229. res3.WarnMsg = res3507for10188.WarnMsg
  5230. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5231. res3.Infcode = infocode
  5232. }
  5233. if res3.Infcode == 0 {
  5234. item.IsChange = 1
  5235. item.BgBchno = bg_number
  5236. service.SaveDF2(item)
  5237. } else {
  5238. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5239. }
  5240. }
  5241. }
  5242. } else {
  5243. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5244. }
  5245. }
  5246. }
  5247. }
  5248. }
  5249. }
  5250. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5251. var struct3502 models.Struct3502
  5252. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5253. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5254. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5255. struct3502.FixmedinsCode = miConfig.Code
  5256. struct3502.Code = miConfig.Code
  5257. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5258. struct3502.Opter = role.UserName
  5259. struct3502.RxFlag = "1"
  5260. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5261. struct3502.OrgName = miConfig.OrgName
  5262. struct3502.AccessKey = miConfig.AccessKey
  5263. struct3502.RequestUrl = miConfig.Url
  5264. struct3502.SecretKey = miConfig.SecretKey
  5265. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5266. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5267. struct3502.Url = miConfig.Url
  5268. struct3502.AppId = miConfig.Cainfo
  5269. struct3502.AppSecret = miConfig.AppSecret
  5270. struct3502.Enckey = miConfig.EncKey
  5271. struct3502.SignKey = miConfig.SignKey
  5272. struct3502.SecretKey = miConfig.SecretKey
  5273. struct3502.InvChgType = chgType
  5274. struct3502.FixmedinsBchno = number
  5275. struct3502.Cnt = strconv.FormatInt(count, 10)
  5276. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5277. //result1, result2, _ := service.FJyb3502(struct3502)
  5278. if miConfig.MdtrtareaAdmvs == "350500" {
  5279. result1, result2, _ := service.FJyb3502(struct3502)
  5280. //saveLog(result1, result2, "3502", "3502")
  5281. return result1, result2
  5282. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5283. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5284. return result1, result2
  5285. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5286. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5287. return result1, result2
  5288. } else {
  5289. data := make(map[string]interface{})
  5290. data["struct_3502s"] = struct3502
  5291. client := &http.Client{}
  5292. bytesData, _ := json.Marshal(data)
  5293. var req *http.Request
  5294. if miConfig.MdtrtareaAdmvs == "320830" {
  5295. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  5296. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5297. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5298. } else {
  5299. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5300. }
  5301. resp, _ := client.Do(req)
  5302. defer resp.Body.Close()
  5303. body, ioErr := ioutil.ReadAll(resp.Body)
  5304. if ioErr != nil {
  5305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5306. }
  5307. var respJSON map[string]interface{}
  5308. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5310. }
  5311. //var resSix10265 ResultSix10265 //1101结果
  5312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5313. result, _ := json.Marshal(respJSON)
  5314. return string(result), ""
  5315. }
  5316. }
  5317. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5318. var struct3505 models.Struct3505
  5319. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5320. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5321. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5322. struct3505.FixmedinsBchno = number
  5323. struct3505.Opter = role.UserName
  5324. struct3505.Bchno = "---"
  5325. struct3505.FixmedinsCode = miConfig.Code
  5326. struct3505.Code = miConfig.Code
  5327. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.HisDoctorAdviceInfo.Price, 'f', -1, 64)
  5328. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5329. struct3505.PrscDrName = roles.UserName
  5330. if org_id == 10191 {
  5331. struct3505.PharName = "刘水山"
  5332. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5333. }
  5334. if org_id == 10188 {
  5335. struct3505.PharName = "李汉清"
  5336. struct3505.PharPracCertNo = "30220200932022010034"
  5337. }
  5338. if org_id == 10217 {
  5339. struct3505.PharName = "张敏"
  5340. struct3505.PharPracCertNo = "30220230432090100108"
  5341. }
  5342. if org_id == 10318 {
  5343. struct3505.PharName = "邹刘阳"
  5344. struct3505.PharPracCertNo = "210441200001378"
  5345. }
  5346. if org_id == 10402 {
  5347. struct3505.PharName = "刘韶健"
  5348. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5349. }
  5350. if org_id == 9919 {
  5351. struct3505.PharName = "周君权"
  5352. struct3505.PharPracCertNo = "089644396094401375"
  5353. }
  5354. if org_id == 10644 {
  5355. struct3505.PharName = "陈金娣"
  5356. struct3505.PharPracCertNo = "20181441500320100066"
  5357. }
  5358. if org_id == 10567 {
  5359. struct3505.PharName = "范小兰"
  5360. struct3505.PharPracCertNo = "0200102079485"
  5361. }
  5362. if org_id == 10721 {
  5363. struct3505.PharName = "孙莉侠"
  5364. struct3505.PharPracCertNo = "060399"
  5365. }
  5366. if org_id == 10726 {
  5367. struct3505.PharName = "彭建福"
  5368. struct3505.PharPracCertNo = "D445281006261"
  5369. }
  5370. if org_id == 10697 {
  5371. struct3505.PharName = "陶海兰"
  5372. struct3505.PharPracCertNo = "0010933"
  5373. }
  5374. if org_id == 10265 {
  5375. struct3505.PharName = "李彩星"
  5376. struct3505.PharPracCertNo = "20171110600110100019"
  5377. }
  5378. if org_id == 10028 {
  5379. struct3505.PharName = "曾细平"
  5380. struct3505.PharPracCertNo = "D440307022134"
  5381. }
  5382. if org_id == 10138 {
  5383. struct3505.PharName = "彭斯遥"
  5384. struct3505.PharPracCertNo = "30220200943042010052"
  5385. }
  5386. if org_id == 10278 {
  5387. struct3505.PharName = "彭斯遥"
  5388. struct3505.PharPracCertNo = "30220200943042010052"
  5389. }
  5390. if org_id == 10610 {
  5391. struct3505.PharName = "彭斯遥"
  5392. struct3505.PharPracCertNo = "30220200943042010052"
  5393. }
  5394. if org_id == 10537 {
  5395. struct3505.PharName = "彭斯遥"
  5396. struct3505.PharPracCertNo = "30220200943042010052"
  5397. }
  5398. if org_id == 9504 {
  5399. struct3505.PharName = "资美红"
  5400. struct3505.PharPracCertNo = "D440904006635"
  5401. }
  5402. if org_id == 10480 {
  5403. struct3505.PharName = "陈思"
  5404. struct3505.PharPracCertNo = "30220240434110010470"
  5405. }
  5406. if org_id == 10653 {
  5407. struct3505.PharName = "邓树英"
  5408. struct3505.PharPracCertNo = "201910026440004734"
  5409. }
  5410. if org_id == 10571 {
  5411. struct3505.PharName = "廖志平"
  5412. struct3505.PharPracCertNo = "0136425"
  5413. }
  5414. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5415. struct3505.SetlId = order.SetlId
  5416. struct3505.MdtrtSn = order.MdtrtId
  5417. struct3505.ManuLotnum = drug.BatchNumber
  5418. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5419. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5420. struct3505.RxFlag = "1"
  5421. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5422. struct3505.TrdnFlag = "0"
  5423. } else {
  5424. struct3505.TrdnFlag = "1"
  5425. }
  5426. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5427. struct3505.TrdnFlag = "1"
  5428. }
  5429. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5430. struct3505.TrdnFlag = "0"
  5431. }
  5432. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 {
  5433. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 1 {
  5434. struct3505.TrdnFlag = "1"
  5435. }
  5436. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 2 {
  5437. struct3505.TrdnFlag = "0"
  5438. }
  5439. }
  5440. struct3505.RtalDocno = order.Number
  5441. struct3505.PsnCertType = "01"
  5442. struct3505.CertNo = order.Certno
  5443. struct3505.PsnNo = order.PsnNo
  5444. struct3505.PsnName = order.PsnName
  5445. struct3505.Url = miConfig.Url
  5446. struct3505.AppId = miConfig.Cainfo
  5447. struct3505.AppSecret = miConfig.AppSecret
  5448. struct3505.Enckey = miConfig.EncKey
  5449. struct3505.SignKey = miConfig.SignKey
  5450. struct3505.SecretKey = miConfig.SecretKey
  5451. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5452. struct3505.SelRetnCnt = strValue
  5453. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5454. struct3505.SelRetnOpterName = role.UserName
  5455. if order.IsMedicineInsurance == 1 {
  5456. struct3505.MdtrtSetlType = "1"
  5457. } else {
  5458. struct3505.MdtrtSetlType = "2"
  5459. }
  5460. struct3505.OrgName = miConfig.OrgName
  5461. struct3505.AccessKey = miConfig.AccessKey
  5462. struct3505.RequestUrl = miConfig.Url
  5463. struct3505.SecretKey = miConfig.SecretKey
  5464. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5465. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5466. struct3505.Cainfo = miConfig.Cainfo
  5467. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5468. if miConfig.MdtrtareaAdmvs == "350500" {
  5469. result1, result2, _ := service.FJyb3505(struct3505)
  5470. return result1, result2
  5471. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5472. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5473. return result1, result2
  5474. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5475. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5476. return result1, result2
  5477. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5478. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5479. return result1, result2
  5480. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5481. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5482. return result1, result2
  5483. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5484. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5485. return result1, result2
  5486. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5487. data := make(map[string]interface{})
  5488. data["struct_3505s"] = struct3505
  5489. client := &http.Client{}
  5490. bytesData, _ := json.Marshal(data)
  5491. var req *http.Request
  5492. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5493. resp, _ := client.Do(req)
  5494. defer resp.Body.Close()
  5495. body, ioErr := ioutil.ReadAll(resp.Body)
  5496. if ioErr != nil {
  5497. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5498. }
  5499. var respJSON map[string]interface{}
  5500. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5502. }
  5503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5504. result, _ := json.Marshal(respJSON)
  5505. return string(result), ""
  5506. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5507. data := make(map[string]interface{})
  5508. data["struct_3505s"] = struct3505
  5509. client := &http.Client{}
  5510. bytesData, _ := json.Marshal(data)
  5511. var req *http.Request
  5512. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5513. resp, _ := client.Do(req)
  5514. defer resp.Body.Close()
  5515. body, ioErr := ioutil.ReadAll(resp.Body)
  5516. if ioErr != nil {
  5517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5518. }
  5519. var respJSON map[string]interface{}
  5520. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5522. }
  5523. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5524. if status == "0" {
  5525. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5526. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5527. }
  5528. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5529. result, _ := json.Marshal(respJSON)
  5530. return string(result), ""
  5531. } else {
  5532. data := make(map[string]interface{})
  5533. data["struct_3505s"] = struct3505
  5534. client := &http.Client{}
  5535. bytesData, _ := json.Marshal(data)
  5536. var req *http.Request
  5537. if miConfig.MdtrtareaAdmvs == "320830" {
  5538. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5539. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5540. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5541. } else {
  5542. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5543. }
  5544. resp, _ := client.Do(req)
  5545. defer resp.Body.Close()
  5546. body, ioErr := ioutil.ReadAll(resp.Body)
  5547. if ioErr != nil {
  5548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5549. }
  5550. var respJSON map[string]interface{}
  5551. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5553. }
  5554. //var resSix10265 ResultSix10265 //1101结果
  5555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5556. result, _ := json.Marshal(respJSON)
  5557. return string(result), ""
  5558. }
  5559. }
  5560. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5561. var struct3505 models.Struct3505
  5562. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5563. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5564. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5565. struct3505.FixmedinsBchno = number
  5566. struct3505.Opter = role.UserName
  5567. struct3505.FixmedinsCode = miConfig.Code
  5568. struct3505.Code = miConfig.Code
  5569. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5570. struct3505.PrscDrName = roles.UserName
  5571. if org_id == 10191 {
  5572. struct3505.PharName = "刘水山"
  5573. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5574. }
  5575. if org_id == 10188 {
  5576. struct3505.PharName = "李汉清"
  5577. struct3505.PharPracCertNo = "30220200932022010034"
  5578. }
  5579. if org_id == 10217 {
  5580. struct3505.PharName = "张敏"
  5581. struct3505.PharPracCertNo = "30220230432090100108"
  5582. }
  5583. if org_id == 10318 {
  5584. struct3505.PharName = "邹刘阳"
  5585. struct3505.PharPracCertNo = "210441200001378"
  5586. }
  5587. if org_id == 10402 {
  5588. struct3505.PharName = "刘韶健"
  5589. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5590. }
  5591. if org_id == 9919 {
  5592. struct3505.PharName = "周君权"
  5593. struct3505.PharPracCertNo = "089644396094401375"
  5594. }
  5595. if org_id == 10644 {
  5596. struct3505.PharName = "陈金娣"
  5597. struct3505.PharPracCertNo = "20181441500320100066"
  5598. }
  5599. if org_id == 10567 {
  5600. struct3505.PharName = "范小兰"
  5601. struct3505.PharPracCertNo = "0200102079485"
  5602. }
  5603. if org_id == 10721 {
  5604. struct3505.PharName = "孙莉侠"
  5605. struct3505.PharPracCertNo = "060399"
  5606. }
  5607. if org_id == 10726 {
  5608. struct3505.PharName = "彭建福"
  5609. struct3505.PharPracCertNo = "D445281006261"
  5610. }
  5611. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5612. struct3505.SetlId = order.SetlId
  5613. struct3505.MdtrtSn = order.MdtrtId
  5614. struct3505.ManuLotnum = drug.Number
  5615. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5616. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5617. struct3505.RxFlag = "1"
  5618. struct3505.TrdnFlag = "0"
  5619. struct3505.RtalDocno = order.Number
  5620. struct3505.PsnCertType = "01"
  5621. struct3505.CertNo = order.Certno
  5622. struct3505.PsnNo = order.PsnNo
  5623. struct3505.PsnName = order.PsnName
  5624. struct3505.Url = miConfig.Url
  5625. struct3505.AppId = miConfig.Cainfo
  5626. struct3505.AppSecret = miConfig.AppSecret
  5627. struct3505.Enckey = miConfig.EncKey
  5628. struct3505.SignKey = miConfig.SignKey
  5629. struct3505.SecretKey = miConfig.SecretKey
  5630. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5631. struct3505.SelRetnCnt = strValue
  5632. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5633. struct3505.SelRetnOpterName = role.UserName
  5634. if order.IsMedicineInsurance == 1 {
  5635. struct3505.MdtrtSetlType = "1"
  5636. } else {
  5637. struct3505.MdtrtSetlType = "2"
  5638. }
  5639. struct3505.OrgName = miConfig.OrgName
  5640. struct3505.AccessKey = miConfig.AccessKey
  5641. struct3505.RequestUrl = miConfig.Url
  5642. struct3505.SecretKey = miConfig.SecretKey
  5643. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5644. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5645. struct3505.Cainfo = miConfig.Cainfo
  5646. struct3505.DrugTracCodg = drug.DrugCode
  5647. if miConfig.MdtrtareaAdmvs == "350500" {
  5648. result1, result2, _ := service.FJyb3505(struct3505)
  5649. return result1, result2
  5650. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5651. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5652. return result1, result2
  5653. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5654. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5655. return result1, result2
  5656. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5657. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5658. return result1, result2
  5659. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5660. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5661. return result1, result2
  5662. } else {
  5663. data := make(map[string]interface{})
  5664. data["struct_3505s"] = struct3505
  5665. client := &http.Client{}
  5666. bytesData, _ := json.Marshal(data)
  5667. var req *http.Request
  5668. if miConfig.MdtrtareaAdmvs == "320830" {
  5669. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5670. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5671. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5672. } else {
  5673. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5674. }
  5675. resp, _ := client.Do(req)
  5676. defer resp.Body.Close()
  5677. body, ioErr := ioutil.ReadAll(resp.Body)
  5678. if ioErr != nil {
  5679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5680. }
  5681. var respJSON map[string]interface{}
  5682. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5684. }
  5685. //var resSix10265 ResultSix10265 //1101结果
  5686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5687. result, _ := json.Marshal(respJSON)
  5688. return string(result), ""
  5689. }
  5690. }
  5691. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5692. var struct3506 models.Struct3506
  5693. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5694. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5695. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5696. struct3506.FixmedinsCode = miConfig.Code
  5697. struct3506.Code = miConfig.Code
  5698. struct3506.FixmedinsBchno = number
  5699. struct3506.Opter = role.UserName
  5700. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5701. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5702. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5703. struct3506.MdtrtSn = order.MdtrtId
  5704. struct3506.ExpyEnd = ""
  5705. struct3506.RxFlag = "0"
  5706. struct3506.TrdnFlag = "1"
  5707. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5708. struct3506.SelRetnCnt = strValue
  5709. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5710. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5711. struct3506.SelRetnOpterName = role.UserName
  5712. struct3506.OrgName = miConfig.OrgName
  5713. struct3506.AccessKey = miConfig.AccessKey
  5714. struct3506.RequestUrl = miConfig.Url
  5715. struct3506.SecretKey = miConfig.SecretKey
  5716. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5717. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5718. struct3506.Url = miConfig.Url
  5719. struct3506.AppId = miConfig.Cainfo
  5720. struct3506.AppSecret = miConfig.AppSecret
  5721. struct3506.Enckey = miConfig.EncKey
  5722. struct3506.SignKey = miConfig.SignKey
  5723. struct3506.SecretKey = miConfig.SecretKey
  5724. struct3506.DrugTracCodg = drug.DrugCode
  5725. if miConfig.MdtrtareaAdmvs == "350500" {
  5726. result1, result2, _ := service.FJyb3506(struct3506)
  5727. return result1, result2
  5728. } else {
  5729. data := make(map[string]interface{})
  5730. data["struct_3506s"] = struct3506
  5731. client := &http.Client{}
  5732. bytesData, _ := json.Marshal(data)
  5733. var req *http.Request
  5734. if miConfig.MdtrtareaAdmvs == "320830" {
  5735. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3506", bytes.NewReader(bytesData))
  5736. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5737. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5738. } else {
  5739. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5740. }
  5741. resp, _ := client.Do(req)
  5742. defer resp.Body.Close()
  5743. body, ioErr := ioutil.ReadAll(resp.Body)
  5744. if ioErr != nil {
  5745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5746. }
  5747. var respJSON map[string]interface{}
  5748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5750. }
  5751. //var resSix10265 ResultSix10265 //1101结果
  5752. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5753. result, _ := json.Marshal(respJSON)
  5754. return string(result), ""
  5755. }
  5756. }
  5757. func (c *HisApiController) Get1318() {
  5758. adminUser := c.GetAdminUserInfo()
  5759. admin_user_id, _ := c.GetInt64("admin_user_id")
  5760. code := c.GetString("code")
  5761. code = ""
  5762. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5763. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5764. api := ""
  5765. if miConfig.MdtrtareaAdmvs == "320830" {
  5766. api = miConfig.AppSecret + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5767. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5768. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5769. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5770. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5771. } else {
  5772. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5773. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5774. }
  5775. resp, requestErr := http.Get(api)
  5776. if requestErr != nil {
  5777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5778. return
  5779. }
  5780. body, ioErr := ioutil.ReadAll(resp.Body)
  5781. if ioErr != nil {
  5782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5784. return
  5785. }
  5786. var respJSON map[string]interface{}
  5787. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5790. return
  5791. }
  5792. //var res Result2406
  5793. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5794. result, _ := json.Marshal(respJSON)
  5795. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5796. utils.ErrorLog("解析失败:%v", err)
  5797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5798. return
  5799. }
  5800. if res.Infcode == "0" {
  5801. c.ServeSuccessJSON(map[string]interface{}{
  5802. "result": "",
  5803. })
  5804. } else {
  5805. c.ServeSuccessJSON(map[string]interface{}{
  5806. "failed_code": -10,
  5807. "msg": res.ErrMsg,
  5808. })
  5809. */return
  5810. //}
  5811. }
  5812. func (c *HisApiController) Get2503() {
  5813. adminUser := c.GetAdminUserInfo()
  5814. admin_user_id, _ := c.GetInt64("admin_user_id")
  5815. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5816. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5817. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5818. }
  5819. func (c *HisApiController) Get2406() {
  5820. id, _ := c.GetInt64("id")
  5821. record_time := c.GetString("record_time")
  5822. his_patient_id, _ := c.GetInt64("his_patient_id")
  5823. admin_user_id, _ := c.GetInt64("admin_user_id")
  5824. diagnosis_id := c.GetString("diagnosis")
  5825. timeLayout := "2006-01-02"
  5826. loc, _ := time.LoadLocation("Local")
  5827. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5828. if err != nil {
  5829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5830. return
  5831. }
  5832. recordDateTime := theTime.Unix()
  5833. adminUser := c.GetAdminUserInfo()
  5834. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5835. var config []*models.HisXtDiagnoseConfig
  5836. for _, item := range diagnosis_ids {
  5837. id, _ := strconv.ParseInt(item, 10, 64)
  5838. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5839. config = append(config, &diagnosisConfig)
  5840. }
  5841. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5842. fmt.Println(his_patient_id)
  5843. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5844. //timestamp := time.Now().Unix()
  5845. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5846. var patientPrescription models.HisPrescriptionInfo
  5847. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5848. if patientPrescription.ID == 0 {
  5849. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5850. }
  5851. var res2 Result2406
  5852. if miConfig.MdtrtareaAdmvs == "341203" {
  5853. data := make(map[string]interface{})
  5854. client := &http.Client{}
  5855. data["psn_no"] = his.PsnNo
  5856. data["mdtrt_id"] = his.Number
  5857. data["operator"] = roles.UserName
  5858. data["cert_no"] = his.IdCardNo
  5859. data["org_name"] = miConfig.OrgName
  5860. data["psn_name"] = his.Name
  5861. data["ipt_otp_no"] = his.IptOtpNo
  5862. data["ipt_psn_sp_flag_type"] = "0901"
  5863. data["ipt_psn_sp_flag"] = "1"
  5864. data["fixmedins_code"] = miConfig.Code
  5865. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5866. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5867. data["url"] = miConfig.Url
  5868. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5869. bytesData, _ := json.Marshal(data)
  5870. var req *http.Request
  5871. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5872. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5873. resp, _ := client.Do(req)
  5874. defer resp.Body.Close()
  5875. body, ioErr := ioutil.ReadAll(resp.Body)
  5876. if ioErr != nil {
  5877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5879. return
  5880. }
  5881. var respJSON map[string]interface{}
  5882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5885. return
  5886. }
  5887. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5888. if status == "0" {
  5889. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5890. c.ServeSuccessJSON(map[string]interface{}{
  5891. "failed_code": -10,
  5892. "msg": err_msg,
  5893. })
  5894. return
  5895. }
  5896. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5897. userJSONBytes, _ := json.Marshal(respJSON)
  5898. fmt.Println("log")
  5899. fmt.Println(string(userJSONBytes))
  5900. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5901. utils.ErrorLog("解析失败:%v", err)
  5902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5903. return
  5904. }
  5905. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5906. data := make(map[string]interface{})
  5907. client := &http.Client{}
  5908. data["psn_no"] = his.PsnNo
  5909. data["mdtrt_id"] = his.Number
  5910. data["operator"] = roles.UserName
  5911. data["cert_no"] = his.IdCardNo
  5912. data["org_name"] = miConfig.OrgName
  5913. data["psn_name"] = his.Name
  5914. data["ipt_otp_no"] = his.IptOtpNo
  5915. data["ipt_psn_sp_flag_type"] = "0901"
  5916. data["ipt_psn_sp_flag"] = "1"
  5917. data["fixmedins_code"] = miConfig.Code
  5918. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5919. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5920. data["url"] = miConfig.Url
  5921. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5922. bytesData, _ := json.Marshal(data)
  5923. var req *http.Request
  5924. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5925. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5926. resp, _ := client.Do(req)
  5927. defer resp.Body.Close()
  5928. body, ioErr := ioutil.ReadAll(resp.Body)
  5929. if ioErr != nil {
  5930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5932. return
  5933. }
  5934. var respJSON map[string]interface{}
  5935. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5938. return
  5939. }
  5940. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5941. if status == "0" {
  5942. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5943. c.ServeSuccessJSON(map[string]interface{}{
  5944. "failed_code": -10,
  5945. "msg": err_msg,
  5946. })
  5947. return
  5948. }
  5949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5950. userJSONBytes, _ := json.Marshal(respJSON)
  5951. fmt.Println("log")
  5952. fmt.Println(string(userJSONBytes))
  5953. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5954. utils.ErrorLog("解析失败:%v", err)
  5955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5956. return
  5957. }
  5958. }
  5959. if res2.Infcode != 0 {
  5960. adminUser := c.GetAdminUserInfo()
  5961. errlog := &models.HisOrderError{
  5962. UserOrgId: adminUser.CurrentOrgId,
  5963. Ctime: time.Now().Unix(),
  5964. Mtime: time.Now().Unix(),
  5965. ErrMsg: res2.ErrMsg,
  5966. Status: 1,
  5967. PatientId: id,
  5968. RecordTime: recordDateTime,
  5969. Stage: 3,
  5970. }
  5971. service.CreateErrMsgLog(errlog)
  5972. c.ServeSuccessJSON(map[string]interface{}{
  5973. "failed_code": -10,
  5974. "msg": res2.ErrMsg,
  5975. })
  5976. return
  5977. } else {
  5978. c.ServeSuccessJSON(map[string]interface{}{
  5979. "msg": "上传成功",
  5980. })
  5981. return
  5982. }
  5983. }
  5984. func (c *HisApiController) Get4105() {
  5985. }
  5986. func (c *HisApiController) Post5302() {
  5987. patient_id, _ := c.GetInt64("id")
  5988. admin_user_id, _ := c.GetInt64("admin_user_id")
  5989. p, _ := service.GetHisPatientById(patient_id)
  5990. adminUser := c.GetAdminUserInfo()
  5991. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5992. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5993. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5994. }
  5995. func (c *HisApiController) Get4104() {
  5996. }
  5997. type Output struct {
  5998. CertNo string `json:"certno"`
  5999. PsnName string `json:"psn_name"`
  6000. CardNo string `json:"card_no"`
  6001. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6002. CardSN string `json:"card_sn"`
  6003. PsnCertType string `json:"psn_cert_type"`
  6004. MdtrtCertNo string `json:"mdtrt_cert_no"`
  6005. MdtrtCertType string `json:"mdtrt_cert_type"`
  6006. QRCode string `json:"qrCode"`
  6007. EcToken string `json:"ecToken"`
  6008. }
  6009. type AHResponse struct {
  6010. Body AHBody `json:"body"`
  6011. Code int `json:"code"`
  6012. CSBCode int `json:"csbCode"`
  6013. Message string `json:"message"`
  6014. RequestID string `json:"requestId"`
  6015. State struct{} `json:"state"`
  6016. }
  6017. type AHBody struct {
  6018. ErrMsg string `json:"err_msg"`
  6019. InfRefMsgID string `json:"inf_refmsgid"`
  6020. InfCode int `json:"infcode"`
  6021. Output struct {
  6022. Result []struct {
  6023. BasMednFlag string `json:"bas_medn_flag"`
  6024. ChldMedcFlag string `json:"chld_medc_flag"`
  6025. ChrgitmLv string `json:"chrgitm_lv"`
  6026. Cnt float64 `json:"cnt"`
  6027. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6028. DrtReimFlag string `json:"drt_reim_flag"`
  6029. FeedetlSn string `json:"feedetl_sn"`
  6030. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6031. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6032. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6033. ListSpItemFlag string `json:"list_sp_item_flag"`
  6034. LmtUsedFlag string `json:"lmt_used_flag"`
  6035. MedChrgitmType string `json:"med_chrgitm_type"`
  6036. Memo string `json:"memo"`
  6037. OverlmtAmt float64 `json:"overlmt_amt"`
  6038. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6039. Pric float64 `json:"pric"`
  6040. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6041. SelfpayProp float64 `json:"selfpay_prop"`
  6042. } `json:"result"`
  6043. } `json:"output"`
  6044. }
  6045. type Response struct {
  6046. Output Output `json:"output"`
  6047. Infcode int `json:"infcode"`
  6048. InfRefMsgID string `json:"inf_refmsgid"`
  6049. RefMsgTime string `json:"refmsg_time"`
  6050. RespondTime string `json:"respond_time"`
  6051. ErrMsg string `json:"err_msg"`
  6052. WarnMsg string `json:"warn_msg"`
  6053. SignType string `json:"signtype"`
  6054. CAInfo string `json:"cainfo"`
  6055. }
  6056. func (c *HisApiController) Getquerydata() {
  6057. query_type, _ := c.GetInt64("type")
  6058. refd_setl_flag := c.GetString("refd_setl_flag")
  6059. med_type := c.GetString("med_type")
  6060. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6061. cert_no := c.GetString("cert_no")
  6062. psn_no := c.GetString("psn_no")
  6063. start_time := c.GetString("start_time")
  6064. end_time := c.GetString("end_time")
  6065. page, _ := c.GetInt64("page")
  6066. limit, _ := c.GetInt64("limit")
  6067. var bp models.BusinessParams5262
  6068. bp.RefdSetlFlag = refd_setl_flag
  6069. bp.MedType = med_type
  6070. bp.Certno = cert_no
  6071. bp.Psnno = psn_no
  6072. bp.QBegntime = start_time
  6073. bp.QEndtime = end_time
  6074. if query_type == 1 { //本地
  6075. Post5262(c, bp, page, limit)
  6076. } else { //异地
  6077. Post5267(c, bp, page, limit)
  6078. }
  6079. }
  6080. func (c *HisApiController) Drugscheck() {
  6081. admin_user_id, _ := c.GetInt64("admin_user_id")
  6082. adminUser := c.GetAdminUserInfo()
  6083. var queryResult []QueryResult
  6084. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6085. for _, item := range drugs {
  6086. result := QueryResult{
  6087. ID: item.ID,
  6088. Name: item.DrugName,
  6089. Code: item.MedicalInsuranceNumber,
  6090. List_type_code: "101",
  6091. }
  6092. queryResult = append(queryResult, result)
  6093. }
  6094. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6095. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6096. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6097. for _, item := range queryResult {
  6098. 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)
  6099. }
  6100. }
  6101. func (c *HisApiController) Goodcheck() {
  6102. admin_user_id, _ := c.GetInt64("admin_user_id")
  6103. adminUser := c.GetAdminUserInfo()
  6104. var queryResult []QueryResult
  6105. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6106. for _, item := range goods {
  6107. result := QueryResult{
  6108. ID: item.ID,
  6109. Name: item.GoodName,
  6110. Code: item.SocialSecurityDirectoryCode,
  6111. List_type_code: "301",
  6112. }
  6113. queryResult = append(queryResult, result)
  6114. }
  6115. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6116. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6117. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6118. for _, item := range queryResult {
  6119. 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)
  6120. //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)
  6121. }
  6122. }
  6123. func (c *HisApiController) Projectcheck() {
  6124. admin_user_id, _ := c.GetInt64("admin_user_id")
  6125. adminUser := c.GetAdminUserInfo()
  6126. var queryResult []QueryResult
  6127. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6128. for _, item := range projects {
  6129. result := QueryResult{
  6130. ID: item.ID,
  6131. Name: item.ProjectName,
  6132. Code: item.MedicalCode,
  6133. List_type_code: "201",
  6134. }
  6135. queryResult = append(queryResult, result)
  6136. }
  6137. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6138. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6139. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6140. for _, item := range queryResult {
  6141. 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)
  6142. }
  6143. }
  6144. //func (c *HisApiController)CancleDia(){
  6145. //
  6146. // id, _ := c.GetInt64("id")
  6147. // record_time := c.GetString("record_time")
  6148. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6149. //
  6150. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6151. //
  6152. // diagnosis_id := c.GetString("diagnosis")
  6153. // sick_type, _ := c.GetInt64("sick_type")
  6154. // reg_type, _ := c.GetInt64("p_type")
  6155. // begin_time := c.GetString("begin_time")
  6156. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6157. //
  6158. //
  6159. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6160. //
  6161. // fmt.Println(acct_used_flag)
  6162. //
  6163. //
  6164. // timeLayout := "2006-01-02"
  6165. // loc, _ := time.LoadLocation("Local")
  6166. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6167. // if err != nil {
  6168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6169. // return
  6170. // }
  6171. // recordDateTime := theTime.Unix()
  6172. // adminUser := c.GetAdminUserInfo()
  6173. //
  6174. //
  6175. //
  6176. //
  6177. //
  6178. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6179. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6180. // var patientPrescription models.HisPrescriptionInfo
  6181. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6182. // if patientPrescription.ID == 0 {
  6183. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6184. // }
  6185. // //if patientPrescription.Do
  6186. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6187. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6188. //
  6189. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6190. //
  6191. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6192. //
  6193. // var config []*models.HisXtDiagnoseConfig
  6194. // for _, item := range diagnosis_ids {
  6195. // id, _ := strconv.ParseInt(item, 10, 64)
  6196. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6197. // config = append(config, &diagnosisConfig)
  6198. // }
  6199. //
  6200. // sickConfig, _ := service.FindSickById(sick_type)
  6201. //
  6202. //
  6203. // data := make(map[string]interface{})
  6204. // client := &http.Client{}
  6205. // data["psn_no"] = his.PsnNo
  6206. // data["mdtrt_id"] = his.Number
  6207. // data["doctor"] = roles.UserName
  6208. // data["department"] = department.Name
  6209. // data["org_name"] = miConfig.OrgName
  6210. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6211. // data["doctor_id"] = doctor_info.DoctorNumber
  6212. // data["new_doctor_name"] = doctor_info.UserName
  6213. // data["fixmedins_code"] = miConfig.Code
  6214. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6215. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6216. // data["secret_key"] = miConfig.SecretKey
  6217. // data["sick_code"] = sickConfig.CountryCode
  6218. // data["sick_name"] = sickConfig.ClassName
  6219. // data["url"] = miConfig.Url
  6220. // data["ak"] = miConfig.AccessKey
  6221. // data["begin_time"] = begin_time
  6222. // data["cainfo"] = miConfig.Cainfo
  6223. // data["is_vaild"] = "0"
  6224. //
  6225. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6226. // data["config"] = config
  6227. // bytesData, _ := json.Marshal(data)
  6228. //
  6229. // var req *http.Request
  6230. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6231. // resp, _ := client.Do(req)
  6232. // defer resp.Body.Close()
  6233. // body, ioErr := ioutil.ReadAll(resp.Body)
  6234. // if ioErr != nil {
  6235. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6236. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6237. // return
  6238. // }
  6239. // var respJSON map[string]interface{}
  6240. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6241. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6242. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6243. // return
  6244. // }
  6245. //
  6246. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6247. // userJSONBytes, _ := json.Marshal(respJSON)
  6248. // fmt.Println("log")
  6249. // fmt.Println(string(userJSONBytes))
  6250. //
  6251. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6252. // utils.ErrorLog("解析失败:%v", err)
  6253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6254. // return
  6255. // }
  6256. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6257. // res2.Output = ressix10265.Output
  6258. // res2.ErrMsg = ressix10265.ErrMsg
  6259. // res2.Cainfo = ressix10265.Cainfo
  6260. // res2.WarnMsg = ressix10265.WarnMsg
  6261. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6262. // res2.Infcode = infocode
  6263. //
  6264. //}
  6265. func (c *HisApiController) Get4102() {
  6266. order_id, _ := c.GetInt64("order_id")
  6267. admin_user_id, _ := c.GetInt64("admin_user_id")
  6268. stas_type := c.GetString("stas_type")
  6269. order, _ := service.GetHisOrderByIDTwo(order_id)
  6270. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6271. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6272. var pp models.PublicParams
  6273. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6274. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6275. pp.FixmedinsName = miConfig.OrgName
  6276. pp.FixmedinsCode = miConfig.Code
  6277. pp.RequestUrl = miConfig.Url
  6278. pp.Cainfo = miConfig.Cainfo
  6279. pp.SecretKey = miConfig.SecretKey
  6280. pp.AccessKey = miConfig.AccessKey
  6281. pp.OpterName = curRoles.UserName
  6282. if miConfig.MdtrtareaAdmvs == "350500" {
  6283. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6284. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6285. saveLog(result, request, "4102", "清单确认")
  6286. var dat map[string]interface{}
  6287. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6288. fmt.Println(dat)
  6289. } else {
  6290. fmt.Println(err)
  6291. }
  6292. var empty ResultFourteen
  6293. userJSONBytes, _ := json.Marshal(dat)
  6294. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6295. utils.ErrorLog("解析失败:%v", err)
  6296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6297. return
  6298. }
  6299. if empty.Infcode == 0 {
  6300. c.ServeSuccessJSON(map[string]interface{}{
  6301. "msg": "确认成功",
  6302. })
  6303. return
  6304. }
  6305. } else {
  6306. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6307. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6308. result3, request3 := service.Jxyb4105(pp)
  6309. saveLog(result, request, "4102", "清单确认")
  6310. saveLog(result2, request2, "4103", "清单确认")
  6311. saveLog(result3, request3, "4105", "清单统计")
  6312. var dat map[string]interface{}
  6313. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6314. fmt.Println(dat)
  6315. } else {
  6316. fmt.Println(err)
  6317. }
  6318. var empty ResultFourteen
  6319. userJSONBytes, _ := json.Marshal(dat)
  6320. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6321. utils.ErrorLog("解析失败:%v", err)
  6322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6323. return
  6324. }
  6325. if empty.Infcode == 0 {
  6326. c.ServeSuccessJSON(map[string]interface{}{
  6327. "msg": "确认成功",
  6328. })
  6329. return
  6330. }
  6331. }
  6332. }
  6333. // 对账权限查询
  6334. func (c *HisApiController) Get3260() {
  6335. admin_user_id, _ := c.GetInt64("admin_user_id")
  6336. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6337. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6338. var api string
  6339. var res models.JSResult3260
  6340. if miConfig.MdtrtareaAdmvs == "320830" {
  6341. api = miConfig.AppSecret + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6342. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6343. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6344. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6345. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6346. } else {
  6347. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6348. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6349. }
  6350. resp, requestErr := http.Get(api)
  6351. if requestErr != nil {
  6352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6353. return
  6354. }
  6355. body, ioErr := ioutil.ReadAll(resp.Body)
  6356. if ioErr != nil {
  6357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6359. return
  6360. }
  6361. var respJSON map[string]interface{}
  6362. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6365. return
  6366. }
  6367. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6368. result, _ := json.Marshal(respJSON)
  6369. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6370. utils.ErrorLog("解析失败:%v", err)
  6371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6372. return
  6373. }
  6374. if res.Infcode == "0" {
  6375. c.ServeSuccessJSON(map[string]interface{}{
  6376. "result": res.Output.Data,
  6377. })
  6378. } else {
  6379. c.ServeSuccessJSON(map[string]interface{}{
  6380. "failed_code": -10,
  6381. "msg": res.ErrMsg,
  6382. })
  6383. return
  6384. }
  6385. }
  6386. func (c *HisApiController) Get3261() {
  6387. admin_user_id, _ := c.GetInt64("admin_user_id")
  6388. //month := c.GetString("month")
  6389. startTime := c.GetString("start_time")
  6390. //endTime, _ := c.GetString("end_time")
  6391. times := strings.Split(startTime, "-")
  6392. stmt_mon := times[0] + times[1]
  6393. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6394. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6395. var api string
  6396. var res models.JSResult3261
  6397. //var res10265 Result5301For10265
  6398. if miConfig.MdtrtareaAdmvs == "320830" {
  6399. api = miConfig.AppSecret + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6400. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6401. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6402. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6403. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6404. } else {
  6405. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6406. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6407. }
  6408. resp, requestErr := http.Get(api)
  6409. if requestErr != nil {
  6410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6411. return
  6412. }
  6413. body, ioErr := ioutil.ReadAll(resp.Body)
  6414. if ioErr != nil {
  6415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6417. return
  6418. }
  6419. var respJSON map[string]interface{}
  6420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6423. return
  6424. }
  6425. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6426. result, _ := json.Marshal(respJSON)
  6427. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6428. utils.ErrorLog("解析失败:%v", err)
  6429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6430. return
  6431. }
  6432. if res.Infcode == "0" {
  6433. c.ServeSuccessJSON(map[string]interface{}{
  6434. "result": res.Output,
  6435. })
  6436. } else {
  6437. c.ServeSuccessJSON(map[string]interface{}{
  6438. "failed_code": -10,
  6439. "msg": res.ErrMsg,
  6440. })
  6441. return
  6442. }
  6443. }
  6444. type TempFun struct {
  6445. FundKey string
  6446. FundCode string
  6447. }
  6448. func (c *HisApiController) Get3262() {
  6449. admin_user_id, _ := c.GetInt64("admin_user_id")
  6450. startTime := c.GetString("start_time")
  6451. endTime := c.GetString("end_time")
  6452. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6453. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6454. //timeLayout := "2006-01-02"
  6455. //loc, _ := time.LoadLocation("Local")
  6456. //var theStartTIme int64
  6457. //if len(startTime) > 0 {
  6458. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6459. // if err != nil {
  6460. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6461. // return
  6462. // }
  6463. // theStartTIme = theTime.Unix()
  6464. //}
  6465. //var theEndtTIme int64
  6466. //if len(endTime) > 0 {
  6467. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6468. // if err != nil {
  6469. // utils.ErrorLog(err.Error())
  6470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6471. // return
  6472. // }
  6473. // theEndtTIme = theTime.Unix()
  6474. //}
  6475. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6476. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6477. for _, team := range datas {
  6478. fmt.Println(team.PsnTime)
  6479. for _, team_two := range datas_two {
  6480. fmt.Println(team_two.PsnTime)
  6481. if team.FundKey == team_two.FundKey {
  6482. fmt.Println(team_two.PsnTime)
  6483. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6484. fmt.Println(team.PsnTime)
  6485. }
  6486. }
  6487. }
  6488. fmt.Println("1111")
  6489. fmt.Println(datas)
  6490. fmt.Println("1111")
  6491. var twos []models.FixMonRecDetailFileInTwo
  6492. for _, team := range datas {
  6493. var two models.FixMonRecDetailFileInTwo
  6494. two.MedType = team.MedType
  6495. two.Insutype = team.Insutype
  6496. two.PsnType = team.PsnType
  6497. two.MedType = team.MedType
  6498. two.FixBlngAdmdvs = "999999"
  6499. two.InsuAdmdvs = "555555"
  6500. two.PsnTime = team.PsnTime
  6501. two.PsnCnt = team.PsnCnt
  6502. two.FundKey = team.FundKey
  6503. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6504. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6505. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6506. two.MedfeeSumAmt = ms
  6507. two.InscpAmt = ia
  6508. two.FundPaySumAmt = fps
  6509. twos = append(twos, two)
  6510. }
  6511. //startTime := c.GetString("start_time")
  6512. //endTime, _ := c.GetString("end_time")
  6513. times := strings.Split(startTime, "-")
  6514. stmt_mon := times[0] + times[1]
  6515. var funs []models.FundDetail
  6516. for _, item := range datas {
  6517. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6518. funs = append(funs, fun...)
  6519. }
  6520. var funInfos []models.Fund
  6521. //for _, item := range funs {
  6522. // var rf []models.FundInfo
  6523. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6524. // for _, subitem := range rf {
  6525. // var fund models.Fund
  6526. // fund.FundCode = subitem.FundPayType
  6527. // fund.FundName = subitem.FundPayTypeName
  6528. // fund.FundAmt = subitem.FundPayAmt
  6529. // fund.FundKey = item.FundKey
  6530. // fund.InsuAdmdvs = "555555"
  6531. // fund.FixBlngAdmdvs = "999999"
  6532. // funInfos = append(funInfos, fund)
  6533. // }
  6534. //}
  6535. var tempFuns []TempFun
  6536. for _, funInfo := range funInfos {
  6537. var tempFun TempFun
  6538. tempFun.FundKey = funInfo.FundKey
  6539. tempFun.FundCode = funInfo.FundCode
  6540. tempFuns = append(tempFuns, tempFun)
  6541. }
  6542. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6543. fmt.Println(tempFuns)
  6544. var funInfosTwo []models.Fund
  6545. decimal.DivisionPrecision = 2
  6546. for _, item := range tempFuns {
  6547. var fund models.Fund
  6548. for _, subItem := range funInfos {
  6549. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6550. fund.FundKey = subItem.FundKey
  6551. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6552. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6553. fund.FundName = subItem.FundName
  6554. fund.FundCode = subItem.FundCode
  6555. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6556. }
  6557. }
  6558. funInfosTwo = append(funInfosTwo, fund)
  6559. }
  6560. fmt.Println("funInfosTwo")
  6561. fmt.Println(funInfosTwo)
  6562. var upld_btch string
  6563. var empty models.JSResultEmpty
  6564. data := make(map[string]interface{})
  6565. data["org_name"] = miConfig.OrgName
  6566. data["doctor"] = curRoles.UserName
  6567. data["doctor_name"] = curRoles.UserName
  6568. data["fixmedins_code"] = miConfig.Code
  6569. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6570. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6571. data["secret_key"] = miConfig.SecretKey
  6572. data["url"] = miConfig.Url
  6573. data["ak"] = miConfig.AccessKey
  6574. data["cainfo"] = miConfig.Cainfo
  6575. data["datas"] = twos
  6576. data["fund"] = funInfosTwo
  6577. fmt.Println(twos)
  6578. month := time.Unix(1557042972, 0).Format("1")
  6579. year := time.Now().Format("2006")
  6580. month = time.Now().Format("01")
  6581. day := time.Now().Format("02")
  6582. hour := time.Now().Format("15")
  6583. min := time.Now().Format("04")
  6584. sec := time.Now().Format("05")
  6585. fix_fill_date := year + month + day + hour + min + sec
  6586. data["fix_fill_dept"] = miConfig.OrgName
  6587. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6588. data["fix_fill_psn"] = curRoles.UserName
  6589. data["fix_fill_date"] = fix_fill_date
  6590. data["stmt_loc"] = "2"
  6591. data["setl_mon"] = stmt_mon
  6592. upld_btch = "0"
  6593. data["upld_btch"] = upld_btch
  6594. //fmt.Println(data)
  6595. client := &http.Client{}
  6596. bytesData, _ := json.Marshal(data)
  6597. var req *http.Request
  6598. if miConfig.MdtrtareaAdmvs == "320830" {
  6599. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3262", bytes.NewReader(bytesData))
  6600. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6601. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6602. } else {
  6603. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6604. }
  6605. resp, _ := client.Do(req)
  6606. defer resp.Body.Close()
  6607. body, ioErr := ioutil.ReadAll(resp.Body)
  6608. if ioErr != nil {
  6609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6611. }
  6612. var respJSON map[string]interface{}
  6613. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6616. }
  6617. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6618. //fmt.Println(respJSON)
  6619. result, _ := json.Marshal(respJSON)
  6620. //fmt.Println(result)
  6621. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6622. utils.ErrorLog("解析失败:%v", err)
  6623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6624. }
  6625. if empty.Infcode != "0" {
  6626. c.ServeSuccessJSON(map[string]interface{}{
  6627. "failed_code": -10,
  6628. "msg": empty.ErrMsg,
  6629. })
  6630. return
  6631. } else {
  6632. c.ServeSuccessJSON(map[string]interface{}{
  6633. "msg": "上传成功",
  6634. })
  6635. return
  6636. }
  6637. }
  6638. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6639. newArr = make([]TempFun, 0)
  6640. for i := 0; i < len(arr); i++ {
  6641. repeat := false
  6642. for j := i + 1; j < len(arr); j++ {
  6643. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6644. repeat = true
  6645. break
  6646. }
  6647. }
  6648. if !repeat {
  6649. newArr = append(newArr, arr[i])
  6650. }
  6651. }
  6652. return
  6653. }
  6654. func (c *HisApiController) Get3263() {
  6655. admin_user_id, _ := c.GetInt64("admin_user_id")
  6656. startTime := c.GetString("start_time")
  6657. //endTime, _ := c.GetString("end_time")
  6658. times := strings.Split(startTime, "-")
  6659. setl_mon := times[0] + times[1]
  6660. upld_btch := "0"
  6661. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6662. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6663. var result3263 models.JSResult3263
  6664. data := make(map[string]interface{})
  6665. data["org_name"] = miConfig.OrgName
  6666. data["doctor"] = curRoles.UserName
  6667. data["doctor_name"] = curRoles.UserName
  6668. data["fixmedins_code"] = miConfig.Code
  6669. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6670. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6671. data["secret_key"] = miConfig.SecretKey
  6672. data["url"] = miConfig.Url
  6673. data["ak"] = miConfig.AccessKey
  6674. data["cainfo"] = miConfig.Cainfo
  6675. data["setl_mon"] = setl_mon
  6676. data["stmt_loc"] = "2"
  6677. data["upld_btch"] = upld_btch
  6678. client := &http.Client{}
  6679. bytesData, _ := json.Marshal(data)
  6680. var req *http.Request
  6681. if miConfig.MdtrtareaAdmvs == "320830" {
  6682. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6683. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6684. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6685. } else {
  6686. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6687. }
  6688. resp, _ := client.Do(req)
  6689. defer resp.Body.Close()
  6690. body, ioErr := ioutil.ReadAll(resp.Body)
  6691. if ioErr != nil {
  6692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6694. }
  6695. var respJSON map[string]interface{}
  6696. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6699. }
  6700. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6701. fmt.Println(respJSON)
  6702. result, _ := json.Marshal(respJSON)
  6703. fmt.Println(result)
  6704. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6705. utils.ErrorLog("解析失败:%v", err)
  6706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6707. }
  6708. if result3263.Infcode != "0" {
  6709. c.ServeSuccessJSON(map[string]interface{}{
  6710. "failed_code": -10,
  6711. "msg": result3263.ErrMsg,
  6712. })
  6713. return
  6714. } else {
  6715. c.ServeSuccessJSON(map[string]interface{}{
  6716. "list": result3263.Output,
  6717. })
  6718. return
  6719. }
  6720. }
  6721. func (c *HisApiController) Get3264() {
  6722. admin_user_id, _ := c.GetInt64("admin_user_id")
  6723. startTime := c.GetString("start_time")
  6724. //endTime, _ := c.GetString("end_time")
  6725. times := strings.Split(startTime, "-")
  6726. setl_mon := times[0] + times[1]
  6727. upld_btch := "0"
  6728. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6729. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6730. //solidify_id := []
  6731. var result3263 models.JSResult3263
  6732. data := make(map[string]interface{})
  6733. data["org_name"] = miConfig.OrgName
  6734. data["doctor"] = curRoles.UserName
  6735. data["doctor_name"] = curRoles.UserName
  6736. data["fixmedins_code"] = miConfig.Code
  6737. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6738. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6739. data["secret_key"] = miConfig.SecretKey
  6740. data["url"] = miConfig.Url
  6741. data["ak"] = miConfig.AccessKey
  6742. data["cainfo"] = miConfig.Cainfo
  6743. data["setl_mon"] = setl_mon
  6744. data["stmt_loc"] = "2"
  6745. data["upld_btch"] = upld_btch
  6746. client := &http.Client{}
  6747. bytesData, _ := json.Marshal(data)
  6748. var req3263 *http.Request
  6749. if miConfig.MdtrtareaAdmvs == "320830" {
  6750. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6751. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6752. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6753. } else {
  6754. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6755. }
  6756. resp, _ := client.Do(req3263)
  6757. defer resp.Body.Close()
  6758. body, ioErr := ioutil.ReadAll(resp.Body)
  6759. if ioErr != nil {
  6760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6762. }
  6763. var respJSON3263 map[string]interface{}
  6764. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6767. }
  6768. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6769. fmt.Println(respJSON3263)
  6770. result, _ := json.Marshal(respJSON3263)
  6771. fmt.Println(result)
  6772. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6773. utils.ErrorLog("解析失败:%v", err)
  6774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6775. }
  6776. var ids []string
  6777. for _, item := range result3263.Output {
  6778. ids = append(ids, item.SolidifyID)
  6779. }
  6780. var empty models.JSResultEmpty
  6781. data2 := make(map[string]interface{})
  6782. data2["org_name"] = miConfig.OrgName
  6783. data2["doctor"] = curRoles.UserName
  6784. data2["doctor_name"] = curRoles.UserName
  6785. data2["fixmedins_code"] = miConfig.Code
  6786. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6787. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6788. data2["secret_key"] = miConfig.SecretKey
  6789. data2["url"] = miConfig.Url
  6790. data2["ak"] = miConfig.AccessKey
  6791. data2["cainfo"] = miConfig.Cainfo
  6792. data2["setl_mon"] = setl_mon
  6793. data2["stmt_loc"] = "2"
  6794. data2["upld_btch"] = upld_btch
  6795. data2["solidify_id"] = ids
  6796. client2 := &http.Client{}
  6797. bytesData2, _ := json.Marshal(data2)
  6798. var req *http.Request
  6799. if miConfig.MdtrtareaAdmvs == "320830" {
  6800. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3264", bytes.NewReader(bytesData))
  6801. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6802. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6803. } else {
  6804. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6805. }
  6806. resp2, _ := client2.Do(req)
  6807. defer resp.Body.Close()
  6808. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6809. if ioErr2 != nil {
  6810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6812. }
  6813. var respJSON map[string]interface{}
  6814. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6817. }
  6818. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6819. fmt.Println(respJSON)
  6820. result2, _ := json.Marshal(respJSON)
  6821. fmt.Println(result2)
  6822. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6823. utils.ErrorLog("解析失败:%v", err)
  6824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6825. }
  6826. if empty.Infcode != "0" {
  6827. c.ServeSuccessJSON(map[string]interface{}{
  6828. "failed_code": -10,
  6829. "msg": empty.ErrMsg,
  6830. })
  6831. return
  6832. } else {
  6833. c.ServeSuccessJSON(map[string]interface{}{
  6834. "msg": "",
  6835. })
  6836. return
  6837. }
  6838. }
  6839. func (c *HisApiController) Get3265() {
  6840. admin_user_id, _ := c.GetInt64("admin_user_id")
  6841. startTime := c.GetString("start_time")
  6842. //endTime, _ := c.GetString("end_time")
  6843. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6845. times := strings.Split(startTime, "-")
  6846. setl_mon := times[0] + times[1]
  6847. var upld_btch string
  6848. upld_btch = "0"
  6849. //var empty models.JSResultEmpty
  6850. var result3265 models.JSResult3264
  6851. var result3263 models.JSResult3263
  6852. data2 := make(map[string]interface{})
  6853. data2["org_name"] = miConfig.OrgName
  6854. data2["doctor"] = curRoles.UserName
  6855. data2["doctor_name"] = curRoles.UserName
  6856. data2["fixmedins_code"] = miConfig.Code
  6857. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6858. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6859. data2["secret_key"] = miConfig.SecretKey
  6860. data2["url"] = miConfig.Url
  6861. data2["ak"] = miConfig.AccessKey
  6862. data2["cainfo"] = miConfig.Cainfo
  6863. data2["setl_mon"] = setl_mon
  6864. data2["stmt_loc"] = "2"
  6865. data2["upld_btch"] = upld_btch
  6866. client2 := &http.Client{}
  6867. bytesData2, _ := json.Marshal(data2)
  6868. var req3263 *http.Request
  6869. if miConfig.MdtrtareaAdmvs == "320830" {
  6870. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData2))
  6871. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6872. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6873. } else {
  6874. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6875. }
  6876. resp2, _ := client2.Do(req3263)
  6877. defer resp2.Body.Close()
  6878. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6879. if ioErr2 != nil {
  6880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6882. }
  6883. var respJSON3263 map[string]interface{}
  6884. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6887. }
  6888. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6889. fmt.Println(respJSON3263)
  6890. result2, _ := json.Marshal(respJSON3263)
  6891. fmt.Println(result2)
  6892. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6893. utils.ErrorLog("解析失败:%v", err)
  6894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6895. }
  6896. var ids []string
  6897. for _, item := range result3263.Output {
  6898. ids = append(ids, item.SolidifyID)
  6899. }
  6900. data := make(map[string]interface{})
  6901. data["org_name"] = miConfig.OrgName
  6902. data["doctor"] = curRoles.UserName
  6903. data["doctor_name"] = curRoles.UserName
  6904. data["fixmedins_code"] = miConfig.Code
  6905. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6906. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6907. data["secret_key"] = miConfig.SecretKey
  6908. data["url"] = miConfig.Url
  6909. data["ak"] = miConfig.AccessKey
  6910. data["cainfo"] = miConfig.Cainfo
  6911. data["setl_mon"] = setl_mon
  6912. data["solidify_id"] = ids
  6913. month := time.Unix(1557042972, 0).Format("1")
  6914. year := time.Now().Format("2006")
  6915. month = time.Now().Format("01")
  6916. day := time.Now().Format("02")
  6917. hour := time.Now().Format("15")
  6918. min := time.Now().Format("04")
  6919. sec := time.Now().Format("05")
  6920. fix_fill_date := year + month + day + hour + min + sec
  6921. data["fix_fill_dept"] = miConfig.OrgName
  6922. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6923. data["fix_fill_psn"] = curRoles.UserName
  6924. data["fix_fill_date"] = fix_fill_date
  6925. data["stmt_loc"] = "2"
  6926. data["upld_btch"] = upld_btch
  6927. client := &http.Client{}
  6928. bytesData, _ := json.Marshal(data)
  6929. var req *http.Request
  6930. if miConfig.MdtrtareaAdmvs == "320830" {
  6931. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3265", bytes.NewReader(bytesData2))
  6932. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6933. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6934. } else {
  6935. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6936. }
  6937. resp, _ := client.Do(req)
  6938. defer resp.Body.Close()
  6939. body, ioErr := ioutil.ReadAll(resp.Body)
  6940. if ioErr != nil {
  6941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6943. }
  6944. var respJSON map[string]interface{}
  6945. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6948. }
  6949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6950. fmt.Println(respJSON)
  6951. result, _ := json.Marshal(respJSON)
  6952. fmt.Println(result)
  6953. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6954. utils.ErrorLog("解析失败:%v", err)
  6955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6956. }
  6957. if result3265.Infcode != "0" {
  6958. c.ServeSuccessJSON(map[string]interface{}{
  6959. "failed_code": -10,
  6960. "msg": result3265.ErrMsg,
  6961. })
  6962. return
  6963. } else {
  6964. c.ServeSuccessJSON(map[string]interface{}{
  6965. "info": result3265.Output,
  6966. })
  6967. return
  6968. }
  6969. }
  6970. func (c *HisApiController) Get3266() {
  6971. admin_user_id, _ := c.GetInt64("admin_user_id")
  6972. startTime := c.GetString("start_time")
  6973. //endTime, _ := c.GetString("end_time")
  6974. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6975. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6976. times := strings.Split(startTime, "-")
  6977. stmt_mon := times[0] + times[1]
  6978. var upld_btch string
  6979. //var empty models.JSResultEmpty
  6980. var result3265 models.JSResult3264
  6981. data := make(map[string]interface{})
  6982. data["org_name"] = miConfig.OrgName
  6983. data["doctor"] = curRoles.UserName
  6984. data["doctor_name"] = curRoles.UserName
  6985. data["fixmedins_code"] = miConfig.Code
  6986. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6987. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6988. data["secret_key"] = miConfig.SecretKey
  6989. data["url"] = miConfig.Url
  6990. data["ak"] = miConfig.AccessKey
  6991. data["cainfo"] = miConfig.Cainfo
  6992. data["setl_mon"] = stmt_mon
  6993. month := time.Unix(1557042972, 0).Format("1")
  6994. year := time.Now().Format("2006")
  6995. month = time.Now().Format("01")
  6996. day := time.Now().Format("02")
  6997. hour := time.Now().Format("15")
  6998. min := time.Now().Format("04")
  6999. sec := time.Now().Format("05")
  7000. fix_fill_date := year + month + day + hour + min + sec
  7001. data["fix_fill_dept"] = miConfig.OrgName
  7002. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7003. data["fix_fill_psn"] = curRoles.UserName
  7004. data["fix_fill_date"] = fix_fill_date
  7005. data["stmt_loc"] = "2"
  7006. upld_btch = "0"
  7007. data["upld_btch"] = upld_btch
  7008. client := &http.Client{}
  7009. bytesData, _ := json.Marshal(data)
  7010. var req *http.Request
  7011. if miConfig.MdtrtareaAdmvs == "320830" {
  7012. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3266", bytes.NewReader(bytesData))
  7013. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7014. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7015. } else {
  7016. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7017. }
  7018. resp, _ := client.Do(req)
  7019. defer resp.Body.Close()
  7020. body, ioErr := ioutil.ReadAll(resp.Body)
  7021. if ioErr != nil {
  7022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7024. }
  7025. var respJSON map[string]interface{}
  7026. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7029. }
  7030. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7031. fmt.Println(respJSON)
  7032. result, _ := json.Marshal(respJSON)
  7033. fmt.Println(result)
  7034. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7035. utils.ErrorLog("解析失败:%v", err)
  7036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7037. }
  7038. if result3265.Infcode != "0" {
  7039. c.ServeSuccessJSON(map[string]interface{}{
  7040. "failed_code": -10,
  7041. "msg": result3265.ErrMsg,
  7042. })
  7043. return
  7044. } else {
  7045. c.ServeSuccessJSON(map[string]interface{}{
  7046. "info": result3265.Output,
  7047. })
  7048. return
  7049. }
  7050. }
  7051. func (c *HisApiController) Get3267() {
  7052. admin_user_id, _ := c.GetInt64("admin_user_id")
  7053. startTime := c.GetString("start_time")
  7054. //endTime, _ := c.GetString("end_time")
  7055. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7056. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7057. times := strings.Split(startTime, "-")
  7058. setl_mon := times[0] + times[1]
  7059. var upld_btch string
  7060. //var empty models.JSResultEmpty
  7061. var result3265 models.JSResult3264
  7062. upld_btch = "0"
  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["stmt_loc"] = "2"
  7076. data["upld_btch"] = upld_btch
  7077. client := &http.Client{}
  7078. bytesData, _ := json.Marshal(data)
  7079. var req *http.Request
  7080. if miConfig.MdtrtareaAdmvs == "320830" {
  7081. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3267", bytes.NewReader(bytesData))
  7082. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7083. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7084. } else {
  7085. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7086. }
  7087. resp, _ := client.Do(req)
  7088. defer resp.Body.Close()
  7089. body, ioErr := ioutil.ReadAll(resp.Body)
  7090. if ioErr != nil {
  7091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7093. }
  7094. var respJSON map[string]interface{}
  7095. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7098. }
  7099. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7100. fmt.Println(respJSON)
  7101. result, _ := json.Marshal(respJSON)
  7102. fmt.Println(result)
  7103. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7104. utils.ErrorLog("解析失败:%v", err)
  7105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7106. }
  7107. if result3265.Infcode != "0" {
  7108. c.ServeSuccessJSON(map[string]interface{}{
  7109. "failed_code": -10,
  7110. "msg": result3265.ErrMsg,
  7111. })
  7112. return
  7113. } else {
  7114. c.ServeSuccessJSON(map[string]interface{}{
  7115. "info": result3265.Output.Data,
  7116. })
  7117. return
  7118. }
  7119. }
  7120. func (c *HisApiController) Get3268() {
  7121. admin_user_id, _ := c.GetInt64("admin_user_id")
  7122. startTime := c.GetString("start_time")
  7123. endTime := c.GetString("end_time")
  7124. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7125. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7126. times := strings.Split(startTime, "-")
  7127. setl_mon := times[0] + times[1]
  7128. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7129. var twos []models.FixMonRecDetailFileInTwo
  7130. var funs []models.FundDetail
  7131. for _, item := range datas {
  7132. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7133. funs = append(funs, fun...)
  7134. }
  7135. var funInfos []models.Fund
  7136. //for _, item := range funs {
  7137. // var rf []models.FundInfo
  7138. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7139. // for _, subitem := range rf {
  7140. // var fund models.Fund
  7141. // fund.FundCode = subitem.FundPayType
  7142. // fund.FundName = subitem.FundPayTypeName
  7143. // fund.FundAmt = subitem.FundPayAmt
  7144. // fund.FundKey = item.FundKey
  7145. // fund.InsuAdmdvs = "555555"
  7146. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7147. // funInfos = append(funInfos, fund)
  7148. // }
  7149. //}
  7150. for _, team := range datas {
  7151. var two models.FixMonRecDetailFileInTwo
  7152. two.SetlDate = time.Now().Format("2006-01-02")
  7153. two.MedType = team.MedType
  7154. two.Insutype = team.Insutype
  7155. two.PsnType = team.PsnType
  7156. two.MedType = team.MedType
  7157. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7158. two.InsuAdmdvs = team.InsuAdmdvs
  7159. two.PsnTime = team.PsnTime
  7160. two.PsnCnt = team.PsnCnt
  7161. two.FundKey = team.FundKey
  7162. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7163. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7164. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7165. two.MedfeeSumAmt = ms
  7166. two.InscpAmt = ia
  7167. two.FundPaySumAmt = fps
  7168. twos = append(twos, two)
  7169. }
  7170. var upld_btch string
  7171. upld_btch = "0"
  7172. var empty models.JSResultEmpty
  7173. data := make(map[string]interface{})
  7174. data["org_name"] = miConfig.OrgName
  7175. data["doctor"] = curRoles.UserName
  7176. data["doctor_name"] = curRoles.UserName
  7177. data["fixmedins_code"] = miConfig.Code
  7178. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7179. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7180. data["secret_key"] = miConfig.SecretKey
  7181. data["url"] = miConfig.Url
  7182. data["ak"] = miConfig.AccessKey
  7183. data["cainfo"] = miConfig.Cainfo
  7184. data["datas"] = twos
  7185. data["fund"] = funInfos
  7186. data["setl_mon"] = setl_mon
  7187. month := time.Unix(1557042972, 0).Format("1")
  7188. year := time.Now().Format("2006")
  7189. month = time.Now().Format("01")
  7190. day := time.Now().Format("02")
  7191. hour := time.Now().Format("15")
  7192. min := time.Now().Format("04")
  7193. sec := time.Now().Format("05")
  7194. fix_fill_date := year + month + day + hour + min + sec
  7195. data["fix_fill_dept"] = miConfig.OrgName
  7196. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7197. data["fix_fill_psn"] = curRoles.UserName
  7198. data["fix_fill_date"] = fix_fill_date
  7199. data["stmt_loc"] = "2"
  7200. data["upld_btch"] = upld_btch
  7201. client := &http.Client{}
  7202. bytesData, _ := json.Marshal(data)
  7203. var req *http.Request
  7204. if miConfig.MdtrtareaAdmvs == "320830" {
  7205. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3268", bytes.NewReader(bytesData))
  7206. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7207. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7208. } else {
  7209. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7210. }
  7211. resp, _ := client.Do(req)
  7212. defer resp.Body.Close()
  7213. body, ioErr := ioutil.ReadAll(resp.Body)
  7214. if ioErr != nil {
  7215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7217. }
  7218. var respJSON map[string]interface{}
  7219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7222. }
  7223. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7224. fmt.Println(respJSON)
  7225. result, _ := json.Marshal(respJSON)
  7226. fmt.Println(result)
  7227. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7228. utils.ErrorLog("解析失败:%v", err)
  7229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7230. }
  7231. if empty.Infcode != "0" {
  7232. c.ServeSuccessJSON(map[string]interface{}{
  7233. "failed_code": -10,
  7234. "msg": empty.ErrMsg,
  7235. })
  7236. return
  7237. } else {
  7238. c.ServeSuccessJSON(map[string]interface{}{
  7239. "msg": "上传成功",
  7240. })
  7241. return
  7242. }
  7243. }
  7244. func (c *HisApiController) Get3269() {
  7245. admin_user_id, _ := c.GetInt64("admin_user_id")
  7246. startTime := c.GetString("start_time")
  7247. //endTime, _ := c.GetString("end_time")
  7248. times := strings.Split(startTime, "-")
  7249. setl_mon := times[0] + times[1]
  7250. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7251. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7252. var result3263 models.JSResult3263
  7253. data := make(map[string]interface{})
  7254. data["org_name"] = miConfig.OrgName
  7255. data["doctor"] = curRoles.UserName
  7256. data["doctor_name"] = curRoles.UserName
  7257. data["fixmedins_code"] = miConfig.Code
  7258. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7259. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7260. data["secret_key"] = miConfig.SecretKey
  7261. data["url"] = miConfig.Url
  7262. data["ak"] = miConfig.AccessKey
  7263. data["cainfo"] = miConfig.Cainfo
  7264. data["setl_mon"] = setl_mon
  7265. data["stmt_loc"] = "2"
  7266. client := &http.Client{}
  7267. bytesData, _ := json.Marshal(data)
  7268. var req *http.Request
  7269. if miConfig.MdtrtareaAdmvs == "320830" {
  7270. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData))
  7271. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7272. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7273. } else {
  7274. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7275. }
  7276. resp, _ := client.Do(req)
  7277. defer resp.Body.Close()
  7278. body, ioErr := ioutil.ReadAll(resp.Body)
  7279. if ioErr != nil {
  7280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7282. }
  7283. var respJSON map[string]interface{}
  7284. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7287. }
  7288. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7289. fmt.Println(respJSON)
  7290. result, _ := json.Marshal(respJSON)
  7291. fmt.Println(result)
  7292. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7293. utils.ErrorLog("解析失败:%v", err)
  7294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7295. }
  7296. if result3263.Infcode != "0" {
  7297. c.ServeSuccessJSON(map[string]interface{}{
  7298. "failed_code": -10,
  7299. "msg": result3263.ErrMsg,
  7300. })
  7301. return
  7302. } else {
  7303. c.ServeSuccessJSON(map[string]interface{}{
  7304. "msg": "上传成功",
  7305. })
  7306. return
  7307. }
  7308. }
  7309. func (c *HisApiController) Get3270() {
  7310. admin_user_id, _ := c.GetInt64("admin_user_id")
  7311. startTime := c.GetString("start_time")
  7312. //endTime, _ := c.GetString("end_time")
  7313. times := strings.Split(startTime, "-")
  7314. setl_mon := times[0] + times[1]
  7315. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7316. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7317. var result3263 models.JSResult3263
  7318. data2 := make(map[string]interface{})
  7319. data2["org_name"] = miConfig.OrgName
  7320. data2["doctor"] = curRoles.UserName
  7321. data2["doctor_name"] = curRoles.UserName
  7322. data2["fixmedins_code"] = miConfig.Code
  7323. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7324. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7325. data2["secret_key"] = miConfig.SecretKey
  7326. data2["url"] = miConfig.Url
  7327. data2["ak"] = miConfig.AccessKey
  7328. data2["cainfo"] = miConfig.Cainfo
  7329. data2["setl_mon"] = setl_mon
  7330. data2["stmt_loc"] = "2"
  7331. client2 := &http.Client{}
  7332. bytesData2, _ := json.Marshal(data2)
  7333. var req3263 *http.Request
  7334. if miConfig.MdtrtareaAdmvs == "320830" {
  7335. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7336. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7337. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7338. } else {
  7339. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7340. }
  7341. resp2, _ := client2.Do(req3263)
  7342. defer resp2.Body.Close()
  7343. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7344. if ioErr2 != nil {
  7345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7347. }
  7348. var respJSON3263 map[string]interface{}
  7349. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7352. }
  7353. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7354. fmt.Println(respJSON3263)
  7355. result2, _ := json.Marshal(respJSON3263)
  7356. fmt.Println(result2)
  7357. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7358. utils.ErrorLog("解析失败:%v", err)
  7359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7360. }
  7361. var ids []string
  7362. for _, item := range result3263.Output {
  7363. ids = append(ids, item.SolidifyID)
  7364. }
  7365. var result3264 models.JSResult3264
  7366. data := make(map[string]interface{})
  7367. data["org_name"] = miConfig.OrgName
  7368. data["doctor"] = curRoles.UserName
  7369. data["doctor_name"] = curRoles.UserName
  7370. data["fixmedins_code"] = miConfig.Code
  7371. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7372. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7373. data["secret_key"] = miConfig.SecretKey
  7374. data["url"] = miConfig.Url
  7375. data["ak"] = miConfig.AccessKey
  7376. data["cainfo"] = miConfig.Cainfo
  7377. data["setl_mon"] = setl_mon
  7378. data["stmt_loc"] = "2"
  7379. data["solidify_id"] = ids
  7380. client := &http.Client{}
  7381. bytesData, _ := json.Marshal(data)
  7382. var req *http.Request
  7383. if miConfig.MdtrtareaAdmvs == "320830" {
  7384. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3270", bytes.NewReader(bytesData))
  7385. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7386. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7387. } else {
  7388. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7389. }
  7390. resp, _ := client.Do(req)
  7391. defer resp.Body.Close()
  7392. body, ioErr := ioutil.ReadAll(resp.Body)
  7393. if ioErr != nil {
  7394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7396. }
  7397. var respJSON map[string]interface{}
  7398. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7401. }
  7402. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7403. fmt.Println(respJSON)
  7404. result, _ := json.Marshal(respJSON)
  7405. fmt.Println(result)
  7406. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7407. utils.ErrorLog("解析失败:%v", err)
  7408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7409. }
  7410. if result3264.Infcode != "0" {
  7411. c.ServeSuccessJSON(map[string]interface{}{
  7412. "failed_code": -10,
  7413. "msg": result3264.ErrMsg,
  7414. })
  7415. return
  7416. } else {
  7417. c.ServeSuccessJSON(map[string]interface{}{
  7418. "info": result3264.Output,
  7419. })
  7420. return
  7421. }
  7422. }
  7423. func (c *HisApiController) Get3271() {
  7424. admin_user_id, _ := c.GetInt64("admin_user_id")
  7425. startTime := c.GetString("start_time")
  7426. //endTime, _ := c.GetString("end_time")
  7427. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7428. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7429. times := strings.Split(startTime, "-")
  7430. setl_mon := times[0] + times[1]
  7431. //var empty models.JSResultEmpty
  7432. var result3265 models.JSResult3264
  7433. var result3263 models.JSResult3263
  7434. data2 := make(map[string]interface{})
  7435. data2["org_name"] = miConfig.OrgName
  7436. data2["doctor"] = curRoles.UserName
  7437. data2["doctor_name"] = curRoles.UserName
  7438. data2["fixmedins_code"] = miConfig.Code
  7439. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7440. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7441. data2["secret_key"] = miConfig.SecretKey
  7442. data2["url"] = miConfig.Url
  7443. data2["ak"] = miConfig.AccessKey
  7444. data2["cainfo"] = miConfig.Cainfo
  7445. data2["setl_mon"] = setl_mon
  7446. data2["stmt_loc"] = "2"
  7447. client2 := &http.Client{}
  7448. bytesData2, _ := json.Marshal(data2)
  7449. var req3263 *http.Request
  7450. if miConfig.MdtrtareaAdmvs == "320830" {
  7451. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7452. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7453. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7454. } else {
  7455. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7456. }
  7457. resp2, _ := client2.Do(req3263)
  7458. defer resp2.Body.Close()
  7459. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7460. if ioErr2 != nil {
  7461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7463. }
  7464. var respJSON3263 map[string]interface{}
  7465. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7468. }
  7469. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7470. fmt.Println(respJSON3263)
  7471. result2, _ := json.Marshal(respJSON3263)
  7472. fmt.Println(result2)
  7473. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7474. utils.ErrorLog("解析失败:%v", err)
  7475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7476. }
  7477. var ids []string
  7478. for _, item := range result3263.Output {
  7479. ids = append(ids, item.SolidifyID)
  7480. }
  7481. data := make(map[string]interface{})
  7482. data["org_name"] = miConfig.OrgName
  7483. data["doctor"] = curRoles.UserName
  7484. data["doctor_name"] = curRoles.UserName
  7485. data["fixmedins_code"] = miConfig.Code
  7486. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7487. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7488. data["secret_key"] = miConfig.SecretKey
  7489. data["url"] = miConfig.Url
  7490. data["ak"] = miConfig.AccessKey
  7491. data["cainfo"] = miConfig.Cainfo
  7492. data["setl_mon"] = setl_mon
  7493. data["solidify_id"] = ids
  7494. month := time.Unix(1557042972, 0).Format("1")
  7495. year := time.Now().Format("2006")
  7496. month = time.Now().Format("01")
  7497. day := time.Now().Format("02")
  7498. hour := time.Now().Format("15")
  7499. min := time.Now().Format("04")
  7500. sec := time.Now().Format("05")
  7501. fix_fill_date := year + month + day + hour + min + sec
  7502. data["fix_fill_dept"] = miConfig.OrgName
  7503. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7504. data["fix_fill_psn"] = curRoles.UserName
  7505. data["fix_fill_date"] = fix_fill_date
  7506. data["stmt_loc"] = "2"
  7507. client := &http.Client{}
  7508. bytesData, _ := json.Marshal(data)
  7509. var req *http.Request
  7510. if miConfig.MdtrtareaAdmvs == "320830" {
  7511. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3271", bytes.NewReader(bytesData2))
  7512. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7513. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7514. } else {
  7515. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7516. }
  7517. resp, _ := client.Do(req)
  7518. defer resp.Body.Close()
  7519. body, ioErr := ioutil.ReadAll(resp.Body)
  7520. if ioErr != nil {
  7521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7523. }
  7524. var respJSON map[string]interface{}
  7525. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7528. }
  7529. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7530. fmt.Println(respJSON)
  7531. result, _ := json.Marshal(respJSON)
  7532. fmt.Println(result)
  7533. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7534. utils.ErrorLog("解析失败:%v", err)
  7535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7536. }
  7537. if result3265.Infcode != "0" {
  7538. c.ServeSuccessJSON(map[string]interface{}{
  7539. "failed_code": -10,
  7540. "msg": result3265.ErrMsg,
  7541. })
  7542. return
  7543. } else {
  7544. c.ServeSuccessJSON(map[string]interface{}{
  7545. "info": result3265.Output.Data,
  7546. })
  7547. return
  7548. }
  7549. }
  7550. func (c *HisApiController) Get3272() {
  7551. admin_user_id, _ := c.GetInt64("admin_user_id")
  7552. startTime := c.GetString("start_time")
  7553. //endTime, _ := c.GetString("end_time")
  7554. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7555. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7556. times := strings.Split(startTime, "-")
  7557. setl_mon := times[0] + times[1]
  7558. var upld_btch string
  7559. //var empty models.JSResultEmpty
  7560. var result3265 models.JSResult3264
  7561. data := make(map[string]interface{})
  7562. data["org_name"] = miConfig.OrgName
  7563. data["doctor"] = curRoles.UserName
  7564. data["doctor_name"] = curRoles.UserName
  7565. data["fixmedins_code"] = miConfig.Code
  7566. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7567. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7568. data["secret_key"] = miConfig.SecretKey
  7569. data["url"] = miConfig.Url
  7570. data["ak"] = miConfig.AccessKey
  7571. data["cainfo"] = miConfig.Cainfo
  7572. data["setl_mon"] = setl_mon
  7573. month := time.Unix(1557042972, 0).Format("1")
  7574. year := time.Now().Format("2006")
  7575. month = time.Now().Format("01")
  7576. day := time.Now().Format("02")
  7577. hour := time.Now().Format("15")
  7578. min := time.Now().Format("04")
  7579. sec := time.Now().Format("05")
  7580. fix_fill_date := year + month + day + hour + min + sec
  7581. data["fix_fill_dept"] = miConfig.OrgName
  7582. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7583. data["fix_fill_psn"] = curRoles.UserName
  7584. data["fix_fill_date"] = fix_fill_date
  7585. data["stmt_loc"] = "2"
  7586. data["upld_btch"] = upld_btch
  7587. client := &http.Client{}
  7588. bytesData, _ := json.Marshal(data)
  7589. var req *http.Request
  7590. if miConfig.MdtrtareaAdmvs == "320830" {
  7591. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3272", bytes.NewReader(bytesData))
  7592. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7593. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7594. } else {
  7595. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7596. }
  7597. resp, _ := client.Do(req)
  7598. defer resp.Body.Close()
  7599. body, ioErr := ioutil.ReadAll(resp.Body)
  7600. if ioErr != nil {
  7601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7603. }
  7604. var respJSON map[string]interface{}
  7605. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7608. }
  7609. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7610. fmt.Println(respJSON)
  7611. result, _ := json.Marshal(respJSON)
  7612. fmt.Println(result)
  7613. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7614. utils.ErrorLog("解析失败:%v", err)
  7615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7616. }
  7617. if result3265.Infcode != "0" {
  7618. c.ServeSuccessJSON(map[string]interface{}{
  7619. "failed_code": -10,
  7620. "msg": result3265.ErrMsg,
  7621. })
  7622. return
  7623. } else {
  7624. c.ServeSuccessJSON(map[string]interface{}{
  7625. "info": result3265.Output,
  7626. })
  7627. return
  7628. }
  7629. }
  7630. func (c *HisApiController) Get3273() {
  7631. admin_user_id, _ := c.GetInt64("admin_user_id")
  7632. startTime := c.GetString("start_time")
  7633. //endTime, _ := c.GetString("end_time")
  7634. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7635. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7636. times := strings.Split(startTime, "-")
  7637. setl_mon := times[0] + times[1]
  7638. var result3265 models.JSResult3264
  7639. data := make(map[string]interface{})
  7640. data["org_name"] = miConfig.OrgName
  7641. data["doctor"] = curRoles.UserName
  7642. data["doctor_name"] = curRoles.UserName
  7643. data["fixmedins_code"] = miConfig.Code
  7644. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7645. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7646. data["secret_key"] = miConfig.SecretKey
  7647. data["url"] = miConfig.Url
  7648. data["ak"] = miConfig.AccessKey
  7649. data["cainfo"] = miConfig.Cainfo
  7650. data["setl_mon"] = setl_mon
  7651. data["stmt_loc"] = "2"
  7652. client := &http.Client{}
  7653. bytesData, _ := json.Marshal(data)
  7654. var req *http.Request
  7655. if miConfig.MdtrtareaAdmvs == "320921" {
  7656. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7657. } else {
  7658. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7659. }
  7660. resp, _ := client.Do(req)
  7661. defer resp.Body.Close()
  7662. body, ioErr := ioutil.ReadAll(resp.Body)
  7663. if ioErr != nil {
  7664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7666. }
  7667. var respJSON map[string]interface{}
  7668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7671. }
  7672. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7673. fmt.Println(respJSON)
  7674. result, _ := json.Marshal(respJSON)
  7675. fmt.Println(result)
  7676. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7677. utils.ErrorLog("解析失败:%v", err)
  7678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7679. }
  7680. if result3265.Infcode != "0" {
  7681. c.ServeSuccessJSON(map[string]interface{}{
  7682. "failed_code": -10,
  7683. "msg": result3265.ErrMsg,
  7684. })
  7685. return
  7686. } else {
  7687. c.ServeSuccessJSON(map[string]interface{}{
  7688. "info": result3265.Output.Data,
  7689. })
  7690. return
  7691. }
  7692. }
  7693. func (c *HisApiController) Get3274() {
  7694. //if miConfig.MdtrtareaAdmvs == "320921" {
  7695. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7696. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7697. // "&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
  7698. //
  7699. //} else {
  7700. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7701. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7702. // "&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
  7703. //
  7704. //}
  7705. }
  7706. func (c *HisApiController) Get3275() {
  7707. //if miConfig.MdtrtareaAdmvs == "320921" {
  7708. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7709. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7710. // "&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
  7711. //
  7712. //} else {
  7713. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7714. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7715. // "&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
  7716. //
  7717. //}
  7718. }
  7719. func (c *HisApiController) Get3276() {
  7720. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7721. //month := c.GetString("month")
  7722. //
  7723. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7724. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7725. //var api string
  7726. //var res Result5301
  7727. //
  7728. //if miConfig.MdtrtareaAdmvs == "320921" {
  7729. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7730. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7731. //} else {
  7732. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7733. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7734. //}
  7735. //
  7736. //resp, requestErr := http.Get(api)
  7737. //if requestErr != nil {
  7738. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7739. // return
  7740. //}
  7741. //
  7742. //body, ioErr := ioutil.ReadAll(resp.Body)
  7743. //if ioErr != nil {
  7744. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7746. // return
  7747. //}
  7748. //var respJSON map[string]interface{}
  7749. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7750. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7752. // return
  7753. //}
  7754. //
  7755. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7756. //result, _ := json.Marshal(respJSON)
  7757. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7758. // utils.ErrorLog("解析失败:%v", err)
  7759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7760. // return
  7761. //}
  7762. }
  7763. func (c *HisApiController) Get3277() {
  7764. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7765. //month := c.GetString("month")
  7766. //
  7767. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7768. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7769. //var api string
  7770. //var res Result5301
  7771. //
  7772. //if miConfig.MdtrtareaAdmvs == "320921" {
  7773. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7774. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7775. //} else {
  7776. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7777. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7778. //}
  7779. //
  7780. //resp, requestErr := http.Get(api)
  7781. //if requestErr != nil {
  7782. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7783. // return
  7784. //}
  7785. //
  7786. //body, ioErr := ioutil.ReadAll(resp.Body)
  7787. //if ioErr != nil {
  7788. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7790. // return
  7791. //}
  7792. //var respJSON map[string]interface{}
  7793. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7794. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7796. // return
  7797. //}
  7798. //
  7799. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7800. //result, _ := json.Marshal(respJSON)
  7801. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7802. // utils.ErrorLog("解析失败:%v", err)
  7803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7804. // return
  7805. //}
  7806. }
  7807. func (c *HisApiController) GetCFYLJG001() {
  7808. admin_user_id, _ := c.GetInt64("admin_user_id")
  7809. patient_id, _ := c.GetInt64("patient_id")
  7810. his_patient_id, _ := c.GetInt64("his_patient_id")
  7811. record_time := c.GetString("record_time")
  7812. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7813. psn, _ := service.GetPsnByPatientId(patient_id)
  7814. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7815. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7816. var cFYLJG001 models.CFYLJG001
  7817. timeLayout := "2006-01-02"
  7818. loc, _ := time.LoadLocation("Local")
  7819. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7820. if err != nil {
  7821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7822. return
  7823. }
  7824. recordDateTime := theTime.Unix()
  7825. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7826. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7827. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7828. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7829. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7830. for _, item := range prescriptions {
  7831. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7832. if his.IdCardType == 1 {
  7833. bas := strings.Split(psn.CardInfo, "|")
  7834. basNumber := bas[1]
  7835. fmt.Println(basNumber)
  7836. card_sn := bas[3]
  7837. card_no := bas[2]
  7838. cFYLJG001.MdtrtCertType = "03"
  7839. cFYLJG001.CardSn = card_sn
  7840. cFYLJG001.MdtrtCertNo = card_no
  7841. cFYLJG001.EcToken = ""
  7842. cFYLJG001.AuthNo = ""
  7843. } else if his.IdCardType == 2 {
  7844. cFYLJG001.MdtrtCertType = "02"
  7845. cFYLJG001.CardSn = ""
  7846. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7847. cFYLJG001.EcToken = ""
  7848. cFYLJG001.AuthNo = ""
  7849. } else if his.IdCardType == 4 {
  7850. cFYLJG001.MdtrtCertType = "01"
  7851. cFYLJG001.CardSn = ""
  7852. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7853. cFYLJG001.EcToken = psn.VerifyNumber
  7854. cFYLJG001.AuthNo = ""
  7855. }
  7856. cFYLJG001.BizTypeCode = "01"
  7857. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7858. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7859. cFYLJG001.RxTypeCode = "1"
  7860. tempTime := time.Unix(item.PreTime, 0)
  7861. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7862. cFYLJG001.PrscTime = timeFormatOne
  7863. var count float64
  7864. if item.Type == 1 {
  7865. for _, sumItem := range item.HisDoctorAdviceInfo {
  7866. count = count + sumItem.PrescribingNumber
  7867. }
  7868. }
  7869. cFYLJG001.RxDrugCnt = count
  7870. cFYLJG001.ValiDays = "2"
  7871. ts := time.Unix(item.PreTime, 0)
  7872. record_time2 := ts.AddDate(0, 0, int(2)).Unix()
  7873. tempTime3 := time.Unix(record_time2, 0)
  7874. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7875. cFYLJG001.ValiEndTime = timeFormat3
  7876. cFYLJG001.RxCotnFlag = "0"
  7877. for _, subItem := range item.HisDoctorAdviceInfo {
  7878. var drug models.RxDrug
  7879. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7880. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7881. drug.RxItemTypeCode = "11"
  7882. drug.DrugDosform = "剂" //TODO
  7883. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7884. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7885. }
  7886. drug.MedcWayDscr = subItem.DeliveryWay
  7887. tempTime2 := time.Unix(subItem.StartTime, 0)
  7888. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7889. drug.MedcBegntime = timeFormatTwo
  7890. if subItem.Day > 0 {
  7891. ts := time.Unix(subItem.StartTime, 0)
  7892. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7893. tempTime4 := time.Unix(record_time, 0)
  7894. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7895. drug.MedcEndtime = timeFormat5
  7896. } else {
  7897. tempTime2 := time.Unix(subItem.StartTime, 0)
  7898. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7899. drug.MedcEndtime = timeFormatTwo
  7900. }
  7901. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7902. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7903. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7904. drug.DrugCnt = subItem.PrescribingNumber
  7905. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7906. drug.DrugGenname = subItem.AdviceName
  7907. drug.MedcWayCodg = subItem.DeliveryWay
  7908. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7909. drug.SinDoscnt = subItem.SingleDose
  7910. drug.SinDosunt = subItem.SingleDoseUnit
  7911. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7912. drug.UsedFrquName = subItem.ExecutionFrequency
  7913. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7914. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7915. drug.HospApprFlag = "1"
  7916. cFYLJG001.List = append(cFYLJG001.List, drug)
  7917. }
  7918. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7919. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  7920. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7921. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7922. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7923. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7924. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7925. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7926. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7927. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7928. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7929. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7930. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7931. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7932. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7933. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7934. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7935. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7936. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7937. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7938. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7939. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7940. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7941. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7942. tempTime2 := time.Now().Unix()
  7943. tempTime6 := time.Unix(tempTime2, 0)
  7944. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7945. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7946. cFYLJG001.Mdtrtinfo.DiseCodg = ""
  7947. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7948. cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
  7949. cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
  7950. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7951. var config []*models.HisXtDiagnoseConfig
  7952. for _, item := range diagnosis_ids {
  7953. id, _ := strconv.ParseInt(item, 10, 64)
  7954. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7955. config = append(config, &diagnosisConfig)
  7956. }
  7957. for index, subitem := range config {
  7958. if index == 0 {
  7959. var dia models.DiseInfo
  7960. dia.DiagType = "1"
  7961. dia.MaindiagFlag = "1"
  7962. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7963. dia.DiagCode = subitem.CountryCode
  7964. dia.DiagName = subitem.ClassName
  7965. dia.DiagDept = "肾内科"
  7966. dia.DiagDrNo = doctor.DoctorNumber
  7967. dia.DiagDrName = doctor.UserName
  7968. tempTime3 := time.Unix(item.PreTime, 0)
  7969. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7970. dia.DiagTime = timeFormatTwo
  7971. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7972. } else {
  7973. var dia models.DiseInfo
  7974. dia.DiagType = "1"
  7975. dia.MaindiagFlag = "0"
  7976. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7977. dia.DiagCode = subitem.CountryCode
  7978. dia.DiagName = subitem.ClassName
  7979. dia.DiagDept = "肾内科"
  7980. dia.DiagDrNo = doctor.DoctorNumber
  7981. dia.DiagDrName = doctor.UserName
  7982. tempTime3 := time.Unix(item.PreTime, 0)
  7983. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7984. dia.DiagTime = timeFormatTwo
  7985. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7986. }
  7987. }
  7988. if miConfig.MdtrtareaAdmvs == "340699" {
  7989. result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
  7990. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7991. var res ResultCFYLJG001AH
  7992. var respJSON2 map[string]interface{}
  7993. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7996. return
  7997. }
  7998. userJSONBytes2, _ := json.Marshal(respJSON2)
  7999. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8000. utils.ErrorLog("解析失败:%v", err)
  8001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8002. return
  8003. }
  8004. var flow models.HisPrescriptionFlow
  8005. flow.Ctime = time.Now().Unix()
  8006. flow.SignDigest = ""
  8007. flow.RxTraceCode = res.RxTraceCode
  8008. flow.HiRxno = res.HiRxno
  8009. flow.MID = his.Number
  8010. flow.Status = 1
  8011. flow.DCode = doctor_info.DoctorNumber
  8012. flow.OriginalRxFile = ""
  8013. flow.OriginalValue = ""
  8014. flow.SignCertDn = ""
  8015. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8016. flow.SignCertSn = ""
  8017. flow.Mtime = time.Now().Unix()
  8018. service.Createflow(&flow)
  8019. c.ServeSuccessJSON(map[string]interface{}{
  8020. "msg": "上传成功",
  8021. })
  8022. } else {
  8023. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  8024. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8025. var res ResultCFYLJG001
  8026. var respJSON2 map[string]interface{}
  8027. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8030. return
  8031. }
  8032. userJSONBytes2, _ := json.Marshal(respJSON2)
  8033. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8034. utils.ErrorLog("解析失败:%v", err)
  8035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8036. return
  8037. }
  8038. if res.Infcode == -1 {
  8039. c.ServeSuccessJSON(map[string]interface{}{
  8040. "failed_code": -10,
  8041. "msg": res.ErrMsg,
  8042. })
  8043. return
  8044. } else {
  8045. var flow models.HisPrescriptionFlow
  8046. flow.Ctime = time.Now().Unix()
  8047. flow.SignDigest = ""
  8048. flow.RxTraceCode = res.Output.RxTraceCode
  8049. flow.HiRxno = res.Output.HiRxno
  8050. flow.MID = his.Number
  8051. flow.Status = 1
  8052. flow.DCode = doctor_info.DoctorNumber
  8053. flow.OriginalRxFile = ""
  8054. flow.OriginalValue = ""
  8055. flow.SignCertDn = ""
  8056. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8057. flow.SignCertSn = ""
  8058. flow.Mtime = time.Now().Unix()
  8059. service.Createflow(&flow)
  8060. c.ServeSuccessJSON(map[string]interface{}{
  8061. "msg": "上传成功",
  8062. })
  8063. }
  8064. }
  8065. }
  8066. }
  8067. func (c *HisApiController) GetCFYLJG12() {
  8068. admin_user_id, _ := c.GetInt64("admin_user_id")
  8069. his_patient_id, _ := c.GetInt64("his_patient_id")
  8070. record_time := c.GetString("record_time")
  8071. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8072. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8073. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8074. flow, _ := service.Getflowtwo(his.Number)
  8075. patient_id, _ := c.GetInt64("patient_id")
  8076. timeLayout := "2006-01-02"
  8077. loc, _ := time.LoadLocation("Local")
  8078. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8079. if err != nil {
  8080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8081. return
  8082. }
  8083. recordDateTime := theTime.Unix()
  8084. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8085. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8086. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8087. dept, _ := service.GetDepartMentDetail(info.Departments)
  8088. inputData := make(map[string]interface{})
  8089. inputData["rxTraceCode"] = flow.RxTraceCode
  8090. inputData["hiRxno"] = flow.HiRxno
  8091. inputData["mdtrtId"] = flow.MID
  8092. inputData["patnName"] = his.PsnName
  8093. inputData["psnCertType"] = his.PsnCertType
  8094. inputData["certno"] = his.Certno
  8095. inputData["fixmedinsName"] = miConfig.OrgName
  8096. inputData["fixmedinsCode"] = miConfig.Code
  8097. inputData["drCode"] = doctor_info.DoctorNumber
  8098. inputData["prscDrName"] = doctor_info.UserName
  8099. inputData["pharDeptName"] = dept.Name
  8100. inputData["pharDeptCode"] = dept.Number
  8101. inputData["pharProfttlCodg"] = ""
  8102. inputData["pharProfttlName"] = ""
  8103. inputData["pharCode"] = "HY340621000425"
  8104. inputData["pharCertType"] = "01"
  8105. inputData["pharCertno"] = ""
  8106. inputData["pharName"] = "孙莉侠"
  8107. inputData["pharPracCertNo"] = ""
  8108. tempTime2 := time.Unix(info.Ctime, 0)
  8109. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8110. inputData["pharChkTime"] = timeFormatTwo
  8111. bytesData, _ := json.Marshal(inputData)
  8112. fmt.Println(string(bytesData))
  8113. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8114. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8115. if err != nil {
  8116. fmt.Println("Error reading PDF file:", err)
  8117. return
  8118. }
  8119. // 将 PDF 文件内容进行 Base64 编码
  8120. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8121. fmt.Println(err)
  8122. if miConfig.MdtrtareaAdmvs == "340699" {
  8123. data := make(map[string]interface{})
  8124. data["rx_encoded"] = rx_encoded
  8125. data["code"] = miConfig.Code
  8126. data["url"] = "http://10.66.149.64:8080/epc/api"
  8127. data["encoded"] = encoded
  8128. client := &http.Client{}
  8129. bytesData, _ := json.Marshal(data)
  8130. var req *http.Request
  8131. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/02", bytes.NewReader(bytesData))
  8132. resp, _ := client.Do(req)
  8133. defer resp.Body.Close()
  8134. body, ioErr := ioutil.ReadAll(resp.Body)
  8135. if ioErr != nil {
  8136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8137. }
  8138. var respJSON map[string]interface{}
  8139. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8142. return
  8143. }
  8144. var resSix10265 ResultSix10265 //1101结果
  8145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8146. result, _ := json.Marshal(respJSON)
  8147. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8148. utils.ErrorLog("解析失败:%v", err)
  8149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8150. return
  8151. }
  8152. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8153. //saveLog(result, "", "GetCFYLJG002", "GetCFYLJG002")
  8154. } else {
  8155. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8156. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8157. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8158. var res2 AhResult002
  8159. var respJSON2 map[string]interface{}
  8160. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8163. return
  8164. }
  8165. userJSONBytes2, _ := json.Marshal(respJSON2)
  8166. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8167. utils.ErrorLog("解析失败:%v", err)
  8168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8169. return
  8170. }
  8171. flow.Ctime = time.Now().Unix()
  8172. flow.SignDigest = res2.SignDigest
  8173. flow.RxFile = res2.RxFile
  8174. flow.MID = his.Number
  8175. flow.Status = 1
  8176. flow.DCode = doctor_info.DoctorNumber
  8177. flow.OriginalRxFile = rx_encoded
  8178. flow.OriginalValue = encoded
  8179. flow.SignCertDn = res2.SignCertDn
  8180. flow.SignCertSn = res2.SignCertSn
  8181. flow.Mtime = time.Now().Unix()
  8182. service.Saveflow(flow)
  8183. c.ServeSuccessJSON(map[string]interface{}{
  8184. "msg": "预签名成功",
  8185. })
  8186. }
  8187. }
  8188. func (c *HisApiController) GetCFYLJG13() {
  8189. admin_user_id, _ := c.GetInt64("admin_user_id")
  8190. his_patient_id, _ := c.GetInt64("his_patient_id")
  8191. record_time := c.GetString("record_time")
  8192. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8193. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8194. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8195. flow, _ := service.Getflowtwo(his.Number)
  8196. patient_id, _ := c.GetInt64("patient_id")
  8197. timeLayout := "2006-01-02"
  8198. loc, _ := time.LoadLocation("Local")
  8199. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8200. if err != nil {
  8201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8202. return
  8203. }
  8204. recordDateTime := theTime.Unix()
  8205. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8206. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8207. dept, _ := service.GetDepartMentDetail(info.Departments)
  8208. var cFYLJG003 models.CFYLJG003
  8209. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8210. cFYLJG003.HiRxno = flow.HiRxno
  8211. cFYLJG003.MdtrtID = flow.MID
  8212. cFYLJG003.PatnName = his.Name
  8213. cFYLJG003.Certno = his.Certno
  8214. cFYLJG003.FixmedinsName = miConfig.OrgName
  8215. cFYLJG003.FixmedinsCode = miConfig.Code
  8216. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8217. cFYLJG003.PrscDrName = doctor_info.UserName
  8218. cFYLJG003.PharDeptName = dept.Name
  8219. cFYLJG003.PharDeptCode = dept.Number
  8220. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8221. cFYLJG003.PharName = "孙莉侠"
  8222. cFYLJG003.PharPracCertNo = "060399"
  8223. cFYLJG003.PharCode = "HY340621000425"
  8224. cFYLJG003.PharCertType = "01"
  8225. cFYLJG003.PharCertno = ""
  8226. } else {
  8227. cFYLJG003.PharName = "彭斯遥"
  8228. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8229. cFYLJG003.PharCode = "HY440309002107"
  8230. cFYLJG003.PharCertType = "01"
  8231. cFYLJG003.PharCertno = "430482199408260023"
  8232. }
  8233. cFYLJG003.PsnCertType = "01"
  8234. cFYLJG003.RxFile = flow.RxFile
  8235. cFYLJG003.SignDigest = flow.SignDigest
  8236. cFYLJG003.FixmedinsCode = miConfig.Code
  8237. cFYLJG003.PsnCertType = "01"
  8238. cFYLJG003.PharProfttlCodg = dept.Name
  8239. tempTime2 := time.Unix(info.Ctime, 0)
  8240. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8241. cFYLJG003.PharChkTime = timeFormatTwo
  8242. if miConfig.MdtrtareaAdmvs == "340699" {
  8243. data := make(map[string]interface{})
  8244. data["url"] = "http://10.66.149.64:8080/epc/api"
  8245. data["13"] = cFYLJG003
  8246. client := &http.Client{}
  8247. bytesData, _ := json.Marshal(data)
  8248. var req *http.Request
  8249. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/03", bytes.NewReader(bytesData))
  8250. resp, _ := client.Do(req)
  8251. defer resp.Body.Close()
  8252. body, ioErr := ioutil.ReadAll(resp.Body)
  8253. if ioErr != nil {
  8254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8255. }
  8256. var respJSON map[string]interface{}
  8257. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8260. return
  8261. }
  8262. var resSix10265 ResultSix10265 //1101结果
  8263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8264. result, _ := json.Marshal(respJSON)
  8265. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8266. utils.ErrorLog("解析失败:%v", err)
  8267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8268. return
  8269. }
  8270. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8271. //saveLog(result, "", "GetCFYLJG013", "GetCFYLJG013")
  8272. } else {
  8273. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8274. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8275. var res ResultCFYLJG003
  8276. var respJSON2 map[string]interface{}
  8277. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8280. return
  8281. }
  8282. userJSONBytes2, _ := json.Marshal(respJSON2)
  8283. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8284. utils.ErrorLog("解析失败:%v", err)
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8286. return
  8287. }
  8288. if res.Infcode == -1 {
  8289. c.ServeSuccessJSON(map[string]interface{}{
  8290. "failed_code": -10,
  8291. "msg": res.ErrMsg,
  8292. })
  8293. return
  8294. } else {
  8295. c.ServeSuccessJSON(map[string]interface{}{
  8296. "info": res.Output,
  8297. })
  8298. }
  8299. }
  8300. }
  8301. func (c *HisApiController) GetCFYLJG002() {
  8302. admin_user_id, _ := c.GetInt64("admin_user_id")
  8303. his_patient_id, _ := c.GetInt64("his_patient_id")
  8304. record_time := c.GetString("record_time")
  8305. admin_user_id = 3626
  8306. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8307. //id, _ := c.GetInt64("id")
  8308. admin_user_id = 3626
  8309. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8310. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8311. flow, _ := service.Getflowtwo(his.Number)
  8312. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8313. //record_time := c.GetString("record_time")
  8314. patient_id, _ := c.GetInt64("patient_id")
  8315. //patient_id = 23834
  8316. //record_time = "2023-09-18"
  8317. timeLayout := "2006-01-02"
  8318. loc, _ := time.LoadLocation("Local")
  8319. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8320. if err != nil {
  8321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8322. return
  8323. }
  8324. recordDateTime := theTime.Unix()
  8325. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8326. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8327. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8328. dept, _ := service.GetDepartMentDetail(info.Departments)
  8329. inputData := make(map[string]interface{})
  8330. inputData["rxTraceCode"] = flow.RxTraceCode
  8331. inputData["hiRxno"] = flow.HiRxno
  8332. inputData["mdtrtId"] = flow.MID
  8333. inputData["patnName"] = his.PsnName
  8334. inputData["psnCertType"] = his.PsnCertType
  8335. inputData["certno"] = his.Certno
  8336. inputData["fixmedinsName"] = miConfig.OrgName
  8337. inputData["fixmedinsCode"] = miConfig.Code
  8338. inputData["drCode"] = doctor_info.DoctorNumber
  8339. inputData["prscDrName"] = doctor_info.UserName
  8340. inputData["pharDeptName"] = dept.Name
  8341. inputData["pharDeptCode"] = dept.Number
  8342. inputData["pharProfttlCodg"] = ""
  8343. inputData["pharProfttlName"] = ""
  8344. inputData["pharCode"] = "HY340621000425"
  8345. inputData["pharCertType"] = "01"
  8346. inputData["pharCertno"] = ""
  8347. inputData["pharName"] = "孙莉侠"
  8348. inputData["pharPracCertNo"] = "060399"
  8349. tempTime2 := time.Unix(info.Ctime, 0)
  8350. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8351. inputData["pharChkTime"] = timeFormatTwo
  8352. bytesData, _ := json.Marshal(inputData)
  8353. fmt.Println(string(bytesData))
  8354. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8355. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8356. if err != nil {
  8357. fmt.Println("Error reading PDF file:", err)
  8358. return
  8359. }
  8360. // 将 PDF 文件内容进行 Base64 编码
  8361. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8362. fmt.Println(err)
  8363. if miConfig.MdtrtareaAdmvs == "340699" {
  8364. result, request := service.GetAHCFYLJG002(miConfig.Code, "http://10.66.149.64:8080/epc/api", encoded, rx_encoded, "")
  8365. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8366. var res2 AhResult002
  8367. var respJSON2 map[string]interface{}
  8368. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8371. return
  8372. }
  8373. userJSONBytes2, _ := json.Marshal(respJSON2)
  8374. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8375. utils.ErrorLog("解析失败:%v", err)
  8376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8377. return
  8378. }
  8379. flow.Ctime = time.Now().Unix()
  8380. flow.SignDigest = res2.SignDigest
  8381. flow.RxFile = res2.RxFile
  8382. flow.MID = his.Number
  8383. flow.Status = 1
  8384. flow.DCode = doctor_info.DoctorNumber
  8385. flow.OriginalRxFile = rx_encoded
  8386. flow.OriginalValue = encoded
  8387. flow.SignCertDn = res2.SignCertDn
  8388. flow.SignCertSn = res2.SignCertSn
  8389. flow.Mtime = time.Now().Unix()
  8390. service.Saveflow(flow)
  8391. c.ServeSuccessJSON(map[string]interface{}{
  8392. "msg": "预签名成功",
  8393. })
  8394. } else {
  8395. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8396. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8397. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8398. var res2 Result002
  8399. var respJSON2 map[string]interface{}
  8400. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8403. return
  8404. }
  8405. userJSONBytes2, _ := json.Marshal(respJSON2)
  8406. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8407. utils.ErrorLog("解析失败:%v", err)
  8408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8409. return
  8410. }
  8411. if res2.Infcode == 0 {
  8412. flow.Ctime = time.Now().Unix()
  8413. flow.SignDigest = res2.Output.SignDigest
  8414. flow.RxFile = res2.Output.RxFile
  8415. flow.MID = his.Number
  8416. flow.Status = 1
  8417. flow.DCode = doctor_info.DoctorNumber
  8418. flow.OriginalRxFile = rx_encoded
  8419. flow.OriginalValue = encoded
  8420. flow.SignCertDn = res2.Output.SignCertDn
  8421. flow.SignCertSn = res2.Output.SignCertSn
  8422. flow.Mtime = time.Now().Unix()
  8423. service.Saveflow(flow)
  8424. c.ServeSuccessJSON(map[string]interface{}{
  8425. "msg": "预签名成功",
  8426. })
  8427. } else {
  8428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8429. return
  8430. }
  8431. }
  8432. }
  8433. func (c *HisApiController) GetCFYLJG003() {
  8434. admin_user_id, _ := c.GetInt64("admin_user_id")
  8435. his_patient_id, _ := c.GetInt64("his_patient_id")
  8436. record_time := c.GetString("record_time")
  8437. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8438. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8439. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8440. flow, _ := service.Getflowtwo(his.Number)
  8441. patient_id, _ := c.GetInt64("patient_id")
  8442. timeLayout := "2006-01-02"
  8443. loc, _ := time.LoadLocation("Local")
  8444. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8445. if err != nil {
  8446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8447. return
  8448. }
  8449. recordDateTime := theTime.Unix()
  8450. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8451. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8452. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8453. dept, _ := service.GetDepartMentDetail(info.Departments)
  8454. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8455. var cFYLJG003 models.CFYLJG003
  8456. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8457. cFYLJG003.HiRxno = flow.HiRxno
  8458. cFYLJG003.MdtrtID = flow.MID
  8459. cFYLJG003.PatnName = his.PsnName
  8460. cFYLJG003.Certno = his.Certno
  8461. cFYLJG003.FixmedinsName = miConfig.OrgName
  8462. cFYLJG003.FixmedinsCode = miConfig.Code
  8463. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8464. cFYLJG003.PrscDrName = doctor_info.UserName
  8465. cFYLJG003.PharDeptName = dept.Name
  8466. cFYLJG003.PharDeptCode = dept.Number
  8467. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8468. cFYLJG003.PharName = "孙莉侠"
  8469. cFYLJG003.PharPracCertNo = "060399"
  8470. cFYLJG003.PharCode = "HY340621000425"
  8471. cFYLJG003.PharCertType = "01"
  8472. cFYLJG003.PharCertno = ""
  8473. } else {
  8474. cFYLJG003.PharName = "彭斯遥"
  8475. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8476. cFYLJG003.PharCode = "HY440309002107"
  8477. cFYLJG003.PharCertType = "01"
  8478. cFYLJG003.PharCertno = "430482199408260023"
  8479. }
  8480. cFYLJG003.RxFile = flow.RxFile
  8481. cFYLJG003.SignDigest = flow.SignDigest
  8482. cFYLJG003.FixmedinsCode = miConfig.Code
  8483. cFYLJG003.PsnCertType = his.PsnCertType
  8484. tempTime2 := time.Unix(info.Ctime, 0)
  8485. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8486. cFYLJG003.PharChkTime = timeFormatTwo
  8487. if miConfig.MdtrtareaAdmvs == "340699" {
  8488. result, request := service.GetAHCFYLJG003("http://10.66.149.64:8080/epc/api", cFYLJG003)
  8489. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  8490. var res AHResult003
  8491. var respJSON2 map[string]interface{}
  8492. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8495. return
  8496. }
  8497. userJSONBytes2, _ := json.Marshal(respJSON2)
  8498. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8499. utils.ErrorLog("解析失败:%v", err)
  8500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8501. return
  8502. }
  8503. {
  8504. c.ServeSuccessJSON(map[string]interface{}{
  8505. "info": res,
  8506. })
  8507. }
  8508. } else {
  8509. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8510. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8511. var res ResultCFYLJG003
  8512. var respJSON2 map[string]interface{}
  8513. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8516. return
  8517. }
  8518. userJSONBytes2, _ := json.Marshal(respJSON2)
  8519. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8520. utils.ErrorLog("解析失败:%v", err)
  8521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8522. return
  8523. }
  8524. if res.Infcode == -1 {
  8525. c.ServeSuccessJSON(map[string]interface{}{
  8526. "failed_code": -10,
  8527. "msg": res.ErrMsg,
  8528. })
  8529. return
  8530. } else {
  8531. c.ServeSuccessJSON(map[string]interface{}{
  8532. "info": res.Output,
  8533. })
  8534. }
  8535. }
  8536. }
  8537. func (c *HisApiController) GetCFYLJG004() {
  8538. admin_user_id, _ := c.GetInt64("admin_user_id")
  8539. his_patient_id, _ := c.GetInt64("his_patient_id")
  8540. record_time := c.GetString("record_time")
  8541. admin_user_id = 3626
  8542. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8543. //id, _ := c.GetInt64("id")
  8544. admin_user_id = 3626
  8545. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8546. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8547. flow, _ := service.Getflowtwo(his.Number)
  8548. //id = 3
  8549. patient_id, _ := c.GetInt64("patient_id")
  8550. //patient_id = 23834
  8551. //record_time = "2023-09-18"
  8552. timeLayout := "2006-01-02"
  8553. loc, _ := time.LoadLocation("Local")
  8554. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8555. if err != nil {
  8556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8557. return
  8558. }
  8559. recordDateTime := theTime.Unix()
  8560. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8561. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8562. var cFYLJG004 models.CFYLJG004
  8563. cFYLJG004.HiRxno = flow.HiRxno
  8564. cFYLJG004.FixmedinsCode = miConfig.Code
  8565. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8566. cFYLJG004.UndoDrCertType = "01"
  8567. cFYLJG004.UndoRea = "撤销处方"
  8568. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8569. cFYLJG004.UndoDrName = doctor_info.UserName
  8570. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8571. if miConfig.MdtrtareaAdmvs == "340699" {
  8572. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8573. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8574. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  8575. } else {
  8576. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8577. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8578. var res ResultCFYLJG004
  8579. var respJSON2 map[string]interface{}
  8580. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8583. return
  8584. }
  8585. userJSONBytes2, _ := json.Marshal(respJSON2)
  8586. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8587. utils.ErrorLog("解析失败:%v", err)
  8588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8589. return
  8590. }
  8591. if res.Infcode == -1 {
  8592. c.ServeSuccessJSON(map[string]interface{}{
  8593. "failed_code": -10,
  8594. "msg": res.ErrMsg,
  8595. })
  8596. return
  8597. } else {
  8598. flow.Status = 0
  8599. service.Saveflow(flow)
  8600. c.ServeSuccessJSON(map[string]interface{}{
  8601. "msg": "撤销成功",
  8602. })
  8603. return
  8604. }
  8605. }
  8606. }
  8607. func (c *HisApiController) GetCFYLJG005() {
  8608. admin_user_id, _ := c.GetInt64("admin_user_id")
  8609. his_patient_id, _ := c.GetInt64("his_patient_id")
  8610. //record_time := c.GetString("record_time")
  8611. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8612. //id, _ := c.GetInt64("id")
  8613. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8614. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8615. flow, _ := service.Getflowtwo(his.Number)
  8616. //id = 3
  8617. var cFYLJG005 models.CFYLJG005
  8618. //patient_id, _ := c.GetInt64("patient_id")
  8619. cFYLJG005.HiRxno = flow.HiRxno
  8620. cFYLJG005.MdtrtID = flow.MID
  8621. cFYLJG005.EcToken = ""
  8622. cFYLJG005.PsnName = his.Name
  8623. cFYLJG005.PsnCertType = "01"
  8624. cFYLJG005.Certno = his.IdCardNo
  8625. if miConfig.MdtrtareaAdmvs == "340699" {
  8626. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8627. result, request := service.GetAHCFYLJG005(miConfig.Code, cFYLJG005)
  8628. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8629. } else {
  8630. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8631. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8632. var res ResultCFYLJG005
  8633. var respJSON2 map[string]interface{}
  8634. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8637. return
  8638. }
  8639. userJSONBytes2, _ := json.Marshal(respJSON2)
  8640. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8641. utils.ErrorLog("解析失败:%v", err)
  8642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8643. return
  8644. }
  8645. if res.Infcode == -1 {
  8646. c.ServeSuccessJSON(map[string]interface{}{
  8647. "failed_code": -10,
  8648. "msg": res.ErrMsg,
  8649. })
  8650. return
  8651. } else {
  8652. c.ServeSuccessJSON(map[string]interface{}{
  8653. "info": res.Output,
  8654. })
  8655. return
  8656. }
  8657. }
  8658. }
  8659. func (c *HisApiController) GetCFYLJG006() {
  8660. admin_user_id, _ := c.GetInt64("admin_user_id")
  8661. his_patient_id, _ := c.GetInt64("his_patient_id")
  8662. admin_user_id = 3626
  8663. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8664. //id, _ := c.GetInt64("id")
  8665. admin_user_id = 3626
  8666. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8667. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8668. flow, _ := service.Getflowtwo(his.Number)
  8669. //id = 3
  8670. patient_id, _ := c.GetInt64("patient_id")
  8671. var cFYLJG006 models.CFYLJG006
  8672. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8673. cFYLJG006.HiRxno = flow.HiRxno
  8674. cFYLJG006.MdtrtID = flow.MID
  8675. cFYLJG006.PsnName = patient.Name
  8676. cFYLJG006.PsnCertType = "01"
  8677. cFYLJG006.Certno = patient.IdCardNo
  8678. if miConfig.MdtrtareaAdmvs == "340699" {
  8679. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8680. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8681. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8682. } else {
  8683. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8684. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8685. var res ResultCFYLJG006
  8686. var respJSON2 map[string]interface{}
  8687. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8690. return
  8691. }
  8692. userJSONBytes2, _ := json.Marshal(respJSON2)
  8693. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8694. utils.ErrorLog("解析失败:%v", err)
  8695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8696. return
  8697. }
  8698. if res.Infcode == -1 {
  8699. c.ServeSuccessJSON(map[string]interface{}{
  8700. "failed_code": -10,
  8701. "msg": res.ErrMsg,
  8702. })
  8703. return
  8704. } else {
  8705. c.ServeSuccessJSON(map[string]interface{}{
  8706. "info": res.Output,
  8707. })
  8708. return
  8709. }
  8710. }
  8711. }
  8712. func (c *HisApiController) GetCFYLJG007() {
  8713. admin_user_id, _ := c.GetInt64("admin_user_id")
  8714. his_patient_id, _ := c.GetInt64("his_patient_id")
  8715. admin_user_id = 3626
  8716. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8717. //id, _ := c.GetInt64("id")
  8718. admin_user_id = 3626
  8719. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8720. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8721. flow, _ := service.Getflowtwo(his.Number)
  8722. //id = 3
  8723. patient_id, _ := c.GetInt64("patient_id")
  8724. var cFYLJG007 models.CFYLJG007
  8725. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8726. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8727. cFYLJG007.HiRxno = flow.HiRxno
  8728. cFYLJG007.MdtrtID = flow.MID
  8729. cFYLJG007.PsnNo = his.PsnNo
  8730. cFYLJG007.PsnCertType = "01"
  8731. cFYLJG007.Certno = patient.IdCardNo
  8732. cFYLJG007.PsnName = patient.Name
  8733. if miConfig.MdtrtareaAdmvs == "340699" {
  8734. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8735. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8736. } else {
  8737. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8738. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8739. var res ResultCFYLJG007
  8740. var respJSON2 map[string]interface{}
  8741. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8744. return
  8745. }
  8746. userJSONBytes2, _ := json.Marshal(respJSON2)
  8747. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8748. utils.ErrorLog("解析失败:%v", err)
  8749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8750. return
  8751. }
  8752. if res.Infcode == -1 {
  8753. c.ServeSuccessJSON(map[string]interface{}{
  8754. "failed_code": -10,
  8755. "msg": res.ErrMsg,
  8756. })
  8757. return
  8758. } else {
  8759. c.ServeSuccessJSON(map[string]interface{}{
  8760. "info": res,
  8761. })
  8762. return
  8763. }
  8764. }
  8765. }
  8766. func (c *HisApiController) GetCFYLJG008() {
  8767. admin_user_id, _ := c.GetInt64("admin_user_id")
  8768. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8769. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8770. var cFYLJG008 models.CFYLJG008
  8771. //id, _ := c.GetInt64("id")
  8772. patient_id, _ := c.GetInt64("patient_id")
  8773. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8774. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8775. //id = 3
  8776. //flow, _ := service.Getflow(id)
  8777. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8778. //
  8779. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8780. //patient_id, _ := c.GetInt64("patient_id")
  8781. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8782. record_time := c.GetString("record_time")
  8783. admin_user_id = 3626
  8784. patient_id = 19424
  8785. //his_patient_id = 263947
  8786. record_time = "2023-08-29"
  8787. timeLayout := "2006-01-02"
  8788. loc, _ := time.LoadLocation("Local")
  8789. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8790. if err != nil {
  8791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8792. return
  8793. }
  8794. recordDateTime := theTime.Unix()
  8795. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8796. cFYLJG008.FixmedinsName = ""
  8797. cFYLJG008.Lat = ""
  8798. cFYLJG008.Lng = ""
  8799. cFYLJG008.OrderType = "1"
  8800. cFYLJG008.PoolareaNo = ""
  8801. cFYLJG008.Lng = ""
  8802. cFYLJG008.PageNum = 1
  8803. cFYLJG008.PageSize = 10
  8804. var MPI models.MedinsProdInvChgDDTO
  8805. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8806. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8807. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8808. if miConfig.MdtrtareaAdmvs == "340699" {
  8809. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8810. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8811. } else {
  8812. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8813. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8814. var res ResultCFYLJG008
  8815. var respJSON2 map[string]interface{}
  8816. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8819. return
  8820. }
  8821. userJSONBytes2, _ := json.Marshal(respJSON2)
  8822. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8823. utils.ErrorLog("解析失败:%v", err)
  8824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8825. return
  8826. }
  8827. if res.Infcode == -1 {
  8828. c.ServeSuccessJSON(map[string]interface{}{
  8829. "failed_code": -10,
  8830. "msg": res.ErrMsg,
  8831. })
  8832. return
  8833. } else {
  8834. c.ServeSuccessJSON(map[string]interface{}{
  8835. "info": res.Output,
  8836. })
  8837. return
  8838. }
  8839. }
  8840. }
  8841. func (c *HisApiController) GetBL4201A() {
  8842. order_id, _ := c.GetInt64("order_id")
  8843. admin_user_id, _ := c.GetInt64("admin_user_id")
  8844. order, _ := service.GetHisOrderByIDTwo(order_id)
  8845. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8846. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8847. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8848. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8849. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8850. department, _ := service.GetDepartMentDetail(his.Departments)
  8851. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8852. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8853. if order.ID == 0 {
  8854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8855. return
  8856. }
  8857. var struct4201A models.Struct4201A
  8858. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8859. for _, items := range order_info {
  8860. memo := make(map[string]interface{})
  8861. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8862. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8863. fsiOPFLD.MedType = "14"
  8864. fsiOPFLD.BkkpSn = items.FeedetlSn
  8865. fsiOPFLD.FixmedinsCode = miConfig.Code
  8866. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8867. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8868. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8869. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8870. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8871. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8872. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8873. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8874. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8875. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8876. fsiOPFLD.BilgDeptName = department.Name
  8877. fsiOPFLD.BilgDeptCodg = department.Number
  8878. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8879. fsiOPFLD.BilgDrName = doctor.UserName
  8880. fsiOPFLD.MedChrgitmType = "09"
  8881. memo["hosp_appr_flag"] = "1"
  8882. memo["invoice_no"] = order.MdtrtId
  8883. memo["memo"] = "自费"
  8884. bytesData, _ := json.Marshal(memo)
  8885. fsiOPFLD.Memo = string(bytesData)
  8886. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8887. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8888. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8889. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8890. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8891. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8892. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8893. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8894. fsiOPFLD.BilgDeptName = department.Name
  8895. fsiOPFLD.BilgDeptCodg = department.Number
  8896. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8897. fsiOPFLD.BilgDrName = doctor.UserName
  8898. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8899. case 0:
  8900. break
  8901. case 1:
  8902. fsiOPFLD.MedChrgitmType = "14"
  8903. break
  8904. case 2:
  8905. fsiOPFLD.MedChrgitmType = "05"
  8906. break
  8907. case 3:
  8908. fsiOPFLD.MedChrgitmType = "03"
  8909. break
  8910. case 4:
  8911. fsiOPFLD.MedChrgitmType = "03"
  8912. break
  8913. case 5:
  8914. fsiOPFLD.MedChrgitmType = "08"
  8915. break
  8916. case 6:
  8917. fsiOPFLD.MedChrgitmType = "14"
  8918. break
  8919. case 7:
  8920. fsiOPFLD.MedChrgitmType = "14"
  8921. break
  8922. case 8:
  8923. fsiOPFLD.MedChrgitmType = "03"
  8924. break
  8925. case 9:
  8926. fsiOPFLD.MedChrgitmType = "14"
  8927. break
  8928. case 10:
  8929. fsiOPFLD.MedChrgitmType = "14"
  8930. break
  8931. case 11:
  8932. fsiOPFLD.MedChrgitmType = "06"
  8933. break
  8934. case 12:
  8935. fsiOPFLD.MedChrgitmType = "12"
  8936. break
  8937. case 13:
  8938. fsiOPFLD.MedChrgitmType = "01"
  8939. break
  8940. case 14:
  8941. fsiOPFLD.MedChrgitmType = "04"
  8942. break
  8943. case 15:
  8944. fsiOPFLD.MedChrgitmType = "14"
  8945. break
  8946. }
  8947. memo["hosp_appr_flag"] = "1"
  8948. memo["invoice_no"] = order.MdtrtId
  8949. memo["memo"] = "自费"
  8950. bytesData, _ := json.Marshal(memo)
  8951. fsiOPFLD.Memo = string(bytesData)
  8952. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8953. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8954. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8955. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8956. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8957. fsiOPFLD.BilgDeptName = department.Name
  8958. fsiOPFLD.BilgDeptCodg = department.Number
  8959. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8960. fsiOPFLD.BilgDrName = doctor.UserName
  8961. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8962. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8963. fsiOPFLD.MedChrgitmType = "08"
  8964. memo["hosp_appr_flag"] = "1"
  8965. memo["invoice_no"] = order.MdtrtId
  8966. memo["memo"] = "自费"
  8967. bytesData, _ := json.Marshal(memo)
  8968. fsiOPFLD.Memo = string(bytesData)
  8969. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8970. }
  8971. }
  8972. }
  8973. for _, items := range order_info_two {
  8974. memo := make(map[string]interface{})
  8975. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8976. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8977. fsiOPFLD.MedType = "14"
  8978. fsiOPFLD.BkkpSn = items.FeedetlSn
  8979. fsiOPFLD.FixmedinsCode = miConfig.Code
  8980. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8981. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8982. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8983. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8984. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8985. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8986. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8987. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8988. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8989. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8990. fsiOPFLD.BilgDeptName = department.Name
  8991. fsiOPFLD.BilgDeptCodg = department.Number
  8992. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8993. fsiOPFLD.BilgDrName = doctor.UserName
  8994. fsiOPFLD.MedChrgitmType = "09"
  8995. memo["hosp_appr_flag"] = "1"
  8996. memo["invoice_no"] = order.MdtrtId
  8997. memo["memo"] = "自费"
  8998. bytesData, _ := json.Marshal(memo)
  8999. fsiOPFLD.Memo = string(bytesData)
  9000. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9001. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9002. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9003. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9004. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9005. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9006. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9007. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9008. fsiOPFLD.BilgDeptName = department.Name
  9009. fsiOPFLD.BilgDeptCodg = department.Number
  9010. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9011. fsiOPFLD.BilgDrName = doctor.UserName
  9012. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9013. case 0:
  9014. break
  9015. case 1:
  9016. fsiOPFLD.MedChrgitmType = "14"
  9017. break
  9018. case 2:
  9019. fsiOPFLD.MedChrgitmType = "05"
  9020. break
  9021. case 3:
  9022. fsiOPFLD.MedChrgitmType = "03"
  9023. break
  9024. case 4:
  9025. fsiOPFLD.MedChrgitmType = "03"
  9026. break
  9027. case 5:
  9028. fsiOPFLD.MedChrgitmType = "08"
  9029. break
  9030. case 6:
  9031. fsiOPFLD.MedChrgitmType = "14"
  9032. break
  9033. case 7:
  9034. fsiOPFLD.MedChrgitmType = "14"
  9035. break
  9036. case 8:
  9037. fsiOPFLD.MedChrgitmType = "03"
  9038. break
  9039. case 9:
  9040. fsiOPFLD.MedChrgitmType = "14"
  9041. break
  9042. case 10:
  9043. fsiOPFLD.MedChrgitmType = "14"
  9044. break
  9045. case 11:
  9046. fsiOPFLD.MedChrgitmType = "06"
  9047. break
  9048. case 12:
  9049. fsiOPFLD.MedChrgitmType = "12"
  9050. break
  9051. case 13:
  9052. fsiOPFLD.MedChrgitmType = "01"
  9053. break
  9054. case 14:
  9055. fsiOPFLD.MedChrgitmType = "04"
  9056. break
  9057. case 15:
  9058. fsiOPFLD.MedChrgitmType = "14"
  9059. break
  9060. }
  9061. memo["hosp_appr_flag"] = "1"
  9062. memo["invoice_no"] = order.MdtrtId
  9063. memo["memo"] = "自费"
  9064. bytesData, _ := json.Marshal(memo)
  9065. fsiOPFLD.Memo = string(bytesData)
  9066. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9067. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9068. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9069. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9070. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9071. fsiOPFLD.BilgDeptName = department.Name
  9072. fsiOPFLD.BilgDeptCodg = department.Number
  9073. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9074. fsiOPFLD.BilgDrName = doctor.UserName
  9075. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9076. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9077. fsiOPFLD.MedChrgitmType = "08"
  9078. memo["hosp_appr_flag"] = "1"
  9079. memo["invoice_no"] = order.MdtrtId
  9080. memo["memo"] = "自费"
  9081. bytesData, _ := json.Marshal(memo)
  9082. fsiOPFLD.Memo = string(bytesData)
  9083. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9084. }
  9085. }
  9086. }
  9087. fmt.Println(fsiOPFLDs)
  9088. struct4201A.Fopfd = fsiOPFLDs
  9089. fmt.Println(struct4201A.Fopfd)
  9090. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9091. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9092. var res2 ResultSix
  9093. var respJSON2 map[string]interface{}
  9094. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9097. return
  9098. }
  9099. userJSONBytes2, _ := json.Marshal(respJSON2)
  9100. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9101. utils.ErrorLog("解析失败:%v", err)
  9102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9103. return
  9104. }
  9105. if res2.Infcode != 0 {
  9106. c.ServeSuccessJSON(map[string]interface{}{
  9107. "failed_code": -10,
  9108. "msg": res2.ErrMsg,
  9109. })
  9110. return
  9111. } else {
  9112. order.IsUploadOrderInfo = 1
  9113. service.UpdateOrder(order)
  9114. c.ServeSuccessJSON(map[string]interface{}{
  9115. "msg": "上传成功",
  9116. })
  9117. }
  9118. }
  9119. func (c *HisApiController) Get3103() {
  9120. admin_user_id, _ := c.GetInt64("admin_user_id")
  9121. warm_type, _ := c.GetInt64("warm_type")
  9122. fk_state, _ := c.GetInt64("fk_state")
  9123. warm_ids := c.GetString("warm_ids")
  9124. desc := c.GetString("desc")
  9125. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9126. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9127. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  9128. saveLog(result, requestLog, "3103", "反馈")
  9129. var res2 ResultSix3103
  9130. var respJSON2 map[string]interface{}
  9131. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9134. return
  9135. }
  9136. userJSONBytes2, _ := json.Marshal(respJSON2)
  9137. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9138. utils.ErrorLog("解析失败:%v", err)
  9139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9140. return
  9141. }
  9142. if res2.Infcode != 0 {
  9143. c.ServeSuccessJSON(map[string]interface{}{
  9144. "failed_code": -10,
  9145. "msg": res2.ErrMsg,
  9146. })
  9147. return
  9148. } else {
  9149. c.ServeSuccessJSON(map[string]interface{}{
  9150. "msg": "反馈成功",
  9151. })
  9152. return
  9153. }
  9154. }
  9155. func (c *HisApiController) Get4201A() {
  9156. order_id, _ := c.GetInt64("order_id")
  9157. admin_user_id, _ := c.GetInt64("admin_user_id")
  9158. order, _ := service.GetHisOrderByIDTwo(order_id)
  9159. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9160. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9161. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9162. //order_info = append(order_info, order_info_two...)
  9163. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9164. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9165. department, _ := service.GetDepartMentDetail(his.Departments)
  9166. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9167. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9168. if order.ID == 0 {
  9169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9170. return
  9171. }
  9172. var struct4201A models.Struct4201A
  9173. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9174. for _, items := range order_info {
  9175. memo := make(map[string]interface{})
  9176. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9177. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9178. fsiOPFLD.MedType = "14"
  9179. fsiOPFLD.BkkpSn = items.FeedetlSn
  9180. fsiOPFLD.FixmedinsCode = miConfig.Code
  9181. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9182. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9183. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9184. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9185. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9186. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9187. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9188. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9189. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9190. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9191. fsiOPFLD.BilgDeptName = department.Name
  9192. fsiOPFLD.BilgDeptCodg = department.Number
  9193. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9194. fsiOPFLD.BilgDrName = doctor.UserName
  9195. fsiOPFLD.MedChrgitmType = "09"
  9196. memo["hosp_appr_flag"] = "1"
  9197. memo["invoice_no"] = order.MdtrtId
  9198. memo["memo"] = "自费"
  9199. bytesData, _ := json.Marshal(memo)
  9200. fsiOPFLD.Memo = string(bytesData)
  9201. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9202. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9203. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9204. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9205. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9206. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9207. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9208. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9209. fsiOPFLD.BilgDeptName = department.Name
  9210. fsiOPFLD.BilgDeptCodg = department.Number
  9211. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9212. fsiOPFLD.BilgDrName = doctor.UserName
  9213. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9214. case 0:
  9215. break
  9216. case 1:
  9217. fsiOPFLD.MedChrgitmType = "14"
  9218. break
  9219. case 2:
  9220. fsiOPFLD.MedChrgitmType = "05"
  9221. break
  9222. case 3:
  9223. fsiOPFLD.MedChrgitmType = "03"
  9224. break
  9225. case 4:
  9226. fsiOPFLD.MedChrgitmType = "03"
  9227. break
  9228. case 5:
  9229. fsiOPFLD.MedChrgitmType = "08"
  9230. break
  9231. case 6:
  9232. fsiOPFLD.MedChrgitmType = "14"
  9233. break
  9234. case 7:
  9235. fsiOPFLD.MedChrgitmType = "14"
  9236. break
  9237. case 8:
  9238. fsiOPFLD.MedChrgitmType = "03"
  9239. break
  9240. case 9:
  9241. fsiOPFLD.MedChrgitmType = "14"
  9242. break
  9243. case 10:
  9244. fsiOPFLD.MedChrgitmType = "14"
  9245. break
  9246. case 11:
  9247. fsiOPFLD.MedChrgitmType = "06"
  9248. break
  9249. case 12:
  9250. fsiOPFLD.MedChrgitmType = "12"
  9251. break
  9252. case 13:
  9253. fsiOPFLD.MedChrgitmType = "01"
  9254. break
  9255. case 14:
  9256. fsiOPFLD.MedChrgitmType = "04"
  9257. break
  9258. case 15:
  9259. fsiOPFLD.MedChrgitmType = "14"
  9260. break
  9261. }
  9262. memo["hosp_appr_flag"] = "1"
  9263. memo["invoice_no"] = order.MdtrtId
  9264. memo["memo"] = "自费"
  9265. bytesData, _ := json.Marshal(memo)
  9266. fsiOPFLD.Memo = string(bytesData)
  9267. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9268. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9269. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9270. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9271. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9272. fsiOPFLD.BilgDeptName = department.Name
  9273. fsiOPFLD.BilgDeptCodg = department.Number
  9274. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9275. fsiOPFLD.BilgDrName = doctor.UserName
  9276. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9277. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9278. fsiOPFLD.MedChrgitmType = "08"
  9279. memo["hosp_appr_flag"] = "1"
  9280. memo["invoice_no"] = order.MdtrtId
  9281. memo["memo"] = "自费"
  9282. bytesData, _ := json.Marshal(memo)
  9283. fsiOPFLD.Memo = string(bytesData)
  9284. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9285. }
  9286. }
  9287. }
  9288. for _, items := range order_info_two {
  9289. memo := make(map[string]interface{})
  9290. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9291. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9292. fsiOPFLD.MedType = "14"
  9293. fsiOPFLD.BkkpSn = items.FeedetlSn
  9294. fsiOPFLD.FixmedinsCode = miConfig.Code
  9295. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9296. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9297. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9298. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9299. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9300. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9301. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9302. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9303. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9304. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9305. fsiOPFLD.BilgDeptName = department.Name
  9306. fsiOPFLD.BilgDeptCodg = department.Number
  9307. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9308. fsiOPFLD.BilgDrName = doctor.UserName
  9309. fsiOPFLD.MedChrgitmType = "09"
  9310. memo["hosp_appr_flag"] = "1"
  9311. memo["invoice_no"] = order.MdtrtId
  9312. memo["memo"] = "自费"
  9313. bytesData, _ := json.Marshal(memo)
  9314. fsiOPFLD.Memo = string(bytesData)
  9315. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9316. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9317. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9318. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9319. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9320. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9321. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9322. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9323. fsiOPFLD.BilgDeptName = department.Name
  9324. fsiOPFLD.BilgDeptCodg = department.Number
  9325. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9326. fsiOPFLD.BilgDrName = doctor.UserName
  9327. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9328. case 0:
  9329. break
  9330. case 1:
  9331. fsiOPFLD.MedChrgitmType = "14"
  9332. break
  9333. case 2:
  9334. fsiOPFLD.MedChrgitmType = "05"
  9335. break
  9336. case 3:
  9337. fsiOPFLD.MedChrgitmType = "03"
  9338. break
  9339. case 4:
  9340. fsiOPFLD.MedChrgitmType = "03"
  9341. break
  9342. case 5:
  9343. fsiOPFLD.MedChrgitmType = "08"
  9344. break
  9345. case 6:
  9346. fsiOPFLD.MedChrgitmType = "14"
  9347. break
  9348. case 7:
  9349. fsiOPFLD.MedChrgitmType = "14"
  9350. break
  9351. case 8:
  9352. fsiOPFLD.MedChrgitmType = "03"
  9353. break
  9354. case 9:
  9355. fsiOPFLD.MedChrgitmType = "14"
  9356. break
  9357. case 10:
  9358. fsiOPFLD.MedChrgitmType = "14"
  9359. break
  9360. case 11:
  9361. fsiOPFLD.MedChrgitmType = "06"
  9362. break
  9363. case 12:
  9364. fsiOPFLD.MedChrgitmType = "12"
  9365. break
  9366. case 13:
  9367. fsiOPFLD.MedChrgitmType = "01"
  9368. break
  9369. case 14:
  9370. fsiOPFLD.MedChrgitmType = "04"
  9371. break
  9372. case 15:
  9373. fsiOPFLD.MedChrgitmType = "14"
  9374. break
  9375. }
  9376. memo["hosp_appr_flag"] = "1"
  9377. memo["invoice_no"] = order.MdtrtId
  9378. memo["memo"] = "自费"
  9379. bytesData, _ := json.Marshal(memo)
  9380. fsiOPFLD.Memo = string(bytesData)
  9381. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9382. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9383. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9384. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9385. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9386. fsiOPFLD.BilgDeptName = department.Name
  9387. fsiOPFLD.BilgDeptCodg = department.Number
  9388. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9389. fsiOPFLD.BilgDrName = doctor.UserName
  9390. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9391. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9392. fsiOPFLD.MedChrgitmType = "08"
  9393. memo["hosp_appr_flag"] = "1"
  9394. memo["invoice_no"] = order.MdtrtId
  9395. memo["memo"] = "自费"
  9396. bytesData, _ := json.Marshal(memo)
  9397. fsiOPFLD.Memo = string(bytesData)
  9398. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9399. }
  9400. }
  9401. }
  9402. fmt.Println(fsiOPFLDs)
  9403. struct4201A.Fopfd = fsiOPFLDs
  9404. fmt.Println(struct4201A.Fopfd)
  9405. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9406. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9407. var res2 ResultSix
  9408. var respJSON2 map[string]interface{}
  9409. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9412. return
  9413. }
  9414. userJSONBytes2, _ := json.Marshal(respJSON2)
  9415. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9416. utils.ErrorLog("解析失败:%v", err)
  9417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9418. return
  9419. }
  9420. if res2.Infcode != 0 {
  9421. c.ServeSuccessJSON(map[string]interface{}{
  9422. "failed_code": -10,
  9423. "msg": res2.ErrMsg,
  9424. })
  9425. return
  9426. } else {
  9427. order.IsUploadOrderInfo = 1
  9428. service.UpdateOrder(order)
  9429. c.ServeSuccessJSON(map[string]interface{}{
  9430. "msg": "上传成功",
  9431. })
  9432. }
  9433. }
  9434. func (c *HisApiController) Get4202() {
  9435. order_id, _ := c.GetInt64("order_id")
  9436. admin_user_id, _ := c.GetInt64("admin_user_id")
  9437. order, _ := service.GetHisOrderByIDTwo(order_id)
  9438. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9439. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9440. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9441. if order.ID == 0 {
  9442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9443. return
  9444. }
  9445. var struct4202 models.Struct4202
  9446. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9447. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9448. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9449. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9450. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9451. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9452. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9453. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9454. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9455. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9456. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9457. var config []*models.HisXtDiagnoseConfig
  9458. for _, item := range diagnosis_ids {
  9459. id, _ := strconv.ParseInt(item, 10, 64)
  9460. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9461. config = append(config, &diagnosisConfig)
  9462. }
  9463. var tempDiaginfos []models.OwnPayPatnDiagListD
  9464. for index, item := range config {
  9465. if index == 0 {
  9466. var tempDiaginfo models.OwnPayPatnDiagListD
  9467. tempDiaginfo.InoutDiagType = "1"
  9468. tempDiaginfo.DiagCode = item.CountryCode
  9469. tempDiaginfo.DiagName = item.CountryContentName
  9470. tempDiaginfo.DiagType = "1"
  9471. tempDiaginfo.DiagSrtNo = "1"
  9472. tempDiaginfo.MaindiagFlag = "1"
  9473. tempDiaginfo.ValiFlag = "1"
  9474. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9475. } else {
  9476. var tempDiaginfo models.OwnPayPatnDiagListD
  9477. tempDiaginfo.DiagCode = item.CountryCode
  9478. tempDiaginfo.DiagName = item.CountryContentName
  9479. tempDiaginfo.DiagType = "2"
  9480. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9481. tempDiaginfo.MaindiagFlag = "0"
  9482. tempDiaginfo.ValiFlag = "1"
  9483. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9484. }
  9485. }
  9486. struct4202.ODiagListD = tempDiaginfos
  9487. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9488. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9489. var res2 ResultSix
  9490. var respJSON2 map[string]interface{}
  9491. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9494. return
  9495. }
  9496. userJSONBytes2, _ := json.Marshal(respJSON2)
  9497. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9498. utils.ErrorLog("解析失败:%v", err)
  9499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9500. return
  9501. }
  9502. if res2.Infcode != 0 {
  9503. c.ServeSuccessJSON(map[string]interface{}{
  9504. "failed_code": -10,
  9505. "msg": res2.ErrMsg,
  9506. })
  9507. return
  9508. } else {
  9509. order.IsUploadDiagnose = 1
  9510. service.UpdateOrder(order)
  9511. c.ServeSuccessJSON(map[string]interface{}{
  9512. "msg": "上传成功",
  9513. })
  9514. }
  9515. }
  9516. func (c *HisApiController) Get4203() {
  9517. admin_user_id, _ := c.GetInt64("admin_user_id")
  9518. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9519. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9520. order_id, _ := c.GetInt64("order_id")
  9521. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9522. number := ""
  9523. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9524. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9525. if his.ID == 0 {
  9526. number = hospital.Number
  9527. } else {
  9528. number = his.Number
  9529. }
  9530. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9531. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9532. var res2 ResultSix
  9533. var respJSON2 map[string]interface{}
  9534. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9537. return
  9538. }
  9539. userJSONBytes2, _ := json.Marshal(respJSON2)
  9540. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9541. utils.ErrorLog("解析失败:%v", err)
  9542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9543. return
  9544. }
  9545. if res2.Infcode != 0 {
  9546. c.ServeSuccessJSON(map[string]interface{}{
  9547. "failed_code": -10,
  9548. "msg": res2.ErrMsg,
  9549. })
  9550. return
  9551. } else {
  9552. order.IsUploadSuccess = 1
  9553. service.UpdateOrderTwo(order)
  9554. c.ServeSuccessJSON(map[string]interface{}{
  9555. "msg": "上传成功",
  9556. })
  9557. }
  9558. }
  9559. func (c *HisApiController) Get4205() {
  9560. order_id, _ := c.GetInt64("order_id")
  9561. admin_user_id, _ := c.GetInt64("admin_user_id")
  9562. fapiao_code := c.GetString("fapiao_code")
  9563. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9564. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9565. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9566. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9567. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9568. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9569. //order_info = append(order_info, order_info_two...)
  9570. department, _ := service.GetDepartMentDetail(his.Departments)
  9571. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9572. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9573. if order.ID == 0 {
  9574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9575. return
  9576. }
  9577. var struct4201A models.Struct4201A
  9578. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9579. for _, items := range order_info {
  9580. memo := make(map[string]interface{})
  9581. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9582. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9583. fsiOPFLD.MedType = pre.MedType
  9584. fsiOPFLD.FixmedinsCode = miConfig.Code
  9585. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9586. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9587. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9588. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9589. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9590. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.StartTime, 0).Format("2006-01-02 15:04:05")
  9591. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9592. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9593. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9594. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9595. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9596. fsiOPFLD.BilgDeptName = department.Name
  9597. fsiOPFLD.BilgDeptCodg = department.Number
  9598. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9599. fsiOPFLD.BilgDrName = doctor.UserName
  9600. fsiOPFLD.MedChrgitmType = "09"
  9601. memo["hosp_appr_flag"] = "1"
  9602. memo["invoice_no"] = fapiao_code
  9603. memo["memo"] = "自费"
  9604. bytesData, _ := json.Marshal(memo)
  9605. fsiOPFLD.Memo = string(bytesData)
  9606. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9607. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9608. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9609. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9610. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.StartTime, 0).Format("2006-01-02 15:04:05")
  9611. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9612. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9613. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9614. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9615. fsiOPFLD.BilgDeptName = department.Name
  9616. fsiOPFLD.BilgDeptCodg = department.Number
  9617. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9618. fsiOPFLD.BilgDrName = doctor.UserName
  9619. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9620. case 0:
  9621. break
  9622. case 1:
  9623. fsiOPFLD.MedChrgitmType = "14"
  9624. break
  9625. case 2:
  9626. fsiOPFLD.MedChrgitmType = "05"
  9627. break
  9628. case 3:
  9629. fsiOPFLD.MedChrgitmType = "03"
  9630. break
  9631. case 4:
  9632. fsiOPFLD.MedChrgitmType = "03"
  9633. break
  9634. case 5:
  9635. fsiOPFLD.MedChrgitmType = "08"
  9636. break
  9637. case 6:
  9638. fsiOPFLD.MedChrgitmType = "14"
  9639. break
  9640. case 7:
  9641. fsiOPFLD.MedChrgitmType = "14"
  9642. break
  9643. case 8:
  9644. fsiOPFLD.MedChrgitmType = "03"
  9645. break
  9646. case 9:
  9647. fsiOPFLD.MedChrgitmType = "14"
  9648. break
  9649. case 10:
  9650. fsiOPFLD.MedChrgitmType = "14"
  9651. break
  9652. case 11:
  9653. fsiOPFLD.MedChrgitmType = "06"
  9654. break
  9655. case 12:
  9656. fsiOPFLD.MedChrgitmType = "12"
  9657. break
  9658. case 13:
  9659. fsiOPFLD.MedChrgitmType = "01"
  9660. break
  9661. case 14:
  9662. fsiOPFLD.MedChrgitmType = "04"
  9663. break
  9664. case 15:
  9665. fsiOPFLD.MedChrgitmType = "14"
  9666. break
  9667. }
  9668. memo["hosp_appr_flag"] = "1"
  9669. memo["invoice_no"] = fapiao_code
  9670. memo["memo"] = "自费"
  9671. bytesData, _ := json.Marshal(memo)
  9672. fsiOPFLD.Memo = string(bytesData)
  9673. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9674. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9675. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9676. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9677. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9678. fsiOPFLD.BilgDeptName = department.Name
  9679. fsiOPFLD.BilgDeptCodg = department.Number
  9680. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9681. fsiOPFLD.BilgDrName = doctor.UserName
  9682. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9683. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9684. fsiOPFLD.MedChrgitmType = "08"
  9685. memo["hosp_appr_flag"] = "1"
  9686. memo["invoice_no"] = fapiao_code
  9687. memo["memo"] = "自费"
  9688. bytesData, _ := json.Marshal(memo)
  9689. fsiOPFLD.Memo = string(bytesData)
  9690. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9691. }
  9692. }
  9693. }
  9694. for _, items := range order_info_two {
  9695. memo := make(map[string]interface{})
  9696. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9697. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9698. fsiOPFLD.MedType = pre.MedType
  9699. fsiOPFLD.BkkpSn = items.FeedetlSn
  9700. fsiOPFLD.FixmedinsCode = miConfig.Code
  9701. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9702. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9703. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9704. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9705. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9706. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9707. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9708. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9709. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9710. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9711. fsiOPFLD.BilgDeptName = department.Name
  9712. fsiOPFLD.BilgDeptCodg = department.Number
  9713. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9714. fsiOPFLD.BilgDrName = doctor.UserName
  9715. fsiOPFLD.MedChrgitmType = "09"
  9716. memo["hosp_appr_flag"] = "1"
  9717. memo["invoice_no"] = fapiao_code
  9718. memo["memo"] = "自费"
  9719. bytesData, _ := json.Marshal(memo)
  9720. fsiOPFLD.Memo = string(bytesData)
  9721. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9722. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9723. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9724. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9725. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9726. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9727. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9728. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9729. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9730. fsiOPFLD.BilgDeptName = department.Name
  9731. fsiOPFLD.BilgDeptCodg = department.Number
  9732. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9733. fsiOPFLD.BilgDrName = doctor.UserName
  9734. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9735. case 0:
  9736. break
  9737. case 1:
  9738. fsiOPFLD.MedChrgitmType = "14"
  9739. break
  9740. case 2:
  9741. fsiOPFLD.MedChrgitmType = "05"
  9742. break
  9743. case 3:
  9744. fsiOPFLD.MedChrgitmType = "03"
  9745. break
  9746. case 4:
  9747. fsiOPFLD.MedChrgitmType = "03"
  9748. break
  9749. case 5:
  9750. fsiOPFLD.MedChrgitmType = "08"
  9751. break
  9752. case 6:
  9753. fsiOPFLD.MedChrgitmType = "14"
  9754. break
  9755. case 7:
  9756. fsiOPFLD.MedChrgitmType = "14"
  9757. break
  9758. case 8:
  9759. fsiOPFLD.MedChrgitmType = "03"
  9760. break
  9761. case 9:
  9762. fsiOPFLD.MedChrgitmType = "14"
  9763. break
  9764. case 10:
  9765. fsiOPFLD.MedChrgitmType = "14"
  9766. break
  9767. case 11:
  9768. fsiOPFLD.MedChrgitmType = "06"
  9769. break
  9770. case 12:
  9771. fsiOPFLD.MedChrgitmType = "12"
  9772. break
  9773. case 13:
  9774. fsiOPFLD.MedChrgitmType = "01"
  9775. break
  9776. case 14:
  9777. fsiOPFLD.MedChrgitmType = "04"
  9778. break
  9779. case 15:
  9780. fsiOPFLD.MedChrgitmType = "14"
  9781. break
  9782. }
  9783. memo["hosp_appr_flag"] = "1"
  9784. memo["invoice_no"] = fapiao_code
  9785. memo["memo"] = "自费"
  9786. bytesData, _ := json.Marshal(memo)
  9787. fsiOPFLD.Memo = string(bytesData)
  9788. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9789. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9790. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9791. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9792. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9793. fsiOPFLD.BilgDeptName = department.Name
  9794. fsiOPFLD.BilgDeptCodg = department.Number
  9795. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9796. fsiOPFLD.BilgDrName = doctor.UserName
  9797. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9798. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9799. fsiOPFLD.MedChrgitmType = "08"
  9800. memo["hosp_appr_flag"] = "1"
  9801. memo["invoice_no"] = fapiao_code
  9802. memo["memo"] = "自费"
  9803. bytesData, _ := json.Marshal(memo)
  9804. fsiOPFLD.Memo = string(bytesData)
  9805. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9806. }
  9807. }
  9808. }
  9809. fmt.Println(fsiOPFLDs)
  9810. struct4201A.Fopfd = fsiOPFLDs
  9811. fmt.Println(struct4201A.Fopfd)
  9812. var struct4202 models.Struct4202
  9813. timeLayout := "2006-01-02 15:04:05"
  9814. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9815. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9816. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9817. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9818. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9819. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9820. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9821. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9822. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9823. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9824. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9825. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9826. var config []*models.HisXtDiagnoseConfig
  9827. for _, item := range diagnosis_ids {
  9828. id, _ := strconv.ParseInt(item, 10, 64)
  9829. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9830. config = append(config, &diagnosisConfig)
  9831. }
  9832. var tempDiaginfos []models.OwnPayPatnDiagListD
  9833. for index, item := range config {
  9834. if index == 0 {
  9835. var tempDiaginfo models.OwnPayPatnDiagListD
  9836. tempDiaginfo.InoutDiagType = "1"
  9837. tempDiaginfo.DiagCode = item.CountryCode
  9838. tempDiaginfo.DiagName = item.CountryContentName
  9839. tempDiaginfo.DiagType = "1"
  9840. tempDiaginfo.DiagSrtNo = "1"
  9841. tempDiaginfo.MaindiagFlag = "1"
  9842. tempDiaginfo.ValiFlag = "1"
  9843. tempDiaginfo.DiagDrName = doctor.UserName
  9844. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9845. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9846. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9847. } else {
  9848. var tempDiaginfo models.OwnPayPatnDiagListD
  9849. tempDiaginfo.DiagCode = item.CountryCode
  9850. tempDiaginfo.DiagName = item.CountryContentName
  9851. tempDiaginfo.DiagType = "2"
  9852. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9853. tempDiaginfo.MaindiagFlag = "0"
  9854. tempDiaginfo.ValiFlag = "1"
  9855. tempDiaginfo.DiagDrName = doctor.UserName
  9856. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9857. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9858. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9859. }
  9860. }
  9861. struct4202.ODiagListD = tempDiaginfos
  9862. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9863. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9864. var res2 ResultSix
  9865. var respJSON2 map[string]interface{}
  9866. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9869. return
  9870. }
  9871. userJSONBytes2, _ := json.Marshal(respJSON2)
  9872. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9873. utils.ErrorLog("解析失败:%v", err)
  9874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9875. return
  9876. }
  9877. if res2.Infcode != 0 {
  9878. c.ServeSuccessJSON(map[string]interface{}{
  9879. "failed_code": -10,
  9880. "msg": res2.ErrMsg,
  9881. })
  9882. return
  9883. } else {
  9884. order.IsUploadDiagnose = 1
  9885. order.IsUploadOrderInfo = 1
  9886. service.UpdateOrderTwo(order)
  9887. c.ServeSuccessJSON(map[string]interface{}{
  9888. "msg": "上传成功",
  9889. })
  9890. }
  9891. }
  9892. func (c *HisApiController) Get4207() {
  9893. admin_user_id, _ := c.GetInt64("admin_user_id")
  9894. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9895. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9896. order_id, _ := c.GetInt64("order_id")
  9897. order, _ := service.GetHisOrderByIDTwo(order_id)
  9898. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9899. var struct4207 models.Struct4207
  9900. struct4207.PageNum = "1"
  9901. struct4207.PageSize = "1000"
  9902. struct4207.FixmedinsCode = miConfig.Code
  9903. struct4207.FixmedinsMdtrtID = order.Number
  9904. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9905. saveLog(result, requestLog, "4207", "查询")
  9906. var res2 ResultSix
  9907. var respJSON2 map[string]interface{}
  9908. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9911. return
  9912. }
  9913. userJSONBytes2, _ := json.Marshal(respJSON2)
  9914. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9915. utils.ErrorLog("解析失败:%v", err)
  9916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9917. return
  9918. }
  9919. if res2.Infcode != 0 {
  9920. c.ServeSuccessJSON(map[string]interface{}{
  9921. "failed_code": -10,
  9922. "msg": res2.ErrMsg,
  9923. })
  9924. return
  9925. } else {
  9926. c.ServeSuccessJSON(map[string]interface{}{
  9927. "msg": "查询成功",
  9928. })
  9929. }
  9930. }
  9931. func (c *HisApiController) Get4208() {
  9932. admin_user_id, _ := c.GetInt64("admin_user_id")
  9933. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9934. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9935. order_id, _ := c.GetInt64("order_id")
  9936. order, _ := service.GetHisOrderByIDTwo(order_id)
  9937. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9938. var struct4208 models.Struct4208
  9939. struct4208.PageNum = "1"
  9940. struct4208.PageSize = "1000"
  9941. struct4208.PsnCertType = "01"
  9942. struct4208.Certno = his.Certno
  9943. struct4208.MedType = order.MedType
  9944. struct4208.PsnName = his.Name
  9945. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9946. saveLog(result, requestLog, "4208", "查询")
  9947. var res2 ResultSix
  9948. var respJSON2 map[string]interface{}
  9949. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9952. return
  9953. }
  9954. userJSONBytes2, _ := json.Marshal(respJSON2)
  9955. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9956. utils.ErrorLog("解析失败:%v", err)
  9957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9958. return
  9959. }
  9960. if res2.Infcode != 0 {
  9961. c.ServeSuccessJSON(map[string]interface{}{
  9962. "failed_code": -10,
  9963. "msg": res2.ErrMsg,
  9964. })
  9965. return
  9966. } else {
  9967. c.ServeSuccessJSON(map[string]interface{}{
  9968. "msg": "查询成功",
  9969. })
  9970. }
  9971. }
  9972. func (c *HisApiController) Get4209() {
  9973. admin_user_id, _ := c.GetInt64("admin_user_id")
  9974. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9975. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9976. order_id, _ := c.GetInt64("order_id")
  9977. order, _ := service.GetHisOrderByIDTwo(order_id)
  9978. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9979. var struct4209 models.Struct4209
  9980. struct4209.FixmedinsMdtrtID = order.Number
  9981. struct4209.FixmedinsCode = miConfig.Code
  9982. struct4209.PageSize = "1000"
  9983. struct4209.PageNum = "1"
  9984. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9985. saveLog(result, requestLog, "4209", "查询")
  9986. var res2 ResultSix
  9987. var respJSON2 map[string]interface{}
  9988. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9991. return
  9992. }
  9993. userJSONBytes2, _ := json.Marshal(respJSON2)
  9994. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9995. utils.ErrorLog("解析失败:%v", err)
  9996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9997. return
  9998. }
  9999. if res2.Infcode != 0 {
  10000. c.ServeSuccessJSON(map[string]interface{}{
  10001. "failed_code": -10,
  10002. "msg": res2.ErrMsg,
  10003. })
  10004. return
  10005. } else {
  10006. c.ServeSuccessJSON(map[string]interface{}{
  10007. "msg": "查询成功",
  10008. })
  10009. }
  10010. }
  10011. type Result3101 struct {
  10012. Infcode string `json:"infcode"`
  10013. InfRefmsgid string `json:"inf_refmsgid"`
  10014. RefmsgTime string `json:"refmsg_time"`
  10015. RespondTime string `json:"respond_time"`
  10016. Enctype string `json:"enctype"`
  10017. Signtype string `json:"signtype"`
  10018. ErrMsg string `json:"err_msg"`
  10019. Output struct {
  10020. Result []struct {
  10021. JudgeResultDetailDtos []struct {
  10022. VolaItemType string `json:"vola_item_type"`
  10023. MdtrtID string `json:"mdtrt_id"`
  10024. JrdID string `json:"jrd_id"`
  10025. PatnID string `json:"patn_id"`
  10026. RxID string `json:"rx_id"`
  10027. VolaAmt interface{} `json:"vola_amt"`
  10028. } `json:"judge_result_detail_dtos"`
  10029. RuleID string `json:"rule_id"`
  10030. VolaEvid string `json:"vola_evid"`
  10031. MdtrtID string `json:"mdtrt_id"`
  10032. RuleName string `json:"rule_name"`
  10033. VolaAmtStas string `json:"vola_amt_stas"`
  10034. JrID string `json:"jr_id"`
  10035. PatnID string `json:"patn_id"`
  10036. SevDeg string `json:"sev_deg"`
  10037. VolaAmt float64 `json:"vola_amt"`
  10038. VolaBhvrType string `json:"vola_bhvr_type"`
  10039. VolaCont string `json:"vola_cont"`
  10040. } `json:"result"`
  10041. } `json:"output"`
  10042. }
  10043. type Resultgd3101 struct {
  10044. Infcode int64 `json:"infcode"`
  10045. InfRefmsgid string `json:"inf_refmsgid"`
  10046. RefmsgTime string `json:"refmsg_time"`
  10047. RespondTime string `json:"respond_time"`
  10048. Enctype string `json:"enctype"`
  10049. Signtype string `json:"signtype"`
  10050. ErrMsg string `json:"err_msg"`
  10051. Output struct {
  10052. Result []struct {
  10053. JudgeResultDetailDtos []struct {
  10054. VolaItemType string `json:"vola_item_type"`
  10055. MdtrtID string `json:"mdtrt_id"`
  10056. JrdID string `json:"jrd_id"`
  10057. PatnID string `json:"patn_id"`
  10058. RxID string `json:"rx_id"`
  10059. VolaAmt interface{} `json:"vola_amt"`
  10060. } `json:"judge_result_detail_dtos"`
  10061. RuleID string `json:"rule_id"`
  10062. VolaEvid string `json:"vola_evid"`
  10063. MdtrtID string `json:"mdtrt_id"`
  10064. RuleName string `json:"rule_name"`
  10065. VolaAmtStas string `json:"vola_amt_stas"`
  10066. JrID string `json:"jr_id"`
  10067. PatnID string `json:"patn_id"`
  10068. SevDeg string `json:"sev_deg"`
  10069. VolaAmt float64 `json:"vola_amt"`
  10070. VolaBhvrType string `json:"vola_bhvr_type"`
  10071. VolaCont string `json:"vola_cont"`
  10072. } `json:"result"`
  10073. } `json:"output"`
  10074. }
  10075. func (c *HisApiController) ReadEleToken() {
  10076. admin_user_id, _ := c.GetInt64("admin_user_id")
  10077. his_patient_id, _ := c.GetInt64("his_patient_id")
  10078. adminUser := c.GetAdminUserInfo()
  10079. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10080. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10081. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10082. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10083. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10084. if len(tokens) > 0 {
  10085. c.ServeSuccessJSON(map[string]interface{}{
  10086. "msg": "读取成功",
  10087. })
  10088. } else {
  10089. c.ServeSuccessJSON(map[string]interface{}{
  10090. "failed_code": -10,
  10091. "msg": "读取失败",
  10092. })
  10093. }
  10094. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10095. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10096. if len(tokens) > 0 {
  10097. c.ServeSuccessJSON(map[string]interface{}{
  10098. "msg": "读取成功",
  10099. })
  10100. } else {
  10101. c.ServeSuccessJSON(map[string]interface{}{
  10102. "failed_code": -10,
  10103. "msg": "读取失败",
  10104. })
  10105. }
  10106. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10107. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10108. if len(tokens) > 0 {
  10109. c.ServeSuccessJSON(map[string]interface{}{
  10110. "msg": "读取成功",
  10111. })
  10112. } else {
  10113. c.ServeSuccessJSON(map[string]interface{}{
  10114. "failed_code": -10,
  10115. "msg": "读取失败",
  10116. })
  10117. }
  10118. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10119. var api string
  10120. 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 +
  10121. "&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"
  10122. resp, requestErr := http.Get(api)
  10123. if requestErr != nil {
  10124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10125. }
  10126. body, ioErr := ioutil.ReadAll(resp.Body)
  10127. if ioErr != nil {
  10128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10130. }
  10131. var respJSON map[string]interface{}
  10132. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10135. return
  10136. }
  10137. var status string
  10138. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10139. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10140. var token string
  10141. var res ResultTwo //1101结果
  10142. var res10265 ResultTwo10265 //1101结果
  10143. if status == "0" { //读卡成功
  10144. var card_info string //卡信息
  10145. var busi_card_info string
  10146. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10147. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10148. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10149. fmt.Println(card_info)
  10150. fmt.Println(busi_card_info)
  10151. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10152. result, _ := json.Marshal(respJSON)
  10153. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10154. utils.ErrorLog("解析失败:%v", err)
  10155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10156. return
  10157. }
  10158. res.ErrMsg = res10265.ErrMsg
  10159. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10160. res.Infcode = infocode
  10161. res.Output = res10265.Output
  10162. res.InfRefmsgid = res10265.InfRefmsgid
  10163. if res.Infcode == 0 {
  10164. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10165. if err == gorm.ErrRecordNotFound {
  10166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10167. return
  10168. } else if err != nil {
  10169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10170. return
  10171. } else {
  10172. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10173. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10174. infoStr := string(Iinfos)
  10175. idetinfoStr := string(Idetinfos)
  10176. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  10177. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10178. psn := &models.HisPsn{
  10179. PsnNo: res.Output.Baseinfo.PsnNo,
  10180. PatientId: patient.ID,
  10181. Certno: res.Output.Baseinfo.Certno,
  10182. Gend: res.Output.Baseinfo.Gend,
  10183. Naty: res.Output.Baseinfo.Naty,
  10184. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10185. PsnName: res.Output.Baseinfo.PsnName,
  10186. Age: float64(age),
  10187. Brdy: b,
  10188. Idetinfo: idetinfoStr,
  10189. Insuinfo: infoStr,
  10190. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10191. CardInfo: card_info,
  10192. VerifyNumber: token,
  10193. IdCardType: 4,
  10194. }
  10195. var rf []*ResultFive
  10196. json.Unmarshal([]byte(infoStr), &rf)
  10197. var insutypes []*ResultFive
  10198. var insutype string
  10199. var is390 int = 0
  10200. var is310 int = 0
  10201. for _, item := range rf {
  10202. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10203. insutypes = append(insutypes, item)
  10204. }
  10205. }
  10206. if len(insutypes) == 1 {
  10207. insutype = insutypes[0].Insutype
  10208. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10209. } else {
  10210. for _, i := range insutypes {
  10211. if i.Insutype == "390" {
  10212. is390 = 1
  10213. }
  10214. if i.Insutype == "310" {
  10215. is310 = 1
  10216. }
  10217. }
  10218. }
  10219. if is390 == 1 {
  10220. insutype = "390"
  10221. }
  10222. if is310 == 1 {
  10223. insutype = "310"
  10224. }
  10225. if len(insutypes) == 0 {
  10226. insutype = "310"
  10227. }
  10228. service.CreateHisPsn(psn)
  10229. c.ServeSuccessJSON(map[string]interface{}{
  10230. "patient": patient,
  10231. "number": token,
  10232. "insutype": insutype,
  10233. })
  10234. }
  10235. } else {
  10236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10237. return
  10238. }
  10239. } else { //读卡失败
  10240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10241. return
  10242. }
  10243. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10244. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  10245. if len(errMsg) == 0 {
  10246. type ELeData struct {
  10247. Data struct {
  10248. IdNo string `json:"idNo"`
  10249. IdType string `json:"idType"`
  10250. UserName string `json:"userName"`
  10251. EcToken string `json:"ecToken"`
  10252. InsuOrg string `json:"insuOrg"`
  10253. Gender string `json:"gender"`
  10254. Birthday string `json:"birthday"`
  10255. Nationality string `json:"nationality"`
  10256. Email string `json:"email"`
  10257. Extra string `json:"extra"`
  10258. } `json:"data"`
  10259. Code int `json:"code"`
  10260. Message string `json:"message"`
  10261. }
  10262. var ele ELeData
  10263. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10264. if err != nil {
  10265. utils.ErrorLog("解析失败:%v", err)
  10266. }
  10267. token := ele.Data.EcToken
  10268. if len(token) > 0 {
  10269. psn := &models.HisPsn{
  10270. PsnNo: his.PsnNo,
  10271. Age: 0,
  10272. PatientId: his.PatientId,
  10273. Certno: his.Certno,
  10274. Brdy: his.Brdy,
  10275. Gend: his.Gend,
  10276. Naty: his.Naty,
  10277. PsnCertType: his.PsnCertType,
  10278. PsnName: his.PsnName,
  10279. Idetinfo: his.Idetinfo,
  10280. Insuinfo: his.Iinfo,
  10281. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10282. CardInfo: outPutInfo,
  10283. VerifyNumber: token,
  10284. }
  10285. service.CreateHisPsn(psn)
  10286. }
  10287. if len(token) > 0 {
  10288. c.ServeSuccessJSON(map[string]interface{}{
  10289. "msg": "读取成功",
  10290. })
  10291. } else {
  10292. c.ServeSuccessJSON(map[string]interface{}{
  10293. "failed_code": -10,
  10294. "msg": "读取失败",
  10295. })
  10296. }
  10297. }
  10298. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10299. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10300. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10301. type ELeData struct {
  10302. Data struct {
  10303. IdNo string `json:"idNo"`
  10304. IdType string `json:"idType"`
  10305. UserName string `json:"userName"`
  10306. EcToken string `json:"ecToken"`
  10307. InsuOrg string `json:"insuOrg"`
  10308. Gender string `json:"gender"`
  10309. Birthday string `json:"birthday"`
  10310. Nationality string `json:"nationality"`
  10311. Email string `json:"email"`
  10312. Extra string `json:"extra"`
  10313. } `json:"data"`
  10314. Code int `json:"code"`
  10315. Message string `json:"message"`
  10316. }
  10317. var ele ELeData
  10318. err := json.Unmarshal([]byte(result), &ele)
  10319. if err != nil {
  10320. utils.ErrorLog("解析失败:%v", err)
  10321. }
  10322. token := ele.Data.EcToken
  10323. token = Remove0000(token)
  10324. fmt.Println(ele.Data.UserName)
  10325. 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)
  10326. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10327. var res ResultTwo
  10328. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10329. utils.ErrorLog("解析失败:%v", err)
  10330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10331. return
  10332. }
  10333. if res.Infcode == 0 {
  10334. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10335. if err == gorm.ErrRecordNotFound {
  10336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10337. return
  10338. } else if err != nil {
  10339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10340. return
  10341. } else {
  10342. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10343. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10344. infoStr := string(Iinfos)
  10345. idetinfoStr := string(Idetinfos)
  10346. psn := &models.HisPsn{
  10347. PsnNo: res.Output.Baseinfo.PsnNo,
  10348. PatientId: patient.ID,
  10349. Certno: res.Output.Baseinfo.Certno,
  10350. Gend: res.Output.Baseinfo.Gend,
  10351. Naty: res.Output.Baseinfo.Naty,
  10352. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10353. PsnName: res.Output.Baseinfo.PsnName,
  10354. Idetinfo: idetinfoStr,
  10355. Insuinfo: infoStr,
  10356. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10357. CardInfo: "",
  10358. VerifyNumber: token,
  10359. }
  10360. service.CreateHisPsn(psn)
  10361. c.ServeSuccessJSON(map[string]interface{}{
  10362. "patient": patient,
  10363. "number": token,
  10364. })
  10365. }
  10366. } else {
  10367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10368. return
  10369. }
  10370. } else if miConfig.MdtrtareaAdmvs == "361025" {
  10371. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10372. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10373. type ELeData struct {
  10374. Data struct {
  10375. IdNo string `json:"idNo"`
  10376. IdType string `json:"idType"`
  10377. UserName string `json:"userName"`
  10378. EcToken string `json:"ecToken"`
  10379. InsuOrg string `json:"insuOrg"`
  10380. Gender string `json:"gender"`
  10381. Birthday string `json:"birthday"`
  10382. Nationality string `json:"nationality"`
  10383. Email string `json:"email"`
  10384. Extra string `json:"extra"`
  10385. } `json:"data"`
  10386. Code int `json:"code"`
  10387. Message string `json:"message"`
  10388. }
  10389. var ele ELeData
  10390. err := json.Unmarshal([]byte(result), &ele)
  10391. if err != nil {
  10392. utils.ErrorLog("解析失败:%v", err)
  10393. }
  10394. token := ele.Data.EcToken
  10395. token = Remove0000(token)
  10396. fmt.Println(ele.Data.UserName)
  10397. 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)
  10398. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10399. var res ResultTwo
  10400. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10401. utils.ErrorLog("解析失败:%v", err)
  10402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10403. return
  10404. }
  10405. if res.Infcode == 0 {
  10406. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10407. if err == gorm.ErrRecordNotFound {
  10408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10409. return
  10410. } else if err != nil {
  10411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10412. return
  10413. } else {
  10414. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10415. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10416. infoStr := string(Iinfos)
  10417. idetinfoStr := string(Idetinfos)
  10418. psn := &models.HisPsn{
  10419. PsnNo: res.Output.Baseinfo.PsnNo,
  10420. PatientId: patient.ID,
  10421. Certno: res.Output.Baseinfo.Certno,
  10422. Gend: res.Output.Baseinfo.Gend,
  10423. Naty: res.Output.Baseinfo.Naty,
  10424. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10425. PsnName: res.Output.Baseinfo.PsnName,
  10426. Idetinfo: idetinfoStr,
  10427. Insuinfo: infoStr,
  10428. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10429. CardInfo: "",
  10430. VerifyNumber: token,
  10431. }
  10432. service.CreateHisPsn(psn)
  10433. c.ServeSuccessJSON(map[string]interface{}{
  10434. "patient": patient,
  10435. "number": token,
  10436. })
  10437. }
  10438. } else {
  10439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10440. return
  10441. }
  10442. } else if miConfig.MdtrtareaAdmvs == "360100" {
  10443. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10444. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10445. type ELeData struct {
  10446. Data struct {
  10447. IdNo string `json:"idNo"`
  10448. IdType string `json:"idType"`
  10449. UserName string `json:"userName"`
  10450. EcToken string `json:"ecToken"`
  10451. InsuOrg string `json:"insuOrg"`
  10452. Gender string `json:"gender"`
  10453. Birthday string `json:"birthday"`
  10454. Nationality string `json:"nationality"`
  10455. Email string `json:"email"`
  10456. Extra string `json:"extra"`
  10457. } `json:"data"`
  10458. Code int `json:"code"`
  10459. Message string `json:"message"`
  10460. }
  10461. var ele ELeData
  10462. err := json.Unmarshal([]byte(result), &ele)
  10463. if err != nil {
  10464. utils.ErrorLog("解析失败:%v", err)
  10465. }
  10466. token := ele.Data.EcToken
  10467. token = Remove0000(token)
  10468. fmt.Println(ele.Data.UserName)
  10469. 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)
  10470. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10471. var res ResultTwo
  10472. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10473. utils.ErrorLog("解析失败:%v", err)
  10474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10475. return
  10476. }
  10477. if res.Infcode == 0 {
  10478. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10479. if err == gorm.ErrRecordNotFound {
  10480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10481. return
  10482. } else if err != nil {
  10483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10484. return
  10485. } else {
  10486. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10487. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10488. infoStr := string(Iinfos)
  10489. idetinfoStr := string(Idetinfos)
  10490. psn := &models.HisPsn{
  10491. PsnNo: res.Output.Baseinfo.PsnNo,
  10492. PatientId: patient.ID,
  10493. Certno: res.Output.Baseinfo.Certno,
  10494. Gend: res.Output.Baseinfo.Gend,
  10495. Naty: res.Output.Baseinfo.Naty,
  10496. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10497. PsnName: res.Output.Baseinfo.PsnName,
  10498. Idetinfo: idetinfoStr,
  10499. Insuinfo: infoStr,
  10500. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10501. CardInfo: "",
  10502. VerifyNumber: token,
  10503. }
  10504. service.CreateHisPsn(psn)
  10505. c.ServeSuccessJSON(map[string]interface{}{
  10506. "patient": patient,
  10507. "number": token,
  10508. })
  10509. }
  10510. } else {
  10511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10512. return
  10513. }
  10514. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10515. //if initFlag == 0 {
  10516. //c.TestGetJiangXiBasBaseInit()
  10517. //}
  10518. //if initEleFlag == 0 {
  10519. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10520. //}
  10521. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10522. utils.ErrorLog("解析失败:%v", json_result)
  10523. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10524. type ELeData struct {
  10525. Data struct {
  10526. IdNo string `json:"idNo"`
  10527. IdType string `json:"idType"`
  10528. UserName string `json:"userName"`
  10529. EcToken string `json:"ecToken"`
  10530. InsuOrg string `json:"insuOrg"`
  10531. Gender string `json:"gender"`
  10532. Birthday string `json:"birthday"`
  10533. Nationality string `json:"nationality"`
  10534. Email string `json:"email"`
  10535. Extra string `json:"extra"`
  10536. } `json:"data"`
  10537. Code int `json:"code"`
  10538. Message string `json:"message"`
  10539. }
  10540. var ele ELeData
  10541. err := json.Unmarshal([]byte(json_result), &ele)
  10542. if err != nil {
  10543. utils.ErrorLog("解析失败:%v", err)
  10544. }
  10545. token := ele.Data.EcToken
  10546. token = Remove0000(token)
  10547. //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)
  10548. 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)
  10549. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10550. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10551. var res ResultTwo
  10552. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10553. utils.ErrorLog("解析失败:%v", err)
  10554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10555. return
  10556. }
  10557. if res.Infcode == 0 {
  10558. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10559. if err == gorm.ErrRecordNotFound {
  10560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10561. return
  10562. } else if err != nil {
  10563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10564. return
  10565. } else {
  10566. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10567. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10568. infoStr := string(Iinfos)
  10569. idetinfoStr := string(Idetinfos)
  10570. psn := &models.HisPsn{
  10571. PsnNo: res.Output.Baseinfo.PsnNo,
  10572. PatientId: patient.ID,
  10573. Certno: res.Output.Baseinfo.Certno,
  10574. Gend: res.Output.Baseinfo.Gend,
  10575. Naty: res.Output.Baseinfo.Naty,
  10576. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10577. PsnName: res.Output.Baseinfo.PsnName,
  10578. Idetinfo: idetinfoStr,
  10579. Insuinfo: infoStr,
  10580. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10581. CardInfo: "",
  10582. VerifyNumber: token,
  10583. InsuplcAdmdvs: ele.Data.InsuOrg,
  10584. }
  10585. service.CreateHisPsn(psn)
  10586. c.ServeSuccessJSON(map[string]interface{}{
  10587. "patient": patient,
  10588. "number": token,
  10589. })
  10590. }
  10591. } else {
  10592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10593. return
  10594. }
  10595. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10596. res := c.GetoleInfo()
  10597. if res.Infcode == 0 {
  10598. var result string
  10599. if res.Output.MdtrtCertType == "01" {
  10600. 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)
  10601. } else if res.Output.MdtrtCertType == "02" {
  10602. 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)
  10603. } else if res.Output.MdtrtCertType == "03" {
  10604. 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)
  10605. }
  10606. var dat map[string]interface{}
  10607. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10608. fmt.Println(dat)
  10609. } else {
  10610. fmt.Println(err)
  10611. }
  10612. userJSONBytes, _ := json.Marshal(dat)
  10613. var res2 ResultTwo
  10614. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10615. utils.ErrorLog("解析失败:%v", err)
  10616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10617. return
  10618. }
  10619. if res2.Infcode == 0 {
  10620. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10621. if err == gorm.ErrRecordNotFound {
  10622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10623. return
  10624. } else if err != nil {
  10625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10626. return
  10627. } else {
  10628. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10629. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10630. infoStr := string(Iinfos)
  10631. idetinfoStr := string(Idetinfos)
  10632. var rf []*ResultFive
  10633. json.Unmarshal([]byte(infoStr), &rf)
  10634. var insutypes []*ResultFive
  10635. var insutype string
  10636. var is390 int = 0
  10637. var is310 int = 0
  10638. //var insuplc_admdvs string
  10639. for _, item := range rf {
  10640. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10641. insutypes = append(insutypes, item)
  10642. }
  10643. }
  10644. if len(insutypes) == 1 {
  10645. insutype = insutypes[0].Insutype
  10646. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10647. } else {
  10648. for _, i := range insutypes {
  10649. if i.Insutype == "390" {
  10650. is390 = 1
  10651. }
  10652. if i.Insutype == "310" {
  10653. is310 = 1
  10654. }
  10655. }
  10656. }
  10657. if is390 == 1 {
  10658. insutype = "390"
  10659. }
  10660. if is310 == 1 {
  10661. insutype = "310"
  10662. }
  10663. if len(insutypes) == 0 {
  10664. insutype = "310"
  10665. }
  10666. psn := &models.HisPsn{
  10667. PsnNo: res2.Output.Baseinfo.PsnNo,
  10668. PatientId: patient.ID,
  10669. Certno: res2.Output.Baseinfo.Certno,
  10670. Gend: res2.Output.Baseinfo.Gend,
  10671. Naty: res2.Output.Baseinfo.Naty,
  10672. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10673. PsnName: res2.Output.Baseinfo.PsnName,
  10674. Idetinfo: idetinfoStr,
  10675. Insuinfo: infoStr,
  10676. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10677. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10678. VerifyNumber: res.Output.EcToken,
  10679. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10680. }
  10681. service.CreateHisPsn(psn)
  10682. c.ServeSuccessJSON(map[string]interface{}{
  10683. "patient": patient,
  10684. "number": res.Output.CardNo,
  10685. "insutype": insutype,
  10686. })
  10687. }
  10688. } else {
  10689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10690. return
  10691. }
  10692. } else {
  10693. c.ServeSuccessJSON(map[string]interface{}{
  10694. "failed_code": -10,
  10695. "msg": res.ErrMsg,
  10696. })
  10697. }
  10698. } else {
  10699. //if initFlag == 0 {
  10700. // c.TestGetBasBaseInit()
  10701. //}
  10702. //token := c.GetEleBaseInfo()
  10703. //token = Remove0000(token)
  10704. type ELeData struct {
  10705. Code string `json:"code"`
  10706. Data struct {
  10707. Aac002 string `json:"aac002"`
  10708. Aaz500 string `json:"aaz500"`
  10709. ActCardNo string `json:"actCardNo"`
  10710. Bab520 string `json:"bab520"`
  10711. Bkz543 string `json:"bkz543"`
  10712. BusinessType string `json:"businessType"`
  10713. CertfCodg string `json:"certfCodg"`
  10714. EcIndexNo string `json:"ecIndexNo"`
  10715. EcToken string `json:"ecToken"`
  10716. ID0000 string `json:"id0000"`
  10717. IDNo string `json:"idNo"`
  10718. IDType string `json:"idType"`
  10719. Idcode string `json:"idcode"`
  10720. IdentityToken string `json:"identity_token"`
  10721. InsuOrg string `json:"insuOrg"`
  10722. OfficeID string `json:"officeId"`
  10723. OfficeName string `json:"officeName"`
  10724. OperatorID string `json:"operatorId"`
  10725. OperatorName string `json:"operatorName"`
  10726. OrgID string `json:"orgId"`
  10727. UserName string `json:"userName"`
  10728. } `json:"data"`
  10729. Infno interface{} `json:"infno"`
  10730. Message string `json:"message"`
  10731. OrgID string `json:"orgId"`
  10732. TransType string `json:"transType"`
  10733. }
  10734. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10735. fmt.Println(result)
  10736. outPutInfo := Remove0000(result)
  10737. fmt.Println(outPutInfo)
  10738. var ele ELeData
  10739. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10740. if err != nil {
  10741. utils.ErrorLog("解析失败:%v", err)
  10742. }
  10743. token := ele.Data.EcToken
  10744. var result2 string
  10745. var requestLog2 string
  10746. if len(token) > 0 {
  10747. if strings.Contains(ele.Data.IDNo, "HKG") {
  10748. 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)
  10749. } else {
  10750. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10751. }
  10752. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10753. var res ResultTwo
  10754. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10755. utils.ErrorLog("解析失败:%v", err)
  10756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10757. return
  10758. }
  10759. if res.Infcode == 0 {
  10760. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10761. if err == gorm.ErrRecordNotFound {
  10762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10763. return
  10764. } else if err != nil {
  10765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10766. return
  10767. } else {
  10768. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10769. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10770. infoStr := string(Iinfos)
  10771. idetinfoStr := string(Idetinfos)
  10772. psn := &models.HisPsn{
  10773. PsnNo: res.Output.Baseinfo.PsnNo,
  10774. PatientId: patient.ID,
  10775. Certno: res.Output.Baseinfo.Certno,
  10776. Gend: res.Output.Baseinfo.Gend,
  10777. Naty: res.Output.Baseinfo.Naty,
  10778. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10779. PsnName: res.Output.Baseinfo.PsnName,
  10780. Idetinfo: idetinfoStr,
  10781. Insuinfo: infoStr,
  10782. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10783. CardInfo: "",
  10784. VerifyNumber: token,
  10785. }
  10786. service.CreateHisPsn(psn)
  10787. c.ServeSuccessJSON(map[string]interface{}{
  10788. "msg": "读取成功",
  10789. })
  10790. }
  10791. } else {
  10792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10793. return
  10794. }
  10795. } else {
  10796. c.ServeSuccessJSON(map[string]interface{}{
  10797. "failed_code": -10,
  10798. "msg": "读取失败",
  10799. })
  10800. }
  10801. }
  10802. }
  10803. func (c *HisApiController) ReadEleFace() {
  10804. admin_user_id, _ := c.GetInt64("admin_user_id")
  10805. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10806. adminUser := c.GetAdminUserInfo()
  10807. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10808. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10809. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10810. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10811. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10812. if len(tokens) > 0 {
  10813. c.ServeSuccessJSON(map[string]interface{}{
  10814. "msg": "读取成功",
  10815. })
  10816. } else {
  10817. c.ServeSuccessJSON(map[string]interface{}{
  10818. "failed_code": -10,
  10819. "msg": "读取失败",
  10820. })
  10821. }
  10822. }
  10823. }
  10824. func timestampToBirthdayString(timestamp int64) string {
  10825. // 将时间戳转换为 time.Time
  10826. t := time.Unix(timestamp, 0)
  10827. // 格式化时间为生日字符串,例如 "2006-01-02"
  10828. birthday := t.Format("2006-01-02")
  10829. return birthday
  10830. }
  10831. func (c *HisApiController) Get9001() {
  10832. adminUser := c.GetAdminUserInfo()
  10833. admin_user_id, _ := c.GetInt64("admin_user_id")
  10834. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10835. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10836. if miConfig.MdtrtareaAdmvs == "350500" {
  10837. service.GetFjAuthorizationInfo(miConfig.Code)
  10838. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10839. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10840. var dat map[string]interface{}
  10841. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10842. fmt.Println(dat)
  10843. } else {
  10844. fmt.Println(err)
  10845. }
  10846. userJSONBytes, _ := json.Marshal(dat)
  10847. var res models.Result9001
  10848. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10849. utils.ErrorLog("解析失败:%v", err)
  10850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10851. return
  10852. }
  10853. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10854. fmt.Println(miConfig.SecretKey)
  10855. var res models.Result9001Two
  10856. 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 +
  10857. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10858. resp, requestErr := http.Get(api)
  10859. if requestErr != nil {
  10860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10861. return
  10862. }
  10863. body, ioErr := ioutil.ReadAll(resp.Body)
  10864. if ioErr != nil {
  10865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10867. return
  10868. }
  10869. var respJSON map[string]interface{}
  10870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10873. return
  10874. }
  10875. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10876. if status == "0" {
  10877. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10878. c.ServeSuccessJSON(map[string]interface{}{
  10879. "failed_code": -10,
  10880. "msg": err_msg,
  10881. })
  10882. return
  10883. }
  10884. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10885. result, _ := json.Marshal(respJSON)
  10886. fmt.Println("log")
  10887. fmt.Println(string(result))
  10888. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10889. utils.ErrorLog("解析失败:%v", err)
  10890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10891. return
  10892. }
  10893. if res.Infcode == 0 {
  10894. sign := models.HisSignIn{
  10895. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10896. SignNo: res.Output.Signinoutb.SignNo,
  10897. SignTime: "",
  10898. Ctime: time.Now().Unix(),
  10899. Mtime: time.Now().Unix(),
  10900. Status: 1,
  10901. InputLog: "",
  10902. OutputLog: "",
  10903. FixmedinsCode: miConfig.Code,
  10904. }
  10905. err := service.CreateSignIn(&sign)
  10906. if err == nil {
  10907. c.ServeSuccessJSON(map[string]interface{}{
  10908. "msg": "签到成功",
  10909. })
  10910. }
  10911. } else {
  10912. c.ServeSuccessJSON(map[string]interface{}{
  10913. "failed_code": -10,
  10914. "msg": res.ErrMsg,
  10915. })
  10916. return
  10917. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10918. //return
  10919. }
  10920. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10921. fmt.Println(miConfig.SecretKey)
  10922. var res models.Result9001Two
  10923. 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 +
  10924. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10925. resp, requestErr := http.Get(api)
  10926. if requestErr != nil {
  10927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10928. return
  10929. }
  10930. body, ioErr := ioutil.ReadAll(resp.Body)
  10931. if ioErr != nil {
  10932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10934. return
  10935. }
  10936. var respJSON map[string]interface{}
  10937. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10940. return
  10941. }
  10942. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10943. if status == "0" {
  10944. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10945. c.ServeSuccessJSON(map[string]interface{}{
  10946. "failed_code": -10,
  10947. "msg": err_msg,
  10948. })
  10949. return
  10950. }
  10951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10952. result, _ := json.Marshal(respJSON)
  10953. fmt.Println("log")
  10954. fmt.Println(string(result))
  10955. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10956. utils.ErrorLog("解析失败:%v", err)
  10957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10958. return
  10959. }
  10960. if res.Infcode == 0 {
  10961. sign := models.HisSignIn{
  10962. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10963. SignNo: res.Output.Signinoutb.SignNo,
  10964. SignTime: "",
  10965. Ctime: time.Now().Unix(),
  10966. Mtime: time.Now().Unix(),
  10967. Status: 1,
  10968. InputLog: "",
  10969. OutputLog: "",
  10970. FixmedinsCode: miConfig.Code,
  10971. }
  10972. err := service.CreateSignIn(&sign)
  10973. if err == nil {
  10974. c.ServeSuccessJSON(map[string]interface{}{
  10975. "msg": "签到成功",
  10976. })
  10977. }
  10978. } else {
  10979. c.ServeSuccessJSON(map[string]interface{}{
  10980. "failed_code": -10,
  10981. "msg": res.ErrMsg,
  10982. })
  10983. return
  10984. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10985. //return
  10986. }
  10987. } else {
  10988. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10989. var dat map[string]interface{}
  10990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10991. fmt.Println(dat)
  10992. } else {
  10993. fmt.Println(err)
  10994. }
  10995. userJSONBytes, _ := json.Marshal(dat)
  10996. var res models.Result9001
  10997. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10998. utils.ErrorLog("解析失败:%v", err)
  10999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11000. return
  11001. }
  11002. if res.Infcode == 0 {
  11003. sign := models.HisSignIn{
  11004. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11005. SignNo: res.Output.Signinoutb.SignNo,
  11006. SignTime: res.Output.Signinoutb.SignTime,
  11007. Ctime: time.Now().Unix(),
  11008. Mtime: time.Now().Unix(),
  11009. Status: 1,
  11010. InputLog: "",
  11011. OutputLog: "",
  11012. FixmedinsCode: miConfig.Code,
  11013. }
  11014. err := service.CreateSignIn(&sign)
  11015. if err == nil {
  11016. c.ServeSuccessJSON(map[string]interface{}{
  11017. "msg": "签到成功",
  11018. })
  11019. }
  11020. }
  11021. }
  11022. }
  11023. 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) {
  11024. var res Result3101
  11025. adminUser := c.GetAdminUserInfo()
  11026. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11027. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11028. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11029. //record_time := c.GetString("record_time")
  11030. //trig_scen := c.GetString("trig_scen")
  11031. timeLayout := "2006-01-02"
  11032. loc, _ := time.LoadLocation("Local")
  11033. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11034. if err != nil {
  11035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11036. return res
  11037. }
  11038. recordDateTime := theTime.Unix()
  11039. var patientPrescription models.HisPrescriptionInfo
  11040. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11041. //if patientPrescription.ID == 0 {
  11042. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11043. //}
  11044. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11045. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11046. //
  11047. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11048. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11049. var pp models.PublicParams
  11050. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11051. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11052. pp.FixmedinsName = miConfig.OrgName
  11053. pp.FixmedinsCode = miConfig.Code
  11054. pp.RequestUrl = miConfig.Url
  11055. pp.Cainfo = miConfig.Cainfo
  11056. pp.SecretKey = miConfig.SecretKey
  11057. pp.AccessKey = miConfig.AccessKey
  11058. pp.OpterName = roles.UserName
  11059. var config []*models.HisXtDiagnoseConfig
  11060. for _, item := range diagnosis_ids {
  11061. id, _ := strconv.ParseInt(item, 10, 64)
  11062. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11063. config = append(config, &diagnosisConfig)
  11064. }
  11065. var pd models.PatientDtos
  11066. pd.PatnID = his.PsnNo
  11067. pd.PatnName = his.Name
  11068. pd.Gend = his.Gend
  11069. pd.Brdy = his.Brdy
  11070. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11071. pd.CurrMdtrtID = his.Number
  11072. var fed models.FsiEncounterDtos
  11073. fed.MdtrtID = his.Number
  11074. fed.MedinsID = miConfig.Code
  11075. fed.MedinsName = miConfig.OrgName
  11076. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11077. fed.MedMdtrtType = "1"
  11078. fed.MedinsType = "1"
  11079. fed.MedinsLv = "11"
  11080. tm := time.Unix(his.RecordDate, 0)
  11081. s_tm := tm.Format("2006-01-02 15:04:05")
  11082. fed.AdmDate = s_tm
  11083. fed.DscgDate = s_tm
  11084. fed.DscgMainDiseCodg = config[0].CountryCode
  11085. fed.DscgMainDiseName = config[0].CountryContentName
  11086. //诊断信息
  11087. var fdds []*models.FsiDiagnoseDtos
  11088. for index, item := range config {
  11089. if index == 0 {
  11090. var fdd models.FsiDiagnoseDtos
  11091. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11092. fdd.InoutDiseType = "1"
  11093. fdd.MaindiseFlag = "1"
  11094. fdd.DiseDate = s_tm
  11095. fdd.DiasSrtNo = "1"
  11096. fdd.DiseName = item.CountryContentName
  11097. fdd.DiseCodg = item.CountryCode
  11098. fdds = append(fdds, &fdd)
  11099. } else {
  11100. var fdd models.FsiDiagnoseDtos
  11101. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11102. fdd.InoutDiseType = "1"
  11103. fdd.MaindiseFlag = "1"
  11104. fdd.DiseDate = s_tm
  11105. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11106. fdd.DiseName = item.CountryContentName
  11107. fdd.DiseCodg = item.CountryCode
  11108. fdds = append(fdds, &fdd)
  11109. }
  11110. }
  11111. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11112. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11113. fed.AdmDeptName = de.Name
  11114. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11115. fed.DscgDeptName = de.Name
  11116. fed.MedMdtrtType = "1"
  11117. fed.MedType = "11"
  11118. //if his.Insutype == "390" {
  11119. // fed.MedType = "1402"
  11120. //} else {
  11121. // fed.MedType = "9933"
  11122. //}
  11123. var orders []*models.FsiOrderDtos
  11124. if trig_scen == "2" {
  11125. //处方医嘱信息
  11126. for _, item := range prescriptions {
  11127. for _, subItem := range item.HisDoctorAdviceInfo {
  11128. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11129. var order models.FsiOrderDtos
  11130. order.RxID = strconv.FormatInt(item.ID, 10)
  11131. order.Rxno = strconv.FormatInt(item.ID, 10)
  11132. order.LongDrordFlag = "0"
  11133. order.HilistType = "1"
  11134. order.ChrgType = "1"
  11135. order.DrordBhvr = "-"
  11136. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11137. order.HosplistName = subItem.BaseDrugLib.DrugName
  11138. order.HilistLv = "1"
  11139. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11140. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11141. order.HosplistName = subItem.BaseDrugLib.DrugName
  11142. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11143. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11144. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11145. order.OwnpayAmt = ""
  11146. order.SelfpayAmt = ""
  11147. order.Spec = ""
  11148. order.SpecUnt = ""
  11149. order.DrordBegnDate = s_tm
  11150. order.DrordStopDate = ""
  11151. order.DrordDrCodg = doctor_info.DoctorNumber
  11152. order.DrordDeptName = department.Name
  11153. order.DrordDeptCodg = department.Number
  11154. order.DrordDrName = doctor_info.UserName
  11155. order.DrordDrProfttl = "234"
  11156. order.CurrDrordFlag = "1"
  11157. orders = append(orders, &order)
  11158. }
  11159. }
  11160. for _, subItem := range item.HisPrescriptionProject {
  11161. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11162. var order models.FsiOrderDtos
  11163. order.RxID = strconv.FormatInt(item.ID, 10)
  11164. order.Rxno = strconv.FormatInt(item.ID, 10)
  11165. order.LongDrordFlag = "0"
  11166. order.HilistType = "1"
  11167. order.ChrgType = "1"
  11168. order.DrordBhvr = "-"
  11169. order.HilistCode = subItem.HisProject.MedicalCode
  11170. order.HosplistName = subItem.HisProject.ProjectName
  11171. order.HilistLv = "1"
  11172. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11173. order.HosplistCode = subItem.HisProject.MedicalCode
  11174. order.HosplistName = subItem.HisProject.ProjectName
  11175. order.Cnt = subItem.Count
  11176. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11177. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11178. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11179. order.OwnpayAmt = ""
  11180. order.SelfpayAmt = ""
  11181. order.Spec = ""
  11182. order.SpecUnt = ""
  11183. order.DrordBegnDate = s_tm
  11184. order.DrordStopDate = ""
  11185. order.DrordDrCodg = doctor_info.DoctorNumber
  11186. order.DrordDeptName = department.Name
  11187. order.DrordDeptCodg = department.Number
  11188. order.DrordDrName = doctor_info.UserName
  11189. order.DrordDrProfttl = "234"
  11190. order.CurrDrordFlag = "1"
  11191. orders = append(orders, &order)
  11192. }
  11193. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11194. var order models.FsiOrderDtos
  11195. order.RxID = strconv.FormatInt(item.ID, 10)
  11196. order.Rxno = strconv.FormatInt(item.ID, 10)
  11197. order.LongDrordFlag = "0"
  11198. order.HilistType = "1"
  11199. order.ChrgType = "1"
  11200. order.DrordBhvr = "-"
  11201. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11202. order.HosplistName = subItem.GoodInfo.GoodName
  11203. order.HilistLv = "1"
  11204. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11205. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11206. order.HosplistName = subItem.GoodInfo.GoodName
  11207. order.Cnt = subItem.Count
  11208. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11209. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11210. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11211. order.OwnpayAmt = ""
  11212. order.SelfpayAmt = ""
  11213. order.Spec = ""
  11214. order.SpecUnt = ""
  11215. order.DrordBegnDate = s_tm
  11216. order.DrordStopDate = ""
  11217. order.DrordDrCodg = doctor_info.DoctorNumber
  11218. order.DrordDeptName = department.Name
  11219. order.DrordDeptCodg = department.Number
  11220. order.DrordDrName = doctor_info.UserName
  11221. order.DrordDrProfttl = "234"
  11222. order.CurrDrordFlag = "1"
  11223. orders = append(orders, &order)
  11224. }
  11225. }
  11226. }
  11227. //处方医嘱信息
  11228. }
  11229. fed.MatnStas = "0"
  11230. fed.MedfeeSumamt = "0"
  11231. fed.OwnpayAmt = "0"
  11232. fed.SelfpayAmt = "0"
  11233. fed.AcctPayamt = "0"
  11234. fed.MaAmt = "0"
  11235. fed.HifpPayamt = "0"
  11236. fed.SetlTotlnum = "1"
  11237. fed.Insutype = his.Insutype
  11238. fed.ReimFlag = "0"
  11239. fed.OutSetlFlag = "0"
  11240. var fopd []*models.FsiOperationDtosData
  11241. data := make(map[string]interface{})
  11242. data["fed"] = fed
  11243. data["fdd"] = fdds
  11244. data["fod"] = orders
  11245. data["pd"] = pd
  11246. data["pp"] = pp
  11247. data["fopd"] = fopd
  11248. data["trig_scen"] = trig_scen
  11249. fmt.Println(data)
  11250. fmt.Println(fed)
  11251. fmt.Println(fdds)
  11252. fmt.Println(orders)
  11253. fmt.Println(pd)
  11254. fmt.Println(pp)
  11255. fmt.Println(fopd)
  11256. client := &http.Client{}
  11257. bytesData, _ := json.Marshal(data)
  11258. var req *http.Request
  11259. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11260. if miConfig.MdtrtareaAdmvs == "320830" {
  11261. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11262. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11263. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11264. } else {
  11265. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11266. }
  11267. resp, _ := client.Do(req)
  11268. defer resp.Body.Close()
  11269. body, ioErr := ioutil.ReadAll(resp.Body)
  11270. if ioErr != nil {
  11271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11273. return res
  11274. }
  11275. var respJSON map[string]interface{}
  11276. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11279. return res
  11280. }
  11281. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11282. fmt.Println(respJSON)
  11283. result, _ := json.Marshal(respJSON)
  11284. fmt.Println(result)
  11285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11286. utils.ErrorLog("解析失败:%v", err)
  11287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11288. return res
  11289. }
  11290. return res
  11291. } else {
  11292. //if miConfig.MdtrtareaAdmvs == "441202" {
  11293. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11294. saveLog(output, input, "3101", "事前")
  11295. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11296. utils.ErrorLog("解析失败:%v", err)
  11297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11298. return
  11299. }
  11300. return res
  11301. //}
  11302. }
  11303. }
  11304. 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) {
  11305. adminUser := c.GetAdminUserInfo()
  11306. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11307. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11308. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11309. //record_time := c.GetString("record_time")
  11310. //trig_scen := c.GetString("trig_scen")
  11311. timeLayout := "2006-01-02"
  11312. loc, _ := time.LoadLocation("Local")
  11313. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11314. if err != nil {
  11315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11316. return res
  11317. }
  11318. recordDateTime := theTime.Unix()
  11319. var patientPrescription models.HisPrescriptionInfo
  11320. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11321. if patientPrescription.ID == 0 {
  11322. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11323. }
  11324. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11325. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11326. //
  11327. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11328. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11329. var pp models.PublicParams
  11330. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11331. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11332. pp.FixmedinsName = miConfig.OrgName
  11333. pp.FixmedinsCode = miConfig.Code
  11334. pp.RequestUrl = miConfig.Url
  11335. pp.Cainfo = miConfig.Cainfo
  11336. pp.SecretKey = miConfig.SecretKey
  11337. pp.AccessKey = miConfig.AccessKey
  11338. pp.OpterName = roles.UserName
  11339. var config []*models.HisXtDiagnoseConfig
  11340. for _, item := range diagnosis_ids {
  11341. id, _ := strconv.ParseInt(item, 10, 64)
  11342. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11343. config = append(config, &diagnosisConfig)
  11344. }
  11345. var pd models.PatientDtos
  11346. pd.PatnID = his.PsnNo
  11347. pd.PatnName = his.Name
  11348. pd.Gend = his.Gend
  11349. pd.Brdy = his.Brdy
  11350. pd.Poolarea = his.InsuplcAdmdvs
  11351. pd.CurrMdtrtID = his.Number
  11352. var fed models.FsiEncounterDtos
  11353. fed.MdtrtID = his.Number
  11354. fed.MedinsID = miConfig.Code
  11355. fed.MedinsName = miConfig.OrgName
  11356. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11357. fed.MedMdtrtType = "1"
  11358. fed.MedinsType = "1"
  11359. fed.MedinsLv = "11"
  11360. tm := time.Unix(his.RecordDate, 0)
  11361. s_tm := tm.Format("2006-01-02 15:04:05")
  11362. fed.AdmDate = s_tm
  11363. fed.DscgDate = s_tm
  11364. fed.DscgMainDiseCodg = config[0].CountryCode
  11365. fed.DscgMainDiseName = config[0].CountryContentName
  11366. //诊断信息
  11367. var fdds []*models.FsiDiagnoseDtos
  11368. for index, item := range config {
  11369. if index == 0 {
  11370. var fdd models.FsiDiagnoseDtos
  11371. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11372. fdd.InoutDiseType = "1"
  11373. fdd.MaindiseFlag = "1"
  11374. fdd.DiseDate = s_tm
  11375. fdd.DiasSrtNo = "1"
  11376. fdd.DiseName = item.CountryContentName
  11377. fdd.DiseCodg = item.CountryCode
  11378. fdds = append(fdds, &fdd)
  11379. } else {
  11380. var fdd models.FsiDiagnoseDtos
  11381. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11382. fdd.InoutDiseType = "1"
  11383. fdd.MaindiseFlag = "1"
  11384. fdd.DiseDate = s_tm
  11385. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11386. fdd.DiseName = item.CountryContentName
  11387. fdd.DiseCodg = item.CountryCode
  11388. fdds = append(fdds, &fdd)
  11389. }
  11390. }
  11391. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11392. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11393. fed.AdmDeptName = department.Name
  11394. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11395. fed.DscgDeptName = department.Name
  11396. fed.MedMdtrtType = "1"
  11397. fed.MedType = "11"
  11398. //if his.Insutype == "390" {
  11399. // fed.MedType = "1402"
  11400. //} else {
  11401. // fed.MedType = "9933"
  11402. //}
  11403. var orders []*models.FsiOrderDtos
  11404. if trig_scen == "2" {
  11405. //处方医嘱信息
  11406. for _, item := range prescriptions {
  11407. for _, subItem := range item.HisDoctorAdviceInfo {
  11408. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11409. var order models.FsiOrderDtos
  11410. order.RxID = strconv.FormatInt(item.ID, 10)
  11411. order.Rxno = strconv.FormatInt(item.ID, 10)
  11412. order.LongDrordFlag = "0"
  11413. order.HilistType = "1"
  11414. order.ChrgType = "1"
  11415. order.DrordBhvr = "-"
  11416. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11417. order.HosplistName = subItem.BaseDrugLib.DrugName
  11418. order.HilistLv = "1"
  11419. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11420. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11421. order.HosplistName = subItem.BaseDrugLib.DrugName
  11422. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11423. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11424. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11425. order.OwnpayAmt = ""
  11426. order.SelfpayAmt = ""
  11427. order.Spec = ""
  11428. order.SpecUnt = ""
  11429. order.DrordBegnDate = s_tm
  11430. order.DrordStopDate = ""
  11431. order.DrordDrCodg = doctor_info.DoctorNumber
  11432. order.DrordDeptName = department.Name
  11433. order.DrordDeptCodg = department.Number
  11434. order.DrordDrName = doctor_info.UserName
  11435. order.DrordDrProfttl = "234"
  11436. order.CurrDrordFlag = "1"
  11437. orders = append(orders, &order)
  11438. }
  11439. }
  11440. for _, subItem := range item.HisPrescriptionProject {
  11441. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11442. var order models.FsiOrderDtos
  11443. order.RxID = strconv.FormatInt(item.ID, 10)
  11444. order.Rxno = strconv.FormatInt(item.ID, 10)
  11445. order.LongDrordFlag = "0"
  11446. order.HilistType = "1"
  11447. order.ChrgType = "1"
  11448. order.DrordBhvr = "-"
  11449. order.HilistCode = subItem.HisProject.MedicalCode
  11450. order.HosplistName = subItem.HisProject.ProjectName
  11451. order.HilistLv = "1"
  11452. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11453. order.HosplistCode = subItem.HisProject.MedicalCode
  11454. order.HosplistName = subItem.HisProject.ProjectName
  11455. order.Cnt = subItem.Count
  11456. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11457. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11458. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11459. order.OwnpayAmt = ""
  11460. order.SelfpayAmt = ""
  11461. order.Spec = ""
  11462. order.SpecUnt = ""
  11463. order.DrordBegnDate = s_tm
  11464. order.DrordStopDate = ""
  11465. order.DrordDrCodg = doctor_info.DoctorNumber
  11466. order.DrordDeptName = department.Name
  11467. order.DrordDeptCodg = department.Number
  11468. order.DrordDrName = doctor_info.UserName
  11469. order.DrordDrProfttl = "234"
  11470. order.CurrDrordFlag = "1"
  11471. orders = append(orders, &order)
  11472. }
  11473. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11474. var order models.FsiOrderDtos
  11475. order.RxID = strconv.FormatInt(item.ID, 10)
  11476. order.Rxno = strconv.FormatInt(item.ID, 10)
  11477. order.LongDrordFlag = "0"
  11478. order.HilistType = "1"
  11479. order.ChrgType = "1"
  11480. order.DrordBhvr = "-"
  11481. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11482. order.HosplistName = subItem.GoodInfo.GoodName
  11483. order.HilistLv = "1"
  11484. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11485. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11486. order.HosplistName = subItem.GoodInfo.GoodName
  11487. order.Cnt = subItem.Count
  11488. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11489. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11490. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11491. order.OwnpayAmt = ""
  11492. order.SelfpayAmt = ""
  11493. order.Spec = ""
  11494. order.SpecUnt = ""
  11495. order.DrordBegnDate = s_tm
  11496. order.DrordStopDate = ""
  11497. order.DrordDrCodg = doctor_info.DoctorNumber
  11498. order.DrordDeptName = department.Name
  11499. order.DrordDeptCodg = department.Number
  11500. order.DrordDrName = doctor_info.UserName
  11501. order.DrordDrProfttl = "234"
  11502. order.CurrDrordFlag = "1"
  11503. orders = append(orders, &order)
  11504. }
  11505. }
  11506. }
  11507. //处方医嘱信息
  11508. }
  11509. fed.MatnStas = "0"
  11510. fed.MedfeeSumamt = "0"
  11511. fed.OwnpayAmt = "0"
  11512. fed.SelfpayAmt = "0"
  11513. fed.AcctPayamt = "0"
  11514. fed.MaAmt = "0"
  11515. fed.HifpPayamt = "0"
  11516. fed.SetlTotlnum = "1"
  11517. fed.Insutype = his.Insutype
  11518. fed.ReimFlag = "0"
  11519. fed.OutSetlFlag = "0"
  11520. var fopd []*models.FsiOperationDtosData
  11521. data := make(map[string]interface{})
  11522. data["fed"] = fed
  11523. data["fdd"] = fdds
  11524. data["fod"] = orders
  11525. data["pd"] = pd
  11526. data["pp"] = pp
  11527. data["fopd"] = fopd
  11528. data["trig_scen"] = trig_scen
  11529. fmt.Println(data)
  11530. fmt.Println(fed)
  11531. fmt.Println(fdds)
  11532. fmt.Println(orders)
  11533. fmt.Println(pd)
  11534. fmt.Println(pp)
  11535. fmt.Println(fopd)
  11536. client := &http.Client{}
  11537. bytesData, _ := json.Marshal(data)
  11538. var req *http.Request
  11539. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11540. if miConfig.MdtrtareaAdmvs == "320830" {
  11541. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11542. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11543. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11544. } else {
  11545. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11546. }
  11547. resp, _ := client.Do(req)
  11548. defer resp.Body.Close()
  11549. body, ioErr := ioutil.ReadAll(resp.Body)
  11550. if ioErr != nil {
  11551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11553. return res
  11554. }
  11555. var respJSON map[string]interface{}
  11556. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11559. return res
  11560. }
  11561. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11562. fmt.Println(respJSON)
  11563. result, _ := json.Marshal(respJSON)
  11564. fmt.Println(result)
  11565. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11566. utils.ErrorLog("解析失败:%v", err)
  11567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11568. return res
  11569. }
  11570. return res
  11571. } else {
  11572. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11573. saveLog(output, input, "3101", "事前")
  11574. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11575. utils.ErrorLog("解析失败:%v", err)
  11576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11577. return
  11578. }
  11579. return res
  11580. }
  11581. return res
  11582. }
  11583. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11584. ////patient_id, _ := c.GetInt64("patient_id")
  11585. //order_id, _ := c.GetInt64("order_id")
  11586. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11587. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11588. //trig_scen := c.GetString("trig_scen")
  11589. adminUser := c.GetAdminUserInfo()
  11590. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11591. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11592. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11593. record_time := c.GetString("record_time")
  11594. order, _ := service.GetHisOrderByID(order_id)
  11595. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11596. timeLayout := "2006-01-02"
  11597. loc, _ := time.LoadLocation("Local")
  11598. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11599. if err != nil {
  11600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11601. return
  11602. }
  11603. recordDateTime := theTime.Unix()
  11604. var patientPrescription models.HisPrescriptionInfo
  11605. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11606. if patientPrescription.ID == 0 {
  11607. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11608. }
  11609. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11610. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11611. //
  11612. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11613. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11614. var pp models.PublicParams
  11615. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11616. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11617. pp.FixmedinsName = miConfig.OrgName
  11618. pp.FixmedinsCode = miConfig.Code
  11619. pp.RequestUrl = miConfig.Url
  11620. pp.Cainfo = miConfig.Cainfo
  11621. pp.SecretKey = miConfig.SecretKey
  11622. pp.AccessKey = miConfig.AccessKey
  11623. pp.OpterName = roles.UserName
  11624. var config []*models.HisXtDiagnoseConfig
  11625. for _, item := range diagnosis_ids {
  11626. id, _ := strconv.ParseInt(item, 10, 64)
  11627. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11628. config = append(config, &diagnosisConfig)
  11629. }
  11630. var pd models.PatientDtos
  11631. pd.PatnID = his.PsnNo
  11632. pd.PatnName = his.Name
  11633. pd.Gend = his.Gend
  11634. pd.Brdy = psn_info.Brdy
  11635. pd.Poolarea = his.InsuplcAdmdvs
  11636. pd.CurrMdtrtID = his.Number
  11637. var fed models.FsiEncounterDtos
  11638. fed.MdtrtID = his.Number
  11639. fed.MedinsID = miConfig.Code
  11640. fed.MedinsName = miConfig.OrgName
  11641. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11642. fed.MedMdtrtType = "1"
  11643. fed.MedinsType = "1"
  11644. fed.MedinsLv = "11"
  11645. tm := time.Unix(his.RecordDate, 0)
  11646. s_tm := tm.Format("2006-01-02 15:04:05")
  11647. fed.AdmDate = s_tm
  11648. fed.DscgDate = s_tm
  11649. fed.DscgMainDiseCodg = config[0].CountryCode
  11650. fed.DscgMainDiseName = config[0].CountryContentName
  11651. //诊断信息
  11652. var fdds []*models.FsiDiagnoseDtos
  11653. for index, item := range config {
  11654. if index == 0 {
  11655. var fdd models.FsiDiagnoseDtos
  11656. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11657. fdd.InoutDiseType = "1"
  11658. fdd.MaindiseFlag = "1"
  11659. fdd.DiseDate = s_tm
  11660. fdd.DiasSrtNo = "1"
  11661. fdd.DiseName = item.CountryContentName
  11662. fdd.DiseCodg = item.CountryCode
  11663. fdds = append(fdds, &fdd)
  11664. } else {
  11665. var fdd models.FsiDiagnoseDtos
  11666. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11667. fdd.InoutDiseType = "1"
  11668. fdd.MaindiseFlag = "1"
  11669. fdd.DiseDate = s_tm
  11670. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11671. fdd.DiseName = item.CountryContentName
  11672. fdd.DiseCodg = item.CountryCode
  11673. fdds = append(fdds, &fdd)
  11674. }
  11675. }
  11676. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11677. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11678. fed.AdmDeptName = department.Name
  11679. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11680. fed.DscgDeptName = department.Name
  11681. fed.MedType = order.MedType
  11682. //处方医嘱信息
  11683. var orders []*models.FsiOrderDtos
  11684. //for _, item := range prescriptions {
  11685. // for _, subItem := range item.HisDoctorAdviceInfo {
  11686. // var order models.FsiOrderDtos
  11687. // order.RxID = strconv.FormatInt(item.ID, 10)
  11688. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11689. // order.LongDrordFlag = "0"
  11690. // order.HilistType = "1"
  11691. // order.ChrgType = "1"
  11692. // order.DrordBhvr = "-"
  11693. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11694. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11695. // order.HilistLv = "1"
  11696. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11697. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11698. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11699. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11700. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11701. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11702. // order.OwnpayAmt = ""
  11703. // order.SelfpayAmt = ""
  11704. // order.Spec = ""
  11705. // order.SpecUnt = ""
  11706. // order.DrordBegnDate = s_tm
  11707. // order.DrordStopDate = ""
  11708. // order.DrordDrCodg = "1"
  11709. // order.DrordDeptName = department.Name
  11710. // order.DrordDrCodg = "1"
  11711. // order.DrordDrName = doctor_info.UserName
  11712. // order.DrordDrProfttl = ""
  11713. // order.CurrDrordFlag = "1"
  11714. // orders = append(orders, &order)
  11715. // }
  11716. // for _, subItem := range item.HisPrescriptionProject {
  11717. // if subItem.Type == 2 {
  11718. // var order models.FsiOrderDtos
  11719. // order.RxID = strconv.FormatInt(item.ID, 10)
  11720. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11721. // order.LongDrordFlag = "0"
  11722. // order.HilistType = "1"
  11723. // order.ChrgType = "1"
  11724. // order.DrordBhvr = "-"
  11725. // order.HilistCode = subItem.HisProject.MedicalCode
  11726. // order.HosplistName = subItem.HisProject.ProjectName
  11727. // order.HilistLv = "1"
  11728. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11729. // order.HosplistCode = subItem.HisProject.MedicalCode
  11730. // order.HosplistName = subItem.HisProject.ProjectName
  11731. // order.Cnt = subItem.Count
  11732. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11733. //
  11734. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11735. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11736. // order.OwnpayAmt = ""
  11737. // order.SelfpayAmt = ""
  11738. // order.Spec = ""
  11739. // order.SpecUnt = ""
  11740. // order.DrordBegnDate = s_tm
  11741. // order.DrordStopDate = ""
  11742. // order.DrordDrCodg = "1"
  11743. // order.DrordDeptName = department.Name
  11744. // order.DrordDrCodg = "1"
  11745. // order.DrordDrName = doctor_info.UserName
  11746. // order.DrordDrProfttl = ""
  11747. // order.CurrDrordFlag = "1"
  11748. // orders = append(orders, &order)
  11749. //
  11750. // }
  11751. // if subItem.Type == 3 {
  11752. //
  11753. // var order models.FsiOrderDtos
  11754. // order.RxID = strconv.FormatInt(item.ID, 10)
  11755. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11756. // order.LongDrordFlag = "0"
  11757. // order.HilistType = "1"
  11758. // order.ChrgType = "1"
  11759. // order.DrordBhvr = "-"
  11760. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11761. // order.HosplistName = subItem.GoodInfo.GoodName
  11762. // order.HilistLv = "1"
  11763. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11764. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11765. // order.HosplistName = subItem.GoodInfo.GoodName
  11766. // order.Cnt = subItem.Count
  11767. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11768. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11769. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11770. // order.OwnpayAmt = ""
  11771. // order.SelfpayAmt = ""
  11772. // order.Spec = ""
  11773. // order.SpecUnt = ""
  11774. // order.DrordBegnDate = s_tm
  11775. // order.DrordStopDate = ""
  11776. // order.DrordDrCodg = "1"
  11777. // order.DrordDeptName = department.Name
  11778. // order.DrordDrCodg = "1"
  11779. // order.DrordDrName = doctor_info.UserName
  11780. // order.DrordDrProfttl = ""
  11781. // order.CurrDrordFlag = "1"
  11782. // orders = append(orders, &order)
  11783. //
  11784. // }
  11785. // }
  11786. //}
  11787. for _, item := range prescriptions {
  11788. for _, subItem := range item.HisDoctorAdviceInfo {
  11789. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11790. var order models.FsiOrderDtos
  11791. order.RxID = strconv.FormatInt(item.ID, 10)
  11792. order.Rxno = strconv.FormatInt(item.ID, 10)
  11793. order.LongDrordFlag = "0"
  11794. order.HilistType = "101"
  11795. order.ChrgType = "1"
  11796. order.DrordBhvr = "-"
  11797. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11798. order.HosplistName = subItem.BaseDrugLib.DrugName
  11799. order.HilistLv = "1"
  11800. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11801. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11802. order.HosplistName = subItem.BaseDrugLib.DrugName
  11803. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11804. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11805. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11806. order.OwnpayAmt = ""
  11807. order.SelfpayAmt = ""
  11808. order.Spec = ""
  11809. order.SpecUnt = ""
  11810. order.DrordBegnDate = s_tm
  11811. order.DrordStopDate = ""
  11812. order.DrordDrCodg = doctor_info.DoctorNumber
  11813. order.DrordDeptName = department.Name
  11814. order.DrordDeptCodg = department.Number
  11815. order.DrordDrName = doctor_info.UserName
  11816. order.DrordDrProfttl = "234"
  11817. order.CurrDrordFlag = "1"
  11818. orders = append(orders, &order)
  11819. }
  11820. }
  11821. for _, subItem := range item.HisPrescriptionProject {
  11822. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11823. var order models.FsiOrderDtos
  11824. order.RxID = strconv.FormatInt(item.ID, 10)
  11825. order.Rxno = strconv.FormatInt(item.ID, 10)
  11826. order.LongDrordFlag = "0"
  11827. order.HilistType = "201"
  11828. order.ChrgType = "1"
  11829. order.DrordBhvr = "-"
  11830. order.HilistCode = subItem.HisProject.MedicalCode
  11831. order.HosplistName = subItem.HisProject.ProjectName
  11832. order.HilistLv = "1"
  11833. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11834. order.HosplistCode = subItem.HisProject.MedicalCode
  11835. order.HosplistName = subItem.HisProject.ProjectName
  11836. order.Cnt = subItem.Count
  11837. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11838. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11839. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11840. order.OwnpayAmt = ""
  11841. order.SelfpayAmt = ""
  11842. order.Spec = ""
  11843. order.SpecUnt = ""
  11844. order.DrordBegnDate = s_tm
  11845. order.DrordStopDate = ""
  11846. order.DrordDrCodg = doctor_info.DoctorNumber
  11847. order.DrordDeptName = department.Name
  11848. order.DrordDeptCodg = department.Number
  11849. order.DrordDrName = doctor_info.UserName
  11850. order.DrordDrProfttl = "234"
  11851. order.CurrDrordFlag = "1"
  11852. orders = append(orders, &order)
  11853. }
  11854. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11855. var order models.FsiOrderDtos
  11856. order.RxID = strconv.FormatInt(item.ID, 10)
  11857. order.Rxno = strconv.FormatInt(item.ID, 10)
  11858. order.LongDrordFlag = "0"
  11859. order.HilistType = "301"
  11860. order.ChrgType = "1"
  11861. order.DrordBhvr = "0"
  11862. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11863. order.HosplistName = subItem.GoodInfo.GoodName
  11864. order.HilistLv = "1"
  11865. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11866. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11867. order.HosplistName = subItem.GoodInfo.GoodName
  11868. order.Cnt = subItem.Count
  11869. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11870. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11871. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11872. order.OwnpayAmt = ""
  11873. order.SelfpayAmt = ""
  11874. order.Spec = ""
  11875. order.SpecUnt = ""
  11876. order.DrordBegnDate = s_tm
  11877. order.DrordStopDate = ""
  11878. order.DrordDrCodg = doctor_info.DoctorNumber
  11879. order.DrordDeptName = department.Name
  11880. order.DrordDeptCodg = department.Number
  11881. order.DrordDrName = doctor_info.UserName
  11882. order.DrordDrProfttl = "234"
  11883. order.CurrDrordFlag = "1"
  11884. orders = append(orders, &order)
  11885. }
  11886. }
  11887. }
  11888. //处方医嘱信息
  11889. fed.MatnStas = "0"
  11890. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11891. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11892. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11893. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11894. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11895. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11896. fed.SetlTotlnum = "1"
  11897. fed.Insutype = his.Insutype
  11898. fed.ReimFlag = "0"
  11899. fed.OutSetlFlag = "0"
  11900. var fopd []*models.FsiOperationDtosData
  11901. data := make(map[string]interface{})
  11902. data["fed"] = fed
  11903. data["fdd"] = fdds
  11904. data["fod"] = orders
  11905. data["pd"] = pd
  11906. data["pp"] = pp
  11907. data["fopd"] = fopd
  11908. data["trig_scen"] = trig_scen
  11909. client := &http.Client{}
  11910. bytesData, _ := json.Marshal(data)
  11911. var req *http.Request
  11912. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11913. if miConfig.MdtrtareaAdmvs == "320830" {
  11914. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  11915. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11916. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11917. } else {
  11918. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11919. }
  11920. resp, _ := client.Do(req)
  11921. defer resp.Body.Close()
  11922. body, ioErr := ioutil.ReadAll(resp.Body)
  11923. if ioErr != nil {
  11924. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11926. return res
  11927. }
  11928. var respJSON map[string]interface{}
  11929. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11932. return res
  11933. }
  11934. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11935. result, _ := json.Marshal(respJSON)
  11936. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11937. utils.ErrorLog("解析失败:%v", err)
  11938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11939. return res
  11940. }
  11941. return res
  11942. } else {
  11943. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11944. saveLog(output, input, "3102", "事中")
  11945. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11946. utils.ErrorLog("解析失败:%v", err)
  11947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11948. return
  11949. }
  11950. return res
  11951. }
  11952. return res
  11953. }
  11954. 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) {
  11955. var res Resultgd3101
  11956. adminUser := c.GetAdminUserInfo()
  11957. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11958. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11959. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11960. //record_time := c.GetString("record_time")
  11961. //trig_scen := c.GetString("trig_scen")
  11962. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11963. //psn_info, _ := service.GetPatientId(patient_id)
  11964. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11965. timeLayout := "2006-01-02"
  11966. loc, _ := time.LoadLocation("Local")
  11967. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11968. if err != nil {
  11969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11970. return res
  11971. }
  11972. recordDateTime := theTime.Unix()
  11973. var patientPrescription models.HisPrescriptionInfo
  11974. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11975. //if patientPrescription.ID == 0 {
  11976. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11977. //}
  11978. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11979. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11980. //
  11981. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11982. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11983. var str string
  11984. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  11985. str = timestampToBirthdayString(patient.Birthday)
  11986. } else {
  11987. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  11988. }
  11989. var pp models.PublicParams
  11990. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11991. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11992. pp.FixmedinsName = miConfig.OrgName
  11993. pp.FixmedinsCode = miConfig.Code
  11994. pp.RequestUrl = miConfig.Url
  11995. pp.Cainfo = miConfig.Cainfo
  11996. pp.SecretKey = miConfig.SecretKey
  11997. pp.AccessKey = miConfig.AccessKey
  11998. pp.OpterName = roles.UserName
  11999. var config []*models.HisXtDiagnoseConfig
  12000. for _, item := range diagnosis_ids {
  12001. id, _ := strconv.ParseInt(item, 10, 64)
  12002. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12003. config = append(config, &diagnosisConfig)
  12004. }
  12005. var pd models.PatientDtos
  12006. pd.PatnID = his.PsnNo
  12007. pd.PatnName = his.Name
  12008. pd.Gend = his.Gend
  12009. pd.Brdy = str
  12010. pd.Poolarea = miConfig.MdtrtareaAdmvs
  12011. pd.CurrMdtrtID = his.Number
  12012. var fed models.FsiEncounterDtos
  12013. fed.MdtrtID = his.Number
  12014. fed.MedinsID = miConfig.Code
  12015. fed.MedinsName = miConfig.OrgName
  12016. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12017. fed.MedMdtrtType = "1"
  12018. fed.MedinsType = "1"
  12019. fed.MedinsLv = "11"
  12020. tm := time.Unix(his.RecordDate, 0)
  12021. s_tm := tm.Format("2006-01-02 15:04:05")
  12022. fed.AdmDate = s_tm
  12023. fed.DscgDate = s_tm
  12024. fed.DscgMainDiseCodg = config[0].CountryCode
  12025. fed.DscgMainDiseName = config[0].CountryContentName
  12026. //诊断信息
  12027. var fdds []*models.FsiDiagnoseDtos
  12028. for index, item := range config {
  12029. if index == 0 {
  12030. var fdd models.FsiDiagnoseDtos
  12031. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12032. fdd.InoutDiseType = "1"
  12033. fdd.MaindiseFlag = "1"
  12034. fdd.DiseDate = s_tm
  12035. fdd.DiasSrtNo = "1"
  12036. fdd.DiseName = item.CountryContentName
  12037. fdd.DiseCodg = item.CountryCode
  12038. fdds = append(fdds, &fdd)
  12039. } else {
  12040. var fdd models.FsiDiagnoseDtos
  12041. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12042. fdd.InoutDiseType = "1"
  12043. fdd.MaindiseFlag = "1"
  12044. fdd.DiseDate = s_tm
  12045. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12046. fdd.DiseName = item.CountryContentName
  12047. fdd.DiseCodg = item.CountryCode
  12048. fdds = append(fdds, &fdd)
  12049. }
  12050. }
  12051. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12052. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  12053. fed.AdmDeptName = de.Name
  12054. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  12055. fed.DscgDeptName = de.Name
  12056. fed.MedMdtrtType = "1"
  12057. fed.MedType = "11"
  12058. //if his.Insutype == "390" {
  12059. // fed.MedType = "1402"
  12060. //} else {
  12061. // fed.MedType = "9933"
  12062. //}
  12063. var orders []*models.FsiOrderDtos
  12064. if trig_scen == "2" {
  12065. //处方医嘱信息
  12066. for _, item := range prescriptions {
  12067. for _, subItem := range item.HisDoctorAdviceInfo {
  12068. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12069. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12070. var order models.FsiOrderDtos
  12071. order.RxID = strconv.FormatInt(item.ID, 10)
  12072. order.Rxno = strconv.FormatInt(item.ID, 10)
  12073. order.LongDrordFlag = "0"
  12074. order.HilistType = "101"
  12075. order.ChrgType = "1"
  12076. order.DrordBhvr = "0"
  12077. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12078. order.HosplistName = subItem.BaseDrugLib.DrugName
  12079. order.HilistLv = "1"
  12080. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12081. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12082. order.HosplistName = subItem.BaseDrugLib.DrugName
  12083. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12084. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12085. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12086. order.OwnpayAmt = ""
  12087. order.SelfpayAmt = ""
  12088. order.Spec = spec
  12089. order.SpecUnt = subItem.PrescribingNumberUnit
  12090. order.DrordBegnDate = s_tm
  12091. order.DrordStopDate = ""
  12092. order.DrordDrCodg = doctor_info.DoctorNumber
  12093. order.DrordDeptName = department.Name
  12094. order.DrordDeptCodg = department.Number
  12095. order.DrordDrName = doctor_info.UserName
  12096. order.DrordDrProfttl = "234"
  12097. order.CurrDrordFlag = "1"
  12098. orders = append(orders, &order)
  12099. }
  12100. }
  12101. for _, subItem := range item.HisPrescriptionProject {
  12102. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12103. var order models.FsiOrderDtos
  12104. order.RxID = strconv.FormatInt(item.ID, 10)
  12105. order.Rxno = strconv.FormatInt(item.ID, 10)
  12106. order.LongDrordFlag = "0"
  12107. order.HilistType = "201"
  12108. order.ChrgType = "1"
  12109. order.DrordBhvr = "0"
  12110. order.HilistCode = subItem.HisProject.MedicalCode
  12111. order.HosplistName = subItem.HisProject.ProjectName
  12112. order.HilistLv = "1"
  12113. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12114. order.HosplistCode = subItem.HisProject.MedicalCode
  12115. order.HosplistName = subItem.HisProject.ProjectName
  12116. order.Cnt = subItem.Count
  12117. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12118. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12119. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12120. order.OwnpayAmt = ""
  12121. order.SelfpayAmt = ""
  12122. order.Spec = subItem.Unit
  12123. order.SpecUnt = subItem.Unit
  12124. order.DrordBegnDate = s_tm
  12125. order.DrordStopDate = ""
  12126. order.DrordDrCodg = doctor_info.DoctorNumber
  12127. order.DrordDeptName = department.Name
  12128. order.DrordDeptCodg = department.Number
  12129. order.DrordDrName = doctor_info.UserName
  12130. order.DrordDrProfttl = "234"
  12131. order.CurrDrordFlag = "1"
  12132. orders = append(orders, &order)
  12133. }
  12134. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12135. var order models.FsiOrderDtos
  12136. order.RxID = strconv.FormatInt(item.ID, 10)
  12137. order.Rxno = strconv.FormatInt(item.ID, 10)
  12138. order.LongDrordFlag = "0"
  12139. order.HilistType = "301"
  12140. order.ChrgType = "1"
  12141. order.DrordBhvr = "0"
  12142. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12143. order.HosplistName = subItem.GoodInfo.GoodName
  12144. order.HilistLv = "1"
  12145. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12146. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12147. order.HosplistName = subItem.GoodInfo.GoodName
  12148. order.Cnt = subItem.Count
  12149. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12150. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12151. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12152. order.OwnpayAmt = ""
  12153. order.SelfpayAmt = ""
  12154. order.Spec = subItem.GoodInfo.SpecificationName
  12155. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12156. order.DrordBegnDate = s_tm
  12157. order.DrordStopDate = ""
  12158. order.DrordDrCodg = doctor_info.DoctorNumber
  12159. order.DrordDeptName = department.Name
  12160. order.DrordDeptCodg = department.Number
  12161. order.DrordDrName = doctor_info.UserName
  12162. order.DrordDrProfttl = "234"
  12163. order.CurrDrordFlag = "1"
  12164. orders = append(orders, &order)
  12165. }
  12166. }
  12167. }
  12168. //处方医嘱信息
  12169. }
  12170. fed.MatnStas = "0"
  12171. fed.MedfeeSumamt = "0"
  12172. fed.OwnpayAmt = "0"
  12173. fed.SelfpayAmt = "0"
  12174. fed.AcctPayamt = "0"
  12175. fed.MaAmt = "0"
  12176. fed.HifpPayamt = "0"
  12177. fed.SetlTotlnum = "1"
  12178. fed.Insutype = his.Insutype
  12179. fed.ReimFlag = "0"
  12180. fed.OutSetlFlag = "0"
  12181. var fopd []*models.FsiOperationDtosData
  12182. data := make(map[string]interface{})
  12183. data["fed"] = fed
  12184. data["fdd"] = fdds
  12185. data["fod"] = orders
  12186. data["pd"] = pd
  12187. data["pp"] = pp
  12188. data["fopd"] = fopd
  12189. data["trig_scen"] = trig_scen
  12190. fmt.Println(data)
  12191. fmt.Println(fed)
  12192. fmt.Println(fdds)
  12193. fmt.Println(orders)
  12194. fmt.Println(pd)
  12195. fmt.Println(pp)
  12196. fmt.Println(fopd)
  12197. client := &http.Client{}
  12198. bytesData, _ := json.Marshal(data)
  12199. var req *http.Request
  12200. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12201. if miConfig.MdtrtareaAdmvs == "320830" {
  12202. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12203. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12204. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12205. } else {
  12206. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12207. }
  12208. resp, _ := client.Do(req)
  12209. defer resp.Body.Close()
  12210. body, ioErr := ioutil.ReadAll(resp.Body)
  12211. if ioErr != nil {
  12212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12214. return res
  12215. }
  12216. var respJSON map[string]interface{}
  12217. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12220. return res
  12221. }
  12222. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12223. fmt.Println(respJSON)
  12224. result, _ := json.Marshal(respJSON)
  12225. fmt.Println(result)
  12226. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12227. utils.ErrorLog("解析失败:%v", err)
  12228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12229. return res
  12230. }
  12231. return res
  12232. } else {
  12233. //if miConfig.MdtrtareaAdmvs == "441202" {
  12234. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12235. saveLog(output, input, "3101", "事前")
  12236. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12237. utils.ErrorLog("解析失败:%v", err)
  12238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12239. return
  12240. }
  12241. return res
  12242. //}
  12243. }
  12244. }
  12245. 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) {
  12246. adminUser := c.GetAdminUserInfo()
  12247. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12248. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12249. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12250. //record_time := c.GetString("record_time")
  12251. //trig_scen := c.GetString("trig_scen")
  12252. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12253. timeLayout := "2006-01-02"
  12254. loc, _ := time.LoadLocation("Local")
  12255. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12256. if err != nil {
  12257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12258. return res
  12259. }
  12260. recordDateTime := theTime.Unix()
  12261. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12262. var patientPrescription models.HisPrescriptionInfo
  12263. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12264. if patientPrescription.ID == 0 {
  12265. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12266. }
  12267. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12268. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12269. //
  12270. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12271. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12272. var pp models.PublicParams
  12273. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12274. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12275. pp.FixmedinsName = miConfig.OrgName
  12276. pp.FixmedinsCode = miConfig.Code
  12277. pp.RequestUrl = miConfig.Url
  12278. pp.Cainfo = miConfig.Cainfo
  12279. pp.SecretKey = miConfig.SecretKey
  12280. pp.AccessKey = miConfig.AccessKey
  12281. pp.OpterName = roles.UserName
  12282. var config []*models.HisXtDiagnoseConfig
  12283. for _, item := range diagnosis_ids {
  12284. id, _ := strconv.ParseInt(item, 10, 64)
  12285. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12286. config = append(config, &diagnosisConfig)
  12287. }
  12288. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12289. var str string
  12290. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12291. str = timestampToBirthdayString(patient.Birthday)
  12292. } else {
  12293. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12294. }
  12295. var pd models.PatientDtos
  12296. pd.PatnID = his.PsnNo
  12297. pd.PatnName = his.Name
  12298. pd.Gend = his.Gend
  12299. pd.Brdy = str
  12300. pd.Poolarea = his.InsuplcAdmdvs
  12301. pd.CurrMdtrtID = his.Number
  12302. var fed models.FsiEncounterDtos
  12303. fed.MdtrtID = his.Number
  12304. fed.MedinsID = miConfig.Code
  12305. fed.MedinsName = miConfig.OrgName
  12306. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12307. fed.MedMdtrtType = "1"
  12308. fed.MedinsType = "1"
  12309. fed.MedinsLv = "11"
  12310. tm := time.Unix(his.RecordDate, 0)
  12311. s_tm := tm.Format("2006-01-02 15:04:05")
  12312. fed.AdmDate = s_tm
  12313. fed.DscgDate = s_tm
  12314. fed.DscgMainDiseCodg = config[0].CountryCode
  12315. fed.DscgMainDiseName = config[0].CountryContentName
  12316. //诊断信息
  12317. var fdds []*models.FsiDiagnoseDtos
  12318. for index, item := range config {
  12319. if index == 0 {
  12320. var fdd models.FsiDiagnoseDtos
  12321. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12322. fdd.InoutDiseType = "1"
  12323. fdd.MaindiseFlag = "1"
  12324. fdd.DiseDate = s_tm
  12325. fdd.DiasSrtNo = "1"
  12326. fdd.DiseName = item.CountryContentName
  12327. fdd.DiseCodg = item.CountryCode
  12328. fdds = append(fdds, &fdd)
  12329. } else {
  12330. var fdd models.FsiDiagnoseDtos
  12331. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12332. fdd.InoutDiseType = "1"
  12333. fdd.MaindiseFlag = "1"
  12334. fdd.DiseDate = s_tm
  12335. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12336. fdd.DiseName = item.CountryContentName
  12337. fdd.DiseCodg = item.CountryCode
  12338. fdds = append(fdds, &fdd)
  12339. }
  12340. }
  12341. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12342. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12343. fed.AdmDeptName = department.Name
  12344. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12345. fed.DscgDeptName = department.Name
  12346. fed.MedMdtrtType = "1"
  12347. fed.MedType = "11"
  12348. //if his.Insutype == "390" {
  12349. // fed.MedType = "1402"
  12350. //} else {
  12351. // fed.MedType = "9933"
  12352. //}
  12353. var orders []*models.FsiOrderDtos
  12354. if trig_scen == "2" {
  12355. //处方医嘱信息
  12356. for _, item := range prescriptions {
  12357. for _, subItem := range item.HisDoctorAdviceInfo {
  12358. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12359. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12360. var order models.FsiOrderDtos
  12361. order.RxID = strconv.FormatInt(item.ID, 10)
  12362. order.Rxno = strconv.FormatInt(item.ID, 10)
  12363. order.LongDrordFlag = "0"
  12364. order.HilistType = "101"
  12365. order.ChrgType = "1"
  12366. order.DrordBhvr = "0"
  12367. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12368. order.HosplistName = subItem.BaseDrugLib.DrugName
  12369. order.HilistLv = "1"
  12370. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12371. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12372. order.HosplistName = subItem.BaseDrugLib.DrugName
  12373. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12374. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12375. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12376. order.OwnpayAmt = ""
  12377. order.SelfpayAmt = ""
  12378. order.Spec = spec
  12379. order.SpecUnt = subItem.PrescribingNumberUnit
  12380. order.DrordBegnDate = s_tm
  12381. order.DrordStopDate = ""
  12382. order.DrordDrCodg = doctor_info.DoctorNumber
  12383. order.DrordDeptName = department.Name
  12384. order.DrordDeptCodg = department.Number
  12385. order.DrordDrName = doctor_info.UserName
  12386. order.DrordDrProfttl = "234"
  12387. order.CurrDrordFlag = "1"
  12388. orders = append(orders, &order)
  12389. }
  12390. }
  12391. for _, subItem := range item.HisPrescriptionProject {
  12392. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12393. var order models.FsiOrderDtos
  12394. order.RxID = strconv.FormatInt(item.ID, 10)
  12395. order.Rxno = strconv.FormatInt(item.ID, 10)
  12396. order.LongDrordFlag = "0"
  12397. order.HilistType = "201"
  12398. order.ChrgType = "1"
  12399. order.DrordBhvr = "0"
  12400. order.HilistCode = subItem.HisProject.MedicalCode
  12401. order.HosplistName = subItem.HisProject.ProjectName
  12402. order.HilistLv = "1"
  12403. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12404. order.HosplistCode = subItem.HisProject.MedicalCode
  12405. order.HosplistName = subItem.HisProject.ProjectName
  12406. order.Cnt = subItem.Count
  12407. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12408. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12409. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12410. order.OwnpayAmt = ""
  12411. order.SelfpayAmt = ""
  12412. order.Spec = subItem.Unit
  12413. order.SpecUnt = subItem.Unit
  12414. order.DrordBegnDate = s_tm
  12415. order.DrordStopDate = ""
  12416. order.DrordDrCodg = doctor_info.DoctorNumber
  12417. order.DrordDeptName = department.Name
  12418. order.DrordDeptCodg = department.Number
  12419. order.DrordDrName = doctor_info.UserName
  12420. order.DrordDrProfttl = "234"
  12421. order.CurrDrordFlag = "1"
  12422. orders = append(orders, &order)
  12423. }
  12424. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12425. var order models.FsiOrderDtos
  12426. order.RxID = strconv.FormatInt(item.ID, 10)
  12427. order.Rxno = strconv.FormatInt(item.ID, 10)
  12428. order.LongDrordFlag = "0"
  12429. order.HilistType = "301"
  12430. order.ChrgType = "1"
  12431. order.DrordBhvr = "0"
  12432. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12433. order.HosplistName = subItem.GoodInfo.GoodName
  12434. order.HilistLv = "1"
  12435. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12436. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12437. order.HosplistName = subItem.GoodInfo.GoodName
  12438. order.Cnt = subItem.Count
  12439. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12440. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12441. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12442. order.OwnpayAmt = ""
  12443. order.SelfpayAmt = ""
  12444. order.Spec = subItem.GoodInfo.SpecificationName
  12445. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12446. order.DrordBegnDate = s_tm
  12447. order.DrordStopDate = ""
  12448. order.DrordDrCodg = doctor_info.DoctorNumber
  12449. order.DrordDeptName = department.Name
  12450. order.DrordDeptCodg = department.Number
  12451. order.DrordDrName = doctor_info.UserName
  12452. order.DrordDrProfttl = "234"
  12453. order.CurrDrordFlag = "1"
  12454. orders = append(orders, &order)
  12455. }
  12456. }
  12457. }
  12458. //处方医嘱信息
  12459. }
  12460. fed.MatnStas = "0"
  12461. fed.MedfeeSumamt = "0"
  12462. fed.OwnpayAmt = "0"
  12463. fed.SelfpayAmt = "0"
  12464. fed.AcctPayamt = "0"
  12465. fed.MaAmt = "0"
  12466. fed.HifpPayamt = "0"
  12467. fed.SetlTotlnum = "1"
  12468. fed.Insutype = his.Insutype
  12469. fed.ReimFlag = "0"
  12470. fed.OutSetlFlag = "0"
  12471. var fopd []*models.FsiOperationDtosData
  12472. data := make(map[string]interface{})
  12473. data["fed"] = fed
  12474. data["fdd"] = fdds
  12475. data["fod"] = orders
  12476. data["pd"] = pd
  12477. data["pp"] = pp
  12478. data["fopd"] = fopd
  12479. data["trig_scen"] = trig_scen
  12480. fmt.Println(data)
  12481. fmt.Println(fed)
  12482. fmt.Println(fdds)
  12483. fmt.Println(orders)
  12484. fmt.Println(pd)
  12485. fmt.Println(pp)
  12486. fmt.Println(fopd)
  12487. client := &http.Client{}
  12488. bytesData, _ := json.Marshal(data)
  12489. var req *http.Request
  12490. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12491. if miConfig.MdtrtareaAdmvs == "320830" {
  12492. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12493. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12494. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12495. } else {
  12496. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12497. }
  12498. resp, _ := client.Do(req)
  12499. defer resp.Body.Close()
  12500. body, ioErr := ioutil.ReadAll(resp.Body)
  12501. if ioErr != nil {
  12502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12504. return res
  12505. }
  12506. var respJSON map[string]interface{}
  12507. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12510. return res
  12511. }
  12512. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12513. fmt.Println(respJSON)
  12514. result, _ := json.Marshal(respJSON)
  12515. fmt.Println(result)
  12516. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12517. utils.ErrorLog("解析失败:%v", err)
  12518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12519. return res
  12520. }
  12521. return res
  12522. } else {
  12523. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12524. saveLog(output, input, "3101", "事前")
  12525. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12526. utils.ErrorLog("解析失败:%v", err)
  12527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12528. return
  12529. }
  12530. return res
  12531. }
  12532. return res
  12533. }
  12534. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12535. adminUser := c.GetAdminUserInfo()
  12536. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12537. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12538. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12539. record_time := c.GetString("record_time")
  12540. order, _ := service.GetHisOrderByID(order_id)
  12541. timeLayout := "2006-01-02"
  12542. loc, _ := time.LoadLocation("Local")
  12543. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12544. if err != nil {
  12545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12546. return
  12547. }
  12548. recordDateTime := theTime.Unix()
  12549. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12550. var patientPrescription models.HisPrescriptionInfo
  12551. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12552. if patientPrescription.ID == 0 {
  12553. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12554. }
  12555. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12556. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12557. //
  12558. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12559. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12560. var pp models.PublicParams
  12561. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12562. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12563. pp.FixmedinsName = miConfig.OrgName
  12564. pp.FixmedinsCode = miConfig.Code
  12565. pp.RequestUrl = miConfig.Url
  12566. pp.Cainfo = miConfig.Cainfo
  12567. pp.SecretKey = miConfig.SecretKey
  12568. pp.AccessKey = miConfig.AccessKey
  12569. pp.OpterName = roles.UserName
  12570. var config []*models.HisXtDiagnoseConfig
  12571. for _, item := range diagnosis_ids {
  12572. id, _ := strconv.ParseInt(item, 10, 64)
  12573. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12574. config = append(config, &diagnosisConfig)
  12575. }
  12576. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12577. var str string
  12578. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12579. str = timestampToBirthdayString(patient.Birthday)
  12580. } else {
  12581. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12582. }
  12583. var pd models.PatientDtos
  12584. pd.PatnID = his.PsnNo
  12585. pd.PatnName = his.Name
  12586. pd.Gend = his.Gend
  12587. pd.Brdy = str
  12588. pd.Poolarea = his.InsuplcAdmdvs
  12589. pd.CurrMdtrtID = his.Number
  12590. var fed models.FsiEncounterDtos
  12591. fed.MdtrtID = his.Number
  12592. fed.MedinsID = miConfig.Code
  12593. fed.MedinsName = miConfig.OrgName
  12594. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12595. fed.MedMdtrtType = "1"
  12596. fed.MedinsType = "1"
  12597. fed.MedinsLv = "11"
  12598. tm := time.Unix(his.RecordDate, 0)
  12599. s_tm := tm.Format("2006-01-02 15:04:05")
  12600. fed.AdmDate = s_tm
  12601. fed.DscgDate = s_tm
  12602. fed.DscgMainDiseCodg = config[0].CountryCode
  12603. fed.DscgMainDiseName = config[0].CountryContentName
  12604. //诊断信息
  12605. var fdds []*models.FsiDiagnoseDtos
  12606. for index, item := range config {
  12607. if index == 0 {
  12608. var fdd models.FsiDiagnoseDtos
  12609. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12610. fdd.InoutDiseType = "1"
  12611. fdd.MaindiseFlag = "1"
  12612. fdd.DiseDate = s_tm
  12613. fdd.DiasSrtNo = "1"
  12614. fdd.DiseName = item.CountryContentName
  12615. fdd.DiseCodg = item.CountryCode
  12616. fdds = append(fdds, &fdd)
  12617. } else {
  12618. var fdd models.FsiDiagnoseDtos
  12619. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12620. fdd.InoutDiseType = "1"
  12621. fdd.MaindiseFlag = "1"
  12622. fdd.DiseDate = s_tm
  12623. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12624. fdd.DiseName = item.CountryContentName
  12625. fdd.DiseCodg = item.CountryCode
  12626. fdds = append(fdds, &fdd)
  12627. }
  12628. }
  12629. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12630. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12631. fed.AdmDeptName = department.Name
  12632. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12633. fed.DscgDeptName = department.Name
  12634. fed.MedType = order.MedType
  12635. //处方医嘱信息
  12636. var orders []*models.FsiOrderDtos
  12637. //for _, item := range prescriptions {
  12638. // for _, subItem := range item.HisDoctorAdviceInfo {
  12639. // var order models.FsiOrderDtos
  12640. // order.RxID = strconv.FormatInt(item.ID, 10)
  12641. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12642. // order.LongDrordFlag = "0"
  12643. // order.HilistType = "1"
  12644. // order.ChrgType = "1"
  12645. // order.DrordBhvr = "-"
  12646. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12647. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12648. // order.HilistLv = "1"
  12649. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12650. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12651. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12652. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12653. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12654. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12655. // order.OwnpayAmt = ""
  12656. // order.SelfpayAmt = ""
  12657. // order.Spec = ""
  12658. // order.SpecUnt = ""
  12659. // order.DrordBegnDate = s_tm
  12660. // order.DrordStopDate = ""
  12661. // order.DrordDrCodg = "1"
  12662. // order.DrordDeptName = department.Name
  12663. // order.DrordDrCodg = "1"
  12664. // order.DrordDrName = doctor_info.UserName
  12665. // order.DrordDrProfttl = ""
  12666. // order.CurrDrordFlag = "1"
  12667. // orders = append(orders, &order)
  12668. // }
  12669. // for _, subItem := range item.HisPrescriptionProject {
  12670. // if subItem.Type == 2 {
  12671. // var order models.FsiOrderDtos
  12672. // order.RxID = strconv.FormatInt(item.ID, 10)
  12673. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12674. // order.LongDrordFlag = "0"
  12675. // order.HilistType = "1"
  12676. // order.ChrgType = "1"
  12677. // order.DrordBhvr = "-"
  12678. // order.HilistCode = subItem.HisProject.MedicalCode
  12679. // order.HosplistName = subItem.HisProject.ProjectName
  12680. // order.HilistLv = "1"
  12681. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12682. // order.HosplistCode = subItem.HisProject.MedicalCode
  12683. // order.HosplistName = subItem.HisProject.ProjectName
  12684. // order.Cnt = subItem.Count
  12685. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12686. //
  12687. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12688. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12689. // order.OwnpayAmt = ""
  12690. // order.SelfpayAmt = ""
  12691. // order.Spec = ""
  12692. // order.SpecUnt = ""
  12693. // order.DrordBegnDate = s_tm
  12694. // order.DrordStopDate = ""
  12695. // order.DrordDrCodg = "1"
  12696. // order.DrordDeptName = department.Name
  12697. // order.DrordDrCodg = "1"
  12698. // order.DrordDrName = doctor_info.UserName
  12699. // order.DrordDrProfttl = ""
  12700. // order.CurrDrordFlag = "1"
  12701. // orders = append(orders, &order)
  12702. //
  12703. // }
  12704. // if subItem.Type == 3 {
  12705. //
  12706. // var order models.FsiOrderDtos
  12707. // order.RxID = strconv.FormatInt(item.ID, 10)
  12708. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12709. // order.LongDrordFlag = "0"
  12710. // order.HilistType = "1"
  12711. // order.ChrgType = "1"
  12712. // order.DrordBhvr = "-"
  12713. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12714. // order.HosplistName = subItem.GoodInfo.GoodName
  12715. // order.HilistLv = "1"
  12716. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12717. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12718. // order.HosplistName = subItem.GoodInfo.GoodName
  12719. // order.Cnt = subItem.Count
  12720. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12721. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12722. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12723. // order.OwnpayAmt = ""
  12724. // order.SelfpayAmt = ""
  12725. // order.Spec = ""
  12726. // order.SpecUnt = ""
  12727. // order.DrordBegnDate = s_tm
  12728. // order.DrordStopDate = ""
  12729. // order.DrordDrCodg = "1"
  12730. // order.DrordDeptName = department.Name
  12731. // order.DrordDrCodg = "1"
  12732. // order.DrordDrName = doctor_info.UserName
  12733. // order.DrordDrProfttl = ""
  12734. // order.CurrDrordFlag = "1"
  12735. // orders = append(orders, &order)
  12736. //
  12737. // }
  12738. // }
  12739. //}
  12740. for _, item := range prescriptions {
  12741. for _, subItem := range item.HisDoctorAdviceInfo {
  12742. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12743. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12744. var order models.FsiOrderDtos
  12745. order.RxID = strconv.FormatInt(item.ID, 10)
  12746. order.Rxno = strconv.FormatInt(item.ID, 10)
  12747. order.LongDrordFlag = "0"
  12748. order.HilistType = "101"
  12749. order.ChrgType = "01"
  12750. order.DrordBhvr = "0"
  12751. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12752. order.HosplistName = subItem.BaseDrugLib.DrugName
  12753. order.HilistLv = "1"
  12754. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12755. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12756. order.HosplistName = subItem.BaseDrugLib.DrugName
  12757. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12758. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12759. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12760. order.OwnpayAmt = ""
  12761. order.SelfpayAmt = ""
  12762. order.Spec = spec
  12763. order.SpecUnt = subItem.PrescribingNumberUnit
  12764. order.DrordBegnDate = s_tm
  12765. order.DrordStopDate = ""
  12766. order.DrordDrCodg = doctor_info.DoctorNumber
  12767. order.DrordDeptName = department.Name
  12768. order.DrordDeptCodg = department.Number
  12769. order.DrordDrName = doctor_info.UserName
  12770. order.DrordDrProfttl = "234"
  12771. order.CurrDrordFlag = "1"
  12772. orders = append(orders, &order)
  12773. }
  12774. }
  12775. for _, subItem := range item.HisPrescriptionProject {
  12776. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12777. var order models.FsiOrderDtos
  12778. order.RxID = strconv.FormatInt(item.ID, 10)
  12779. order.Rxno = strconv.FormatInt(item.ID, 10)
  12780. order.LongDrordFlag = "0"
  12781. order.HilistType = "201"
  12782. order.ChrgType = "05"
  12783. order.DrordBhvr = "0"
  12784. order.HilistCode = subItem.HisProject.MedicalCode
  12785. order.HosplistName = subItem.HisProject.ProjectName
  12786. order.HilistLv = "1"
  12787. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12788. order.HosplistCode = subItem.HisProject.MedicalCode
  12789. order.HosplistName = subItem.HisProject.ProjectName
  12790. order.Cnt = subItem.Count
  12791. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12792. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12793. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12794. order.OwnpayAmt = ""
  12795. order.SelfpayAmt = ""
  12796. order.Spec = subItem.Unit
  12797. order.SpecUnt = subItem.Unit
  12798. order.DrordBegnDate = s_tm
  12799. order.DrordStopDate = ""
  12800. order.DrordDrCodg = doctor_info.DoctorNumber
  12801. order.DrordDeptName = department.Name
  12802. order.DrordDeptCodg = department.Number
  12803. order.DrordDrName = doctor_info.UserName
  12804. order.DrordDrProfttl = "234"
  12805. order.CurrDrordFlag = "1"
  12806. orders = append(orders, &order)
  12807. }
  12808. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12809. var order models.FsiOrderDtos
  12810. order.RxID = strconv.FormatInt(item.ID, 10)
  12811. order.Rxno = strconv.FormatInt(item.ID, 10)
  12812. order.LongDrordFlag = "0"
  12813. order.HilistType = "301"
  12814. order.ChrgType = "08"
  12815. order.DrordBhvr = "0"
  12816. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12817. order.HosplistName = subItem.GoodInfo.GoodName
  12818. order.HilistLv = "1"
  12819. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12820. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12821. order.HosplistName = subItem.GoodInfo.GoodName
  12822. order.Cnt = subItem.Count
  12823. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12824. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12825. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12826. order.OwnpayAmt = ""
  12827. order.SelfpayAmt = ""
  12828. order.Spec = subItem.GoodInfo.SpecificationName
  12829. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12830. order.DrordBegnDate = s_tm
  12831. order.DrordStopDate = ""
  12832. order.DrordDrCodg = doctor_info.DoctorNumber
  12833. order.DrordDeptName = department.Name
  12834. order.DrordDeptCodg = department.Number
  12835. order.DrordDrName = doctor_info.UserName
  12836. order.DrordDrProfttl = "234"
  12837. order.CurrDrordFlag = "1"
  12838. orders = append(orders, &order)
  12839. }
  12840. }
  12841. }
  12842. //处方医嘱信息
  12843. fed.MatnStas = "0"
  12844. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12845. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12846. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12847. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12848. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12849. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12850. fed.SetlTotlnum = "1"
  12851. fed.Insutype = his.Insutype
  12852. fed.ReimFlag = "0"
  12853. fed.OutSetlFlag = "0"
  12854. var fopd []*models.FsiOperationDtosData
  12855. data := make(map[string]interface{})
  12856. data["fed"] = fed
  12857. data["fdd"] = fdds
  12858. data["fod"] = orders
  12859. data["pd"] = pd
  12860. data["pp"] = pp
  12861. data["fopd"] = fopd
  12862. data["trig_scen"] = trig_scen
  12863. client := &http.Client{}
  12864. bytesData, _ := json.Marshal(data)
  12865. var req *http.Request
  12866. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12867. if miConfig.MdtrtareaAdmvs == "320830" {
  12868. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  12869. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12870. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12871. } else {
  12872. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12873. }
  12874. resp, _ := client.Do(req)
  12875. defer resp.Body.Close()
  12876. body, ioErr := ioutil.ReadAll(resp.Body)
  12877. if ioErr != nil {
  12878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12880. return res
  12881. }
  12882. var respJSON map[string]interface{}
  12883. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12886. return res
  12887. }
  12888. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12889. result, _ := json.Marshal(respJSON)
  12890. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12891. utils.ErrorLog("解析失败:%v", err)
  12892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12893. return res
  12894. }
  12895. return res
  12896. } else {
  12897. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12898. saveLog(output, input, "3102", "事中")
  12899. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12900. utils.ErrorLog("解析失败:%v", err)
  12901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12902. return
  12903. }
  12904. return res
  12905. }
  12906. return res
  12907. }
  12908. func (c *HisApiController) Check() {
  12909. psn_no := c.GetString("psn_no")
  12910. in := c.GetString("in")
  12911. mt := c.GetString("mt")
  12912. baseParams := models.BaseParams{
  12913. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12914. FixmedinsCode: "H15049901371",
  12915. InsuplcAdmdvs: "150499",
  12916. MdtrtareaAdmvs: "150499",
  12917. OrgName: "赤峰费森血液透析中心",
  12918. Doctor: "1111",
  12919. }
  12920. service.Gdyb2001(baseParams, psn_no, in, mt)
  12921. }
  12922. func (c *HisApiController) GetPsnNcdsInfo() {
  12923. admin_user_id, _ := c.GetInt64("admin_user_id")
  12924. patient_id, _ := c.GetInt64("patient_id")
  12925. //id, _ := c.GetInt64("id")
  12926. adminUser := c.GetAdminUserInfo()
  12927. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12928. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12929. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12930. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12931. //psn_record, _ := service.GetP(id)
  12932. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12933. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12934. //
  12935. //if psn_record.ID == 0 {
  12936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12937. // return
  12938. //}
  12939. var res Result5301
  12940. var res10265 Result5301For10265
  12941. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12942. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12943. var api string
  12944. if miConfig.MdtrtareaAdmvs == "320830" {
  12945. api = miConfig.AppSecret + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12946. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12947. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12948. 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 +
  12949. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12950. } else {
  12951. 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 +
  12952. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12953. }
  12954. resp, requestErr := http.Get(api)
  12955. if requestErr != nil {
  12956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12957. return
  12958. }
  12959. body, ioErr := ioutil.ReadAll(resp.Body)
  12960. if ioErr != nil {
  12961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12963. return
  12964. }
  12965. var respJSON map[string]interface{}
  12966. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12969. return
  12970. }
  12971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12972. result, _ := json.Marshal(respJSON)
  12973. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12974. utils.ErrorLog("解析失败:%v", err)
  12975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12976. return
  12977. }
  12978. res.ErrMsg = res10265.ErrMsg
  12979. res.Output = res10265.Output
  12980. res.InfRefmsgid = res10265.InfRefmsgid
  12981. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12982. res.Infcode = infocode
  12983. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12984. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12985. var api string
  12986. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12987. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12988. resp, requestErr := http.Get(api)
  12989. if requestErr != nil {
  12990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12991. return
  12992. }
  12993. body, ioErr := ioutil.ReadAll(resp.Body)
  12994. if ioErr != nil {
  12995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12997. return
  12998. }
  12999. var respJSON map[string]interface{}
  13000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13003. return
  13004. }
  13005. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13006. if status == "0" {
  13007. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13008. c.ServeSuccessJSON(map[string]interface{}{
  13009. "failed_code": -10,
  13010. "msg": err_msg,
  13011. })
  13012. return
  13013. }
  13014. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13015. result, _ := json.Marshal(respJSON)
  13016. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13017. utils.ErrorLog("解析失败:%v", err)
  13018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13019. return
  13020. }
  13021. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13022. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  13023. var api string
  13024. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13025. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13026. resp, requestErr := http.Get(api)
  13027. if requestErr != nil {
  13028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13029. return
  13030. }
  13031. body, ioErr := ioutil.ReadAll(resp.Body)
  13032. if ioErr != nil {
  13033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13035. return
  13036. }
  13037. var respJSON map[string]interface{}
  13038. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13041. return
  13042. }
  13043. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13044. if status == "0" {
  13045. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13046. c.ServeSuccessJSON(map[string]interface{}{
  13047. "failed_code": -10,
  13048. "msg": err_msg,
  13049. })
  13050. return
  13051. }
  13052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13053. result, _ := json.Marshal(respJSON)
  13054. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13055. utils.ErrorLog("解析失败:%v", err)
  13056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13057. return
  13058. }
  13059. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13060. p, _ := service.GetHisPatientById(patient_id)
  13061. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13062. var dat map[string]interface{}
  13063. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13064. fmt.Println(dat)
  13065. } else {
  13066. fmt.Println(err)
  13067. }
  13068. userJSONBytes, _ := json.Marshal(dat)
  13069. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13070. utils.ErrorLog("解析失败:%v", err)
  13071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13072. return
  13073. }
  13074. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13075. p, _ := service.GetHisPatientById(patient_id)
  13076. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13077. var dat map[string]interface{}
  13078. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13079. fmt.Println(dat)
  13080. } else {
  13081. fmt.Println(err)
  13082. }
  13083. userJSONBytes, _ := json.Marshal(dat)
  13084. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13085. utils.ErrorLog("解析失败:%v", err)
  13086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13087. return
  13088. }
  13089. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13090. p, _ := service.GetHisPatientById(patient_id)
  13091. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13092. var dat map[string]interface{}
  13093. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13094. fmt.Println(dat)
  13095. } else {
  13096. fmt.Println(err)
  13097. }
  13098. userJSONBytes, _ := json.Marshal(dat)
  13099. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13100. utils.ErrorLog("解析失败:%v", err)
  13101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13102. return
  13103. }
  13104. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13105. p, _ := service.GetHisPatientById(patient_id)
  13106. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13107. var dat map[string]interface{}
  13108. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13109. fmt.Println(dat)
  13110. } else {
  13111. fmt.Println(err)
  13112. }
  13113. userJSONBytes, _ := json.Marshal(dat)
  13114. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13115. utils.ErrorLog("解析失败:%v", err)
  13116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13117. return
  13118. }
  13119. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13120. p, _ := service.GetHisPatientById(patient_id)
  13121. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13122. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13123. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13124. resp, requestErr := http.Get(api)
  13125. if requestErr != nil {
  13126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13127. return
  13128. }
  13129. body, ioErr := ioutil.ReadAll(resp.Body)
  13130. if ioErr != nil {
  13131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13133. return
  13134. }
  13135. var respJSON map[string]interface{}
  13136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13139. return
  13140. }
  13141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13142. result, _ := json.Marshal(respJSON)
  13143. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13144. utils.ErrorLog("解析失败:%v", err)
  13145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13146. return
  13147. }
  13148. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13149. p, _ := service.GetHisPatientById(patient_id)
  13150. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  13151. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13152. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13153. resp, requestErr := http.Get(api)
  13154. if requestErr != nil {
  13155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13156. return
  13157. }
  13158. body, ioErr := ioutil.ReadAll(resp.Body)
  13159. if ioErr != nil {
  13160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13162. return
  13163. }
  13164. var respJSON map[string]interface{}
  13165. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13168. return
  13169. }
  13170. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13171. result, _ := json.Marshal(respJSON)
  13172. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13173. utils.ErrorLog("解析失败:%v", err)
  13174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13175. return
  13176. }
  13177. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13178. p, _ := service.GetHisPatientById(patient_id)
  13179. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13180. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13181. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13182. resp, requestErr := http.Get(api)
  13183. if requestErr != nil {
  13184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13185. return
  13186. }
  13187. body, ioErr := ioutil.ReadAll(resp.Body)
  13188. if ioErr != nil {
  13189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13191. return
  13192. }
  13193. var respJSON map[string]interface{}
  13194. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13197. return
  13198. }
  13199. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13200. result, _ := json.Marshal(respJSON)
  13201. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13202. utils.ErrorLog("解析失败:%v", err)
  13203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13204. return
  13205. }
  13206. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13207. p, _ := service.GetHisPatientById(patient_id)
  13208. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13209. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13210. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13211. resp, requestErr := http.Get(api)
  13212. if requestErr != nil {
  13213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13214. return
  13215. }
  13216. body, ioErr := ioutil.ReadAll(resp.Body)
  13217. if ioErr != nil {
  13218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13220. return
  13221. }
  13222. var respJSON map[string]interface{}
  13223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13226. return
  13227. }
  13228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13229. result, _ := json.Marshal(respJSON)
  13230. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13231. utils.ErrorLog("解析失败:%v", err)
  13232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13233. return
  13234. }
  13235. } else if miConfig.MdtrtareaAdmvs == "421300" {
  13236. p, _ := service.GetHisPatientById(patient_id)
  13237. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13238. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13239. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13240. resp, requestErr := http.Get(api)
  13241. if requestErr != nil {
  13242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13243. return
  13244. }
  13245. body, ioErr := ioutil.ReadAll(resp.Body)
  13246. if ioErr != nil {
  13247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13249. return
  13250. }
  13251. var respJSON map[string]interface{}
  13252. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13255. return
  13256. }
  13257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13258. result, _ := json.Marshal(respJSON)
  13259. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13260. utils.ErrorLog("解析失败:%v", err)
  13261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13262. return
  13263. }
  13264. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13265. p, _ := service.GetHisPatientById(patient_id)
  13266. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  13267. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13268. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13269. resp, requestErr := http.Get(api)
  13270. if requestErr != nil {
  13271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13272. return
  13273. }
  13274. body, ioErr := ioutil.ReadAll(resp.Body)
  13275. if ioErr != nil {
  13276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13278. return
  13279. }
  13280. var respJSON map[string]interface{}
  13281. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13284. return
  13285. }
  13286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13287. result, _ := json.Marshal(respJSON)
  13288. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13289. utils.ErrorLog("解析失败:%v", err)
  13290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13291. return
  13292. }
  13293. } else {
  13294. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  13295. var dat map[string]interface{}
  13296. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13297. fmt.Println(dat)
  13298. } else {
  13299. fmt.Println(err)
  13300. }
  13301. userJSONBytes, _ := json.Marshal(dat)
  13302. if miConfig.Code == "H15049901371" {
  13303. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13304. utils.ErrorLog("解析失败:%v", err)
  13305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13306. return
  13307. }
  13308. res.InfRefmsgid = res10265.InfRefmsgid
  13309. res.Output = res10265.Output
  13310. res.ErrMsg = res10265.ErrMsg
  13311. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13312. res.Infcode = infocode
  13313. } else {
  13314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13315. utils.ErrorLog("解析失败:%v", err)
  13316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13317. return
  13318. }
  13319. }
  13320. }
  13321. if res.Infcode == 0 {
  13322. c.ServeSuccessJSON(map[string]interface{}{
  13323. "result": res.Output.Result,
  13324. })
  13325. }
  13326. }
  13327. func (c *HisApiController) CheckInsutype() {
  13328. his_patient_id, _ := c.GetInt64("his_patient_id")
  13329. admin_user_id, _ := c.GetInt64("admin_user_id")
  13330. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13331. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13332. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13333. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13334. var dat map[string]interface{}
  13335. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13336. fmt.Println(dat)
  13337. } else {
  13338. fmt.Println(err)
  13339. }
  13340. userJSONBytes, _ := json.Marshal(dat)
  13341. var res Result90100
  13342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13343. utils.ErrorLog("解析失败:%v", err)
  13344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13345. return
  13346. }
  13347. if res.Infcode != 0 {
  13348. c.ServeSuccessJSON(map[string]interface{}{
  13349. "failed_code": -10,
  13350. "msg": res.ErrMsg,
  13351. })
  13352. return
  13353. } else {
  13354. fmt.Println(res)
  13355. }
  13356. }
  13357. func (c *HisApiController) CheckCardPWD() {
  13358. card_pwd := c.GetString("card_pwd")
  13359. his_patient_id, _ := c.GetInt64("his_patient_id")
  13360. admin_user_id, _ := c.GetInt64("admin_user_id")
  13361. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13362. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13363. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13364. psn, _ := service.GetPsnByPatientId(his.PatientId)
  13365. bas := strings.Split(psn.CardInfo, "|")
  13366. basNumber := bas[2]
  13367. if psn.InsuplcAdmdvs[:4] == "4403" {
  13368. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  13369. var dat map[string]interface{}
  13370. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13371. fmt.Println(dat)
  13372. } else {
  13373. fmt.Println(err)
  13374. }
  13375. userJSONBytes, _ := json.Marshal(dat)
  13376. var res Result90991
  13377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13378. utils.ErrorLog("解析失败:%v", err)
  13379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13380. return
  13381. }
  13382. if res.Infcode != 0 {
  13383. c.ServeSuccessJSON(map[string]interface{}{
  13384. "failed_code": -10,
  13385. "msg": res.ErrMsg,
  13386. })
  13387. return
  13388. } else {
  13389. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  13390. var msg string
  13391. switch res.Output.Result.CardStat {
  13392. case "00":
  13393. msg = "未激活"
  13394. break
  13395. case "10":
  13396. msg = "激活"
  13397. break
  13398. case "20":
  13399. msg = "窗口挂失"
  13400. break
  13401. case "21":
  13402. msg = "电话挂失"
  13403. break
  13404. case "22":
  13405. msg = "单位网上申报挂失"
  13406. break
  13407. case "23":
  13408. msg = "保健办挂失"
  13409. break
  13410. case "24":
  13411. msg = "个人网上挂失"
  13412. break
  13413. case "25":
  13414. msg = "网上服务大厅挂失"
  13415. break
  13416. case "30":
  13417. msg = "注销"
  13418. break
  13419. case "40":
  13420. msg = "回收"
  13421. break
  13422. case "99":
  13423. msg = "制卡中(无效卡)"
  13424. break
  13425. }
  13426. c.ServeSuccessJSON(map[string]interface{}{
  13427. "failed_code": -10,
  13428. "msg": msg,
  13429. })
  13430. return
  13431. } else {
  13432. c.ServeSuccessJSON(map[string]interface{}{
  13433. "msg": "校验成功",
  13434. })
  13435. return
  13436. }
  13437. }
  13438. } else {
  13439. c.ServeSuccessJSON(map[string]interface{}{
  13440. "msg": "校验成功",
  13441. })
  13442. return
  13443. }
  13444. }
  13445. func (c *HisApiController) CheckCardPWDTwo() {
  13446. //card_pwd := c.GetString("card_pwd")
  13447. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13448. admin_user_id, _ := c.GetInt64("admin_user_id")
  13449. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13450. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13451. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  13452. var dat map[string]interface{}
  13453. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13454. fmt.Println(dat)
  13455. } else {
  13456. fmt.Println(err)
  13457. }
  13458. userJSONBytes, _ := json.Marshal(dat)
  13459. var res Result90991
  13460. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13461. utils.ErrorLog("解析失败:%v", err)
  13462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13463. return
  13464. }
  13465. if res.Infcode != 0 {
  13466. c.ServeSuccessJSON(map[string]interface{}{
  13467. "failed_code": -10,
  13468. "msg": res.ErrMsg,
  13469. })
  13470. return
  13471. } else {
  13472. if res.Output.Result.SscnoCheckStat == "0" {
  13473. var msg string
  13474. switch res.Output.Result.CardStat {
  13475. case "00":
  13476. msg = "未激活"
  13477. break
  13478. case "10":
  13479. msg = "激活"
  13480. break
  13481. case "20":
  13482. msg = "窗口挂失"
  13483. break
  13484. case "21":
  13485. msg = "电话挂失"
  13486. break
  13487. case "22":
  13488. msg = "单位网上申报挂失"
  13489. break
  13490. case "23":
  13491. msg = "保健办挂失"
  13492. break
  13493. case "24":
  13494. msg = "个人网上挂失"
  13495. break
  13496. case "25":
  13497. msg = "网上服务大厅挂失"
  13498. break
  13499. case "30":
  13500. msg = "注销"
  13501. break
  13502. case "40":
  13503. msg = "回收"
  13504. break
  13505. case "99":
  13506. msg = "制卡中(无效卡)"
  13507. break
  13508. }
  13509. c.ServeSuccessJSON(map[string]interface{}{
  13510. "failed_code": -10,
  13511. "msg": msg,
  13512. })
  13513. return
  13514. } else {
  13515. c.ServeSuccessJSON(map[string]interface{}{
  13516. "msg": "校验成功",
  13517. })
  13518. return
  13519. }
  13520. }
  13521. }
  13522. type ELeCertData struct {
  13523. Data struct {
  13524. Extra string `json:"extra"`
  13525. IDNo string `json:"idNo"`
  13526. IDType string `json:"idType"`
  13527. EcToken string `json:"ecToken"`
  13528. InsuOrg string `json:"insuOrg"`
  13529. UserName string `json:"userName"`
  13530. EcIndexNo string `json:"ecIndexNo"`
  13531. Gender string `json:"gender"`
  13532. Birthday string `json:"birthday"`
  13533. Nationality string `json:"nationality"`
  13534. Email string `json:"email"`
  13535. } `json:"OutData"`
  13536. }
  13537. func (c *HisApiController) ReadCard() {
  13538. id_card_type, _ := c.GetInt64("id_card_type")
  13539. admin_user_id, _ := c.GetInt64("admin_user_id")
  13540. certificates, _ := c.GetInt64("certificates")
  13541. //
  13542. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13543. id_card_no := c.GetString("id_card_no")
  13544. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13545. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13546. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13547. switch id_card_type {
  13548. case 1:
  13549. if miConfig.MdtrtareaAdmvs == "421300" {
  13550. var res ResultTwo
  13551. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13552. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13553. "&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)
  13554. resp, requestErr := http.Get(api)
  13555. if requestErr != nil {
  13556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13557. return
  13558. }
  13559. body, ioErr := ioutil.ReadAll(resp.Body)
  13560. if ioErr != nil {
  13561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13563. return
  13564. }
  13565. var respJSON map[string]interface{}
  13566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13569. return
  13570. }
  13571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13572. result, _ := json.Marshal(respJSON)
  13573. fmt.Println("log")
  13574. fmt.Println(string(result))
  13575. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13576. utils.ErrorLog("解析失败:%v", err)
  13577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13578. return
  13579. }
  13580. if res.Infcode == 0 {
  13581. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13582. if err == gorm.ErrRecordNotFound {
  13583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13584. return
  13585. } else if err != nil {
  13586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13587. return
  13588. } else {
  13589. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13590. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13591. infoStr := string(Iinfos)
  13592. idetinfoStr := string(Idetinfos)
  13593. var rf []*ResultFive
  13594. json.Unmarshal([]byte(infoStr), &rf)
  13595. var insutypes []*ResultFive
  13596. var insutype string
  13597. var is390 int = 0
  13598. var is310 int = 0
  13599. for _, item := range rf {
  13600. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13601. insutypes = append(insutypes, item)
  13602. }
  13603. }
  13604. if len(insutypes) == 1 {
  13605. insutype = insutypes[0].Insutype
  13606. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13607. } else {
  13608. for _, i := range insutypes {
  13609. if i.Insutype == "390" {
  13610. is390 = 1
  13611. }
  13612. if i.Insutype == "310" {
  13613. is310 = 1
  13614. }
  13615. }
  13616. }
  13617. if is390 == 1 {
  13618. insutype = "390"
  13619. }
  13620. if is310 == 1 {
  13621. insutype = "310"
  13622. }
  13623. if len(insutypes) == 0 {
  13624. insutype = "390"
  13625. }
  13626. var insuplc_admdvs string
  13627. for _, item := range rf {
  13628. if item.Insutype == insutype {
  13629. insuplc_admdvs = item.InsuplcAdmdvs
  13630. }
  13631. }
  13632. if strings.Contains(insuplc_admdvs, "4213") {
  13633. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13634. }
  13635. psn := &models.HisPsn{
  13636. PsnNo: res.Output.Baseinfo.PsnNo,
  13637. PatientId: patient.ID,
  13638. Certno: res.Output.Baseinfo.Certno,
  13639. Gend: res.Output.Baseinfo.Gend,
  13640. Naty: res.Output.Baseinfo.Naty,
  13641. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13642. PsnName: res.Output.Baseinfo.PsnName,
  13643. Idetinfo: idetinfoStr,
  13644. Insuinfo: infoStr,
  13645. InsuplcAdmdvs: insuplc_admdvs,
  13646. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13647. }
  13648. service.CreateHisPsn(psn)
  13649. c.ServeSuccessJSON(map[string]interface{}{
  13650. "patient": patient,
  13651. "number": res.Output.Baseinfo.Certno,
  13652. })
  13653. }
  13654. } else {
  13655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13656. return
  13657. }
  13658. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13659. var res ResultTwo
  13660. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13661. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13662. "&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)
  13663. resp, requestErr := http.Get(api)
  13664. if requestErr != nil {
  13665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13666. return
  13667. }
  13668. body, ioErr := ioutil.ReadAll(resp.Body)
  13669. if ioErr != nil {
  13670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13672. return
  13673. }
  13674. var respJSON map[string]interface{}
  13675. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13678. return
  13679. }
  13680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13681. result, _ := json.Marshal(respJSON)
  13682. fmt.Println("log")
  13683. fmt.Println(string(result))
  13684. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13685. utils.ErrorLog("解析失败:%v", err)
  13686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13687. return
  13688. }
  13689. if res.Infcode == 0 {
  13690. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13691. if err == gorm.ErrRecordNotFound {
  13692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13693. return
  13694. } else if err != nil {
  13695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13696. return
  13697. } else {
  13698. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13699. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13700. infoStr := string(Iinfos)
  13701. idetinfoStr := string(Idetinfos)
  13702. psn := &models.HisPsn{
  13703. PsnNo: res.Output.Baseinfo.PsnNo,
  13704. PatientId: patient.ID,
  13705. Certno: res.Output.Baseinfo.Certno,
  13706. Gend: res.Output.Baseinfo.Gend,
  13707. Naty: res.Output.Baseinfo.Naty,
  13708. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13709. PsnName: res.Output.Baseinfo.PsnName,
  13710. Idetinfo: idetinfoStr,
  13711. Insuinfo: infoStr,
  13712. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13713. }
  13714. service.CreateHisPsn(psn)
  13715. var rf []*ResultFive
  13716. json.Unmarshal([]byte(infoStr), &rf)
  13717. var insutypes []*ResultFive
  13718. var insutype string
  13719. var is390 int = 0
  13720. var is310 int = 0
  13721. for _, item := range rf {
  13722. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13723. insutypes = append(insutypes, item)
  13724. }
  13725. }
  13726. if len(insutypes) == 1 {
  13727. insutype = insutypes[0].Insutype
  13728. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13729. } else {
  13730. for _, i := range insutypes {
  13731. if i.Insutype == "390" {
  13732. is390 = 1
  13733. }
  13734. if i.Insutype == "310" {
  13735. is310 = 1
  13736. }
  13737. }
  13738. }
  13739. if is390 == 1 {
  13740. insutype = "390"
  13741. }
  13742. if is310 == 1 {
  13743. insutype = "310"
  13744. }
  13745. if len(insutypes) == 0 {
  13746. insutype = "310"
  13747. }
  13748. c.ServeSuccessJSON(map[string]interface{}{
  13749. "patient": patient,
  13750. "number": res.Output.Baseinfo.Certno,
  13751. "insutype": insutype,
  13752. })
  13753. }
  13754. } else {
  13755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13756. return
  13757. }
  13758. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13759. var res ResultTwo
  13760. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13761. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13762. "&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)
  13763. resp, requestErr := http.Get(api)
  13764. if requestErr != nil {
  13765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13766. return
  13767. }
  13768. body, ioErr := ioutil.ReadAll(resp.Body)
  13769. if ioErr != nil {
  13770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13772. return
  13773. }
  13774. var respJSON map[string]interface{}
  13775. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13778. return
  13779. }
  13780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13781. result, _ := json.Marshal(respJSON)
  13782. fmt.Println("log")
  13783. fmt.Println(string(result))
  13784. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13785. utils.ErrorLog("解析失败:%v", err)
  13786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13787. return
  13788. }
  13789. if res.Infcode == 0 {
  13790. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13791. if err == gorm.ErrRecordNotFound {
  13792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13793. return
  13794. } else if err != nil {
  13795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13796. return
  13797. } else {
  13798. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13799. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13800. infoStr := string(Iinfos)
  13801. idetinfoStr := string(Idetinfos)
  13802. var rf []*ResultFive
  13803. json.Unmarshal([]byte(infoStr), &rf)
  13804. var insutypes []*ResultFive
  13805. var insutype string
  13806. var is390 int = 0
  13807. var is310 int = 0
  13808. for _, item := range rf {
  13809. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13810. insutypes = append(insutypes, item)
  13811. }
  13812. }
  13813. if len(insutypes) == 1 {
  13814. insutype = insutypes[0].Insutype
  13815. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13816. } else {
  13817. for _, i := range insutypes {
  13818. if i.Insutype == "390" {
  13819. is390 = 1
  13820. }
  13821. if i.Insutype == "310" {
  13822. is310 = 1
  13823. }
  13824. }
  13825. }
  13826. if is390 == 1 {
  13827. insutype = "390"
  13828. }
  13829. if is310 == 1 {
  13830. insutype = "310"
  13831. }
  13832. if len(insutypes) == 0 {
  13833. insutype = "390"
  13834. }
  13835. var insuplc_admdvs string
  13836. for _, item := range rf {
  13837. if item.Insutype == insutype {
  13838. insuplc_admdvs = item.InsuplcAdmdvs
  13839. }
  13840. }
  13841. psn := &models.HisPsn{
  13842. PsnNo: res.Output.Baseinfo.PsnNo,
  13843. PatientId: patient.ID,
  13844. Certno: res.Output.Baseinfo.Certno,
  13845. Gend: res.Output.Baseinfo.Gend,
  13846. Naty: res.Output.Baseinfo.Naty,
  13847. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13848. PsnName: res.Output.Baseinfo.PsnName,
  13849. Idetinfo: idetinfoStr,
  13850. Insuinfo: infoStr,
  13851. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13852. InsuplcAdmdvs: insuplc_admdvs,
  13853. }
  13854. service.CreateHisPsn(psn)
  13855. for _, item := range rf {
  13856. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13857. insutypes = append(insutypes, item)
  13858. }
  13859. }
  13860. if len(insutypes) == 1 {
  13861. insutype = insutypes[0].Insutype
  13862. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13863. } else {
  13864. for _, i := range insutypes {
  13865. if i.Insutype == "390" {
  13866. is390 = 1
  13867. }
  13868. if i.Insutype == "310" {
  13869. is310 = 1
  13870. }
  13871. }
  13872. }
  13873. if is390 == 1 {
  13874. insutype = "390"
  13875. }
  13876. if is310 == 1 {
  13877. insutype = "310"
  13878. }
  13879. if len(insutypes) == 0 {
  13880. insutype = "310"
  13881. }
  13882. c.ServeSuccessJSON(map[string]interface{}{
  13883. "patient": patient,
  13884. "number": res.Output.Baseinfo.Certno,
  13885. "insutype": insutype,
  13886. })
  13887. }
  13888. } else {
  13889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13890. return
  13891. }
  13892. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13893. var res ResultTwo
  13894. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13895. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13896. "&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)
  13897. resp, requestErr := http.Get(api)
  13898. if requestErr != nil {
  13899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13900. return
  13901. }
  13902. body, ioErr := ioutil.ReadAll(resp.Body)
  13903. if ioErr != nil {
  13904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13906. return
  13907. }
  13908. var respJSON map[string]interface{}
  13909. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13912. return
  13913. }
  13914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13915. result, _ := json.Marshal(respJSON)
  13916. fmt.Println("log")
  13917. fmt.Println(string(result))
  13918. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13919. utils.ErrorLog("解析失败:%v", err)
  13920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13921. return
  13922. }
  13923. if res.Infcode == 0 {
  13924. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13925. if err == gorm.ErrRecordNotFound {
  13926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13927. return
  13928. } else if err != nil {
  13929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13930. return
  13931. } else {
  13932. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13933. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13934. infoStr := string(Iinfos)
  13935. idetinfoStr := string(Idetinfos)
  13936. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13937. psn := &models.HisPsn{
  13938. PsnNo: res.Output.Baseinfo.PsnNo,
  13939. PatientId: patient.ID,
  13940. Certno: res.Output.Baseinfo.Certno,
  13941. Brdy: b,
  13942. Age: float64(age),
  13943. Gend: res.Output.Baseinfo.Gend,
  13944. Naty: res.Output.Baseinfo.Naty,
  13945. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13946. PsnName: res.Output.Baseinfo.PsnName,
  13947. Idetinfo: idetinfoStr,
  13948. Insuinfo: infoStr,
  13949. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13950. }
  13951. service.CreateHisPsn(psn)
  13952. var rf []*ResultFive
  13953. json.Unmarshal([]byte(infoStr), &rf)
  13954. var insutypes []*ResultFive
  13955. var insutype string
  13956. var is390 int = 0
  13957. var is310 int = 0
  13958. for _, item := range rf {
  13959. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13960. insutypes = append(insutypes, item)
  13961. }
  13962. }
  13963. if len(insutypes) == 1 {
  13964. insutype = insutypes[0].Insutype
  13965. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13966. } else {
  13967. for _, i := range insutypes {
  13968. if i.Insutype == "390" {
  13969. is390 = 1
  13970. }
  13971. if i.Insutype == "310" {
  13972. is310 = 1
  13973. }
  13974. }
  13975. }
  13976. if is390 == 1 {
  13977. insutype = "390"
  13978. }
  13979. if is310 == 1 {
  13980. insutype = "310"
  13981. }
  13982. if len(insutypes) == 0 {
  13983. insutype = "310"
  13984. }
  13985. c.ServeSuccessJSON(map[string]interface{}{
  13986. "patient": patient,
  13987. "number": res.Output.Baseinfo.Certno,
  13988. "insutype": insutype,
  13989. })
  13990. }
  13991. } else {
  13992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13993. return
  13994. }
  13995. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  13996. var api string
  13997. if miConfig.MdtrtareaAdmvs == "320830" {
  13998. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13999. "&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
  14000. fmt.Println(api)
  14001. } else if miConfig.MdtrtareaAdmvs == "320921" {
  14002. 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 +
  14003. "&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
  14004. fmt.Println(api)
  14005. } else {
  14006. 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 +
  14007. "&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)
  14008. }
  14009. resp, requestErr := http.Get(api)
  14010. if requestErr != nil {
  14011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14012. return
  14013. }
  14014. body, ioErr := ioutil.ReadAll(resp.Body)
  14015. if ioErr != nil {
  14016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14018. return
  14019. }
  14020. var respJSON map[string]interface{}
  14021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14024. return
  14025. }
  14026. var status string
  14027. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14028. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14029. //console.log()
  14030. fmt.Println("type===")
  14031. fmt.Println(card_type)
  14032. var token string
  14033. var res ResultTwo //1101结果
  14034. var res10265 ResultTwo10265 //1101结果
  14035. var card_info string //卡信息
  14036. var busi_card_info string
  14037. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14038. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14039. if status == "0" { //读卡成功
  14040. if card_type == "1" {
  14041. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14042. result, _ := json.Marshal(respJSON)
  14043. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14044. utils.ErrorLog("解析失败:%v", err)
  14045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14046. return
  14047. }
  14048. res.ErrMsg = res10265.ErrMsg
  14049. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14050. res.Infcode = infocode
  14051. res.Output = res10265.Output
  14052. res.InfRefmsgid = res10265.InfRefmsgid
  14053. } else {
  14054. //var card_info string //卡信息
  14055. //var busi_card_info string
  14056. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14057. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14058. //fmt.Println(card_info)
  14059. //fmt.Println(busi_card_info)
  14060. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14061. result, _ := json.Marshal(respJSON)
  14062. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14063. utils.ErrorLog("解析失败:%v", err)
  14064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14065. return
  14066. }
  14067. res.ErrMsg = res10265.ErrMsg
  14068. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14069. res.Infcode = infocode
  14070. res.Output = res10265.Output
  14071. res.InfRefmsgid = res10265.InfRefmsgid
  14072. }
  14073. if res.Infcode == 0 {
  14074. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14075. if err == gorm.ErrRecordNotFound {
  14076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14077. return
  14078. } else if err != nil {
  14079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14080. return
  14081. } else {
  14082. if card_type == "1" {
  14083. bas := strings.Split(card_info, "|")
  14084. basNumber := bas[2]
  14085. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14086. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14087. infoStr := string(Iinfos)
  14088. idetinfoStr := string(Idetinfos)
  14089. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14090. psn := &models.HisPsn{
  14091. PsnNo: res.Output.Baseinfo.PsnNo,
  14092. PatientId: patient.ID,
  14093. Certno: res.Output.Baseinfo.Certno,
  14094. Brdy: b,
  14095. Age: float64(age),
  14096. Gend: res.Output.Baseinfo.Gend,
  14097. Naty: res.Output.Baseinfo.Naty,
  14098. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14099. PsnName: res.Output.Baseinfo.PsnName,
  14100. Idetinfo: idetinfoStr,
  14101. Insuinfo: infoStr,
  14102. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14103. CardInfo: card_info,
  14104. VerifyNumber: busi_card_info,
  14105. }
  14106. service.CreateHisPsn(psn)
  14107. var rf []*ResultFive
  14108. json.Unmarshal([]byte(infoStr), &rf)
  14109. var insutypes []*ResultFive
  14110. var insutype string
  14111. var is390 int = 0
  14112. var is310 int = 0
  14113. for _, item := range rf {
  14114. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14115. insutypes = append(insutypes, item)
  14116. }
  14117. }
  14118. if len(insutypes) == 1 {
  14119. insutype = insutypes[0].Insutype
  14120. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14121. } else {
  14122. for _, i := range insutypes {
  14123. if i.Insutype == "390" {
  14124. is390 = 1
  14125. }
  14126. if i.Insutype == "310" {
  14127. is310 = 1
  14128. }
  14129. }
  14130. }
  14131. if is390 == 1 {
  14132. insutype = "390"
  14133. }
  14134. if is310 == 1 {
  14135. insutype = "310"
  14136. }
  14137. if len(insutypes) == 0 {
  14138. insutype = "310"
  14139. }
  14140. c.ServeSuccessJSON(map[string]interface{}{
  14141. "patient": patient,
  14142. "number": basNumber,
  14143. "insutype": insutype,
  14144. })
  14145. } else {
  14146. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14147. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14148. infoStr := string(Iinfos)
  14149. idetinfoStr := string(Idetinfos)
  14150. psn := &models.HisPsn{
  14151. PsnNo: res.Output.Baseinfo.PsnNo,
  14152. PatientId: patient.ID,
  14153. Certno: res.Output.Baseinfo.Certno,
  14154. Gend: res.Output.Baseinfo.Gend,
  14155. Naty: res.Output.Baseinfo.Naty,
  14156. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14157. PsnName: res.Output.Baseinfo.PsnName,
  14158. Idetinfo: idetinfoStr,
  14159. Insuinfo: infoStr,
  14160. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14161. CardInfo: card_info,
  14162. VerifyNumber: token,
  14163. }
  14164. service.CreateHisPsn(psn)
  14165. c.ServeSuccessJSON(map[string]interface{}{
  14166. "patient": patient,
  14167. "number": token,
  14168. })
  14169. }
  14170. }
  14171. } else {
  14172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14173. return
  14174. }
  14175. } else { //读卡失败
  14176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14177. return
  14178. }
  14179. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14180. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  14181. cardnum = DeleteExtraSpaceTwo(cardnum)
  14182. cardCode = DeleteExtraSpaceTwo(cardCode)
  14183. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  14184. name = DeleteExtraSpaceTwo(name)
  14185. errmsg = DeleteExtraSpaceTwo(errmsg)
  14186. cardnum = Remove0000(cardnum)
  14187. cardCode = Remove0000(cardCode)
  14188. id_card_no = Remove0000(id_card_no)
  14189. name = Remove0000(name)
  14190. errmsg = Remove0000(errmsg)
  14191. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  14192. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  14193. //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)
  14194. //fmt.Println(result2)
  14195. //fmt.Println(requestLog2)
  14196. //fmt.Println(errMsgLog2)
  14197. 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)
  14198. saveLog(result, requestLog, "1101", "获取人员信息")
  14199. fmt.Println(errMsgLog)
  14200. if len(errMsgLog) > 0 {
  14201. } else {
  14202. var dat map[string]interface{}
  14203. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14204. fmt.Println(dat)
  14205. } else {
  14206. fmt.Println(err)
  14207. }
  14208. userJSONBytes, _ := json.Marshal(dat)
  14209. var res ResultTwo
  14210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14211. utils.ErrorLog("解析失败:%v", err)
  14212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14213. return
  14214. }
  14215. res.ErrMsg = errMsgLog
  14216. if res.Infcode == 0 {
  14217. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14218. if err == gorm.ErrRecordNotFound {
  14219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14220. return
  14221. } else if err != nil {
  14222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14223. return
  14224. } else {
  14225. fmt.Println(res)
  14226. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14227. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14228. infoStr := string(Iinfos)
  14229. idetinfoStr := string(Idetinfos)
  14230. var rf []*ResultFive
  14231. json.Unmarshal([]byte(infoStr), &rf)
  14232. var insutypes []*ResultFive
  14233. var insutype string
  14234. var is390 int = 0
  14235. var is310 int = 0
  14236. for _, item := range rf {
  14237. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14238. insutypes = append(insutypes, item)
  14239. }
  14240. }
  14241. if len(insutypes) == 1 {
  14242. insutype = insutypes[0].Insutype
  14243. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14244. } else {
  14245. for _, i := range insutypes {
  14246. if i.Insutype == "390" {
  14247. is390 = 1
  14248. }
  14249. if i.Insutype == "310" {
  14250. is310 = 1
  14251. }
  14252. }
  14253. }
  14254. if is390 == 1 {
  14255. insutype = "390"
  14256. }
  14257. if is310 == 1 {
  14258. insutype = "310"
  14259. }
  14260. if len(insutypes) == 0 {
  14261. insutype = "390"
  14262. }
  14263. var insuplc_admdvs string
  14264. for _, item := range rf {
  14265. if item.Insutype == insutype {
  14266. insuplc_admdvs = item.InsuplcAdmdvs
  14267. }
  14268. }
  14269. psn := &models.HisPsn{
  14270. PsnNo: res.Output.Baseinfo.PsnNo,
  14271. PatientId: patient.ID,
  14272. Certno: res.Output.Baseinfo.Certno,
  14273. Gend: res.Output.Baseinfo.Gend,
  14274. Naty: res.Output.Baseinfo.Naty,
  14275. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14276. PsnName: res.Output.Baseinfo.PsnName,
  14277. Idetinfo: idetinfoStr,
  14278. Insuinfo: infoStr,
  14279. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14280. CardInfo: basStr,
  14281. VerifyNumber: "",
  14282. InsuplcAdmdvs: insuplc_admdvs,
  14283. }
  14284. service.CreateHisPsn(psn)
  14285. c.ServeSuccessJSON(map[string]interface{}{
  14286. "patient": patient,
  14287. "number": cardnum,
  14288. "insutype": insutype,
  14289. })
  14290. }
  14291. } else {
  14292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14293. return
  14294. }
  14295. }
  14296. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14297. fmt.Println(initFlag)
  14298. fmt.Println("initFlag")
  14299. if initFlag == 0 {
  14300. c.TestGetJiangXiBasBaseInit()
  14301. }
  14302. basStr := c.GetBasBaseInfo()
  14303. if len(basStr) == 0 {
  14304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14305. return
  14306. }
  14307. fmt.Println(basStr)
  14308. bas := strings.Split(basStr, "|")
  14309. basNumber := bas[1]
  14310. fmt.Println(basNumber)
  14311. card := bas[2]
  14312. card_sn := bas[3]
  14313. fmt.Println(card_sn)
  14314. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14315. 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)
  14316. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14317. var dat map[string]interface{}
  14318. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14319. fmt.Println(dat)
  14320. } else {
  14321. fmt.Println(err)
  14322. }
  14323. userJSONBytes, _ := json.Marshal(dat)
  14324. var res ResultTwo
  14325. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14326. utils.ErrorLog("解析失败:%v", err)
  14327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14328. return
  14329. }
  14330. if res.Infcode == 0 {
  14331. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14332. if err == gorm.ErrRecordNotFound {
  14333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14334. return
  14335. } else if err != nil {
  14336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14337. return
  14338. } else {
  14339. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14340. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14341. infoStr := string(Iinfos)
  14342. idetinfoStr := string(Idetinfos)
  14343. var rf []*ResultFive
  14344. json.Unmarshal([]byte(infoStr), &rf)
  14345. var insutypes []*ResultFive
  14346. var insutype string
  14347. var is390 int = 0
  14348. var is310 int = 0
  14349. var insuplc_admdvs string
  14350. for _, item := range rf {
  14351. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14352. insutypes = append(insutypes, item)
  14353. }
  14354. }
  14355. if len(insutypes) == 1 {
  14356. insutype = insutypes[0].Insutype
  14357. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14358. } else {
  14359. for _, i := range insutypes {
  14360. if i.Insutype == "390" {
  14361. is390 = 1
  14362. }
  14363. if i.Insutype == "310" {
  14364. is310 = 1
  14365. }
  14366. }
  14367. }
  14368. if is390 == 1 {
  14369. insutype = "390"
  14370. }
  14371. if is310 == 1 {
  14372. insutype = "310"
  14373. }
  14374. if len(insutypes) == 0 {
  14375. insutype = "310"
  14376. }
  14377. for _, item := range rf {
  14378. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14379. insuplc_admdvs = item.InsuplcAdmdvs
  14380. }
  14381. }
  14382. psn := &models.HisPsn{
  14383. PsnNo: res.Output.Baseinfo.PsnNo,
  14384. PatientId: patient.ID,
  14385. Certno: res.Output.Baseinfo.Certno,
  14386. Gend: res.Output.Baseinfo.Gend,
  14387. Naty: res.Output.Baseinfo.Naty,
  14388. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14389. PsnName: res.Output.Baseinfo.PsnName,
  14390. Idetinfo: idetinfoStr,
  14391. Insuinfo: infoStr,
  14392. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14393. CardInfo: basStr,
  14394. InsuplcAdmdvs: insuplc_admdvs,
  14395. VerifyNumber: "",
  14396. }
  14397. service.CreateHisPsn(psn)
  14398. c.ServeSuccessJSON(map[string]interface{}{
  14399. "patient": patient,
  14400. "number": basNumber,
  14401. "insutype": insutype,
  14402. })
  14403. }
  14404. } else {
  14405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14406. return
  14407. }
  14408. } else if miConfig.MdtrtareaAdmvs == "361025" {
  14409. basStr := c.GetBasBaseInfo22222()
  14410. fmt.Println(basStr)
  14411. if len(basStr) == 0 {
  14412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14413. return
  14414. }
  14415. fmt.Println(basStr)
  14416. bas := strings.Split(basStr, "|")
  14417. basNumber := bas[2] //卡号
  14418. card_sn := bas[3] //
  14419. id_card_No := bas[1] //卡号
  14420. fmt.Println(basNumber)
  14421. fmt.Println(card_sn)
  14422. fmt.Println(id_card_No)
  14423. var patient service.Patients
  14424. if len(id_card_No) == 0 {
  14425. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14426. } else {
  14427. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14428. }
  14429. 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)
  14430. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14431. var dat map[string]interface{}
  14432. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14433. fmt.Println(dat)
  14434. } else {
  14435. fmt.Println(err)
  14436. }
  14437. userJSONBytes, _ := json.Marshal(dat)
  14438. var res ResultTwo
  14439. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14440. utils.ErrorLog("解析失败:%v", err)
  14441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14442. return
  14443. }
  14444. if res.Infcode == 0 {
  14445. var pateint2 service.Patients
  14446. var err error
  14447. if len(id_card_No) == 0 {
  14448. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14449. } else {
  14450. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14451. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14452. }
  14453. if err == gorm.ErrRecordNotFound {
  14454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14455. return
  14456. } else if err != nil {
  14457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14458. return
  14459. } else {
  14460. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14461. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14462. infoStr := string(Iinfos)
  14463. idetinfoStr := string(Idetinfos)
  14464. var rf []*ResultFive
  14465. json.Unmarshal([]byte(infoStr), &rf)
  14466. var insutypes []*ResultFive
  14467. var insutype string
  14468. var is390 int = 0
  14469. var is310 int = 0
  14470. var insuplc_admdvs string
  14471. for _, item := range rf {
  14472. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14473. insutypes = append(insutypes, item)
  14474. }
  14475. }
  14476. if len(insutypes) == 1 {
  14477. insutype = insutypes[0].Insutype
  14478. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14479. } else {
  14480. for _, i := range insutypes {
  14481. if i.Insutype == "390" {
  14482. is390 = 1
  14483. }
  14484. if i.Insutype == "310" {
  14485. is310 = 1
  14486. }
  14487. }
  14488. }
  14489. if is390 == 1 {
  14490. insutype = "390"
  14491. }
  14492. if is310 == 1 {
  14493. insutype = "310"
  14494. }
  14495. if len(insutypes) == 0 {
  14496. insutype = "310"
  14497. }
  14498. for _, item := range rf {
  14499. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14500. insuplc_admdvs = item.InsuplcAdmdvs
  14501. }
  14502. }
  14503. psn := &models.HisPsn{
  14504. PsnNo: res.Output.Baseinfo.PsnNo,
  14505. PatientId: pateint2.ID,
  14506. Certno: res.Output.Baseinfo.Certno,
  14507. Gend: res.Output.Baseinfo.Gend,
  14508. Naty: res.Output.Baseinfo.Naty,
  14509. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14510. PsnName: res.Output.Baseinfo.PsnName,
  14511. Idetinfo: idetinfoStr,
  14512. Insuinfo: infoStr,
  14513. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14514. CardInfo: basStr,
  14515. InsuplcAdmdvs: insuplc_admdvs,
  14516. VerifyNumber: "",
  14517. }
  14518. service.CreateHisPsn(psn)
  14519. c.ServeSuccessJSON(map[string]interface{}{
  14520. "patient": patient,
  14521. "number": basNumber,
  14522. "insutype": insutype,
  14523. })
  14524. }
  14525. } else {
  14526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14527. return
  14528. }
  14529. } else if miConfig.MdtrtareaAdmvs == "360100" {
  14530. fmt.Println(initFlag)
  14531. fmt.Println("initFlag")
  14532. if initFlag == 0 {
  14533. c.TestGetJiangXiBasBaseInittwo()
  14534. }
  14535. basStr := c.GetBasBaseInfo()
  14536. if len(basStr) == 0 {
  14537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14538. return
  14539. }
  14540. fmt.Println(basStr)
  14541. bas := strings.Split(basStr, "|")
  14542. basNumber := bas[1]
  14543. fmt.Println(basNumber)
  14544. card_sn := bas[3]
  14545. fmt.Println(card_sn)
  14546. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14547. 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)
  14548. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14549. var dat map[string]interface{}
  14550. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14551. fmt.Println(dat)
  14552. } else {
  14553. fmt.Println(err)
  14554. }
  14555. userJSONBytes, _ := json.Marshal(dat)
  14556. var res ResultTwo
  14557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14558. utils.ErrorLog("解析失败:%v", err)
  14559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14560. return
  14561. }
  14562. if res.Infcode == 0 {
  14563. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14564. if err == gorm.ErrRecordNotFound {
  14565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14566. return
  14567. } else if err != nil {
  14568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14569. return
  14570. } else {
  14571. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14572. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14573. infoStr := string(Iinfos)
  14574. idetinfoStr := string(Idetinfos)
  14575. var rf []*ResultFive
  14576. json.Unmarshal([]byte(infoStr), &rf)
  14577. var insutypes []*ResultFive
  14578. var insutype string
  14579. var is390 int = 0
  14580. var is310 int = 0
  14581. var insuplc_admdvs string
  14582. for _, item := range rf {
  14583. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14584. insutypes = append(insutypes, item)
  14585. }
  14586. }
  14587. if len(insutypes) == 1 {
  14588. insutype = insutypes[0].Insutype
  14589. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14590. } else {
  14591. for _, i := range insutypes {
  14592. if i.Insutype == "390" {
  14593. is390 = 1
  14594. }
  14595. if i.Insutype == "310" {
  14596. is310 = 1
  14597. }
  14598. }
  14599. }
  14600. if is390 == 1 {
  14601. insutype = "390"
  14602. }
  14603. if is310 == 1 {
  14604. insutype = "310"
  14605. }
  14606. if len(insutypes) == 0 {
  14607. insutype = "310"
  14608. }
  14609. for _, item := range rf {
  14610. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14611. insuplc_admdvs = item.InsuplcAdmdvs
  14612. }
  14613. }
  14614. psn := &models.HisPsn{
  14615. PsnNo: res.Output.Baseinfo.PsnNo,
  14616. PatientId: patient.ID,
  14617. Certno: res.Output.Baseinfo.Certno,
  14618. Gend: res.Output.Baseinfo.Gend,
  14619. Naty: res.Output.Baseinfo.Naty,
  14620. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14621. PsnName: res.Output.Baseinfo.PsnName,
  14622. Idetinfo: idetinfoStr,
  14623. Insuinfo: infoStr,
  14624. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14625. CardInfo: basStr,
  14626. InsuplcAdmdvs: insuplc_admdvs,
  14627. VerifyNumber: "",
  14628. }
  14629. service.CreateHisPsn(psn)
  14630. c.ServeSuccessJSON(map[string]interface{}{
  14631. "patient": patient,
  14632. "number": basNumber,
  14633. "insutype": insutype,
  14634. })
  14635. }
  14636. } else {
  14637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14638. return
  14639. }
  14640. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14641. fmt.Println(initFlag)
  14642. fmt.Println("initFlag")
  14643. if initFlag == 0 {
  14644. c.TestGetHnBasBaseInit()
  14645. }
  14646. basStr := c.GetBasBaseInfo()
  14647. if len(basStr) == 0 {
  14648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14649. return
  14650. }
  14651. fmt.Println(basStr)
  14652. bas := strings.Split(basStr, "|")
  14653. basNumber := bas[1]
  14654. fmt.Println(basNumber)
  14655. card_sn := bas[3]
  14656. card_no := bas[2]
  14657. fmt.Println(card_sn)
  14658. name := bas[4]
  14659. name = ConvertToString(name, "gbk", "utf-8")
  14660. 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)
  14661. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14662. var dat map[string]interface{}
  14663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14664. fmt.Println(dat)
  14665. } else {
  14666. fmt.Println(err)
  14667. }
  14668. userJSONBytes, _ := json.Marshal(dat)
  14669. var res ResultTwo
  14670. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14671. utils.ErrorLog("解析失败:%v", err)
  14672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14673. return
  14674. }
  14675. if res.Infcode == 0 {
  14676. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14677. if err == gorm.ErrRecordNotFound {
  14678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14679. return
  14680. } else if err != nil {
  14681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14682. return
  14683. } else {
  14684. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14685. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14686. infoStr := string(Iinfos)
  14687. idetinfoStr := string(Idetinfos)
  14688. psn := &models.HisPsn{
  14689. PsnNo: res.Output.Baseinfo.PsnNo,
  14690. PatientId: patient.ID,
  14691. Certno: res.Output.Baseinfo.Certno,
  14692. Gend: res.Output.Baseinfo.Gend,
  14693. Naty: res.Output.Baseinfo.Naty,
  14694. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14695. PsnName: res.Output.Baseinfo.PsnName,
  14696. Idetinfo: idetinfoStr,
  14697. Insuinfo: infoStr,
  14698. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14699. CardInfo: basStr,
  14700. VerifyNumber: "",
  14701. }
  14702. service.CreateHisPsn(psn)
  14703. var rf []*ResultFive
  14704. json.Unmarshal([]byte(infoStr), &rf)
  14705. var insutypes []*ResultFive
  14706. var insutype string
  14707. var is390 int = 0
  14708. var is310 int = 0
  14709. for _, item := range rf {
  14710. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14711. insutypes = append(insutypes, item)
  14712. }
  14713. }
  14714. if len(insutypes) == 1 {
  14715. insutype = insutypes[0].Insutype
  14716. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14717. } else {
  14718. for _, i := range insutypes {
  14719. if i.Insutype == "390" {
  14720. is390 = 1
  14721. }
  14722. if i.Insutype == "310" {
  14723. is310 = 1
  14724. }
  14725. }
  14726. }
  14727. if is390 == 1 {
  14728. insutype = "390"
  14729. }
  14730. if is310 == 1 {
  14731. insutype = "310"
  14732. }
  14733. if len(insutypes) == 0 {
  14734. insutype = "310"
  14735. }
  14736. c.ServeSuccessJSON(map[string]interface{}{
  14737. "patient": patient,
  14738. "number": basNumber,
  14739. "insutype": insutype,
  14740. })
  14741. }
  14742. } else {
  14743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14744. return
  14745. }
  14746. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14747. var api string
  14748. 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 +
  14749. "&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
  14750. fmt.Println(api)
  14751. resp, requestErr := http.Get(api)
  14752. if requestErr != nil {
  14753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14754. return
  14755. }
  14756. body, ioErr := ioutil.ReadAll(resp.Body)
  14757. if ioErr != nil {
  14758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14760. return
  14761. }
  14762. var respJSON map[string]interface{}
  14763. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14766. return
  14767. }
  14768. var res ResultTwo //1101结果
  14769. var res10265 ResultTwo10265 //1101结果
  14770. var card_info string //卡信息
  14771. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14772. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14773. result, _ := json.Marshal(respJSON)
  14774. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14775. utils.ErrorLog("解析失败:%v", err)
  14776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14777. return
  14778. }
  14779. res.ErrMsg = res10265.ErrMsg
  14780. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14781. res.Infcode = infocode
  14782. res.Output = res10265.Output
  14783. res.InfRefmsgid = res10265.InfRefmsgid
  14784. if res.Infcode == 0 {
  14785. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14786. if err == gorm.ErrRecordNotFound {
  14787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14788. return
  14789. } else if err != nil {
  14790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14791. return
  14792. } else {
  14793. bas := strings.Split(card_info, "|")
  14794. basNumber := bas[2]
  14795. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14796. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14797. infoStr := string(Iinfos)
  14798. idetinfoStr := string(Idetinfos)
  14799. psn := &models.HisPsn{
  14800. PsnNo: res.Output.Baseinfo.PsnNo,
  14801. PatientId: patient.ID,
  14802. Certno: res.Output.Baseinfo.Certno,
  14803. Gend: res.Output.Baseinfo.Gend,
  14804. Naty: res.Output.Baseinfo.Naty,
  14805. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14806. PsnName: res.Output.Baseinfo.PsnName,
  14807. Idetinfo: idetinfoStr,
  14808. Insuinfo: infoStr,
  14809. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14810. CardInfo: card_info,
  14811. VerifyNumber: token,
  14812. }
  14813. service.CreateHisPsn(psn)
  14814. var rf []*ResultFive
  14815. json.Unmarshal([]byte(infoStr), &rf)
  14816. var insutypes []*ResultFive
  14817. var insutype string
  14818. var is390 int = 0
  14819. var is310 int = 0
  14820. for _, item := range rf {
  14821. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14822. insutypes = append(insutypes, item)
  14823. }
  14824. }
  14825. if len(insutypes) == 1 {
  14826. insutype = insutypes[0].Insutype
  14827. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14828. } else {
  14829. for _, i := range insutypes {
  14830. if i.Insutype == "390" {
  14831. is390 = 1
  14832. }
  14833. if i.Insutype == "310" {
  14834. is310 = 1
  14835. }
  14836. }
  14837. }
  14838. if is390 == 1 {
  14839. insutype = "390"
  14840. }
  14841. if is310 == 1 {
  14842. insutype = "310"
  14843. }
  14844. if len(insutypes) == 0 {
  14845. insutype = "310"
  14846. }
  14847. c.ServeSuccessJSON(map[string]interface{}{
  14848. "patient": patient,
  14849. "number": basNumber,
  14850. "insutype": insutype,
  14851. })
  14852. }
  14853. } else {
  14854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14855. return
  14856. }
  14857. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14858. res := c.GetoleInfo()
  14859. if res.Infcode == 0 {
  14860. var result string
  14861. if res.Output.MdtrtCertType == "01" {
  14862. 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)
  14863. } else if res.Output.MdtrtCertType == "02" {
  14864. 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)
  14865. } else if res.Output.MdtrtCertType == "03" {
  14866. 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)
  14867. }
  14868. var dat map[string]interface{}
  14869. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14870. fmt.Println(dat)
  14871. } else {
  14872. fmt.Println(err)
  14873. }
  14874. userJSONBytes, _ := json.Marshal(dat)
  14875. var res2 ResultTwo
  14876. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14877. utils.ErrorLog("解析失败:%v", err)
  14878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14879. return
  14880. }
  14881. if res2.Infcode == 0 {
  14882. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14883. if err == gorm.ErrRecordNotFound {
  14884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14885. return
  14886. } else if err != nil {
  14887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14888. return
  14889. } else {
  14890. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14891. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14892. infoStr := string(Iinfos)
  14893. idetinfoStr := string(Idetinfos)
  14894. var rf []*ResultFive
  14895. json.Unmarshal([]byte(infoStr), &rf)
  14896. var insutypes []*ResultFive
  14897. var insutype string
  14898. var is390 int = 0
  14899. var is310 int = 0
  14900. //var insuplc_admdvs string
  14901. for _, item := range rf {
  14902. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14903. insutypes = append(insutypes, item)
  14904. }
  14905. }
  14906. if len(insutypes) == 1 {
  14907. insutype = insutypes[0].Insutype
  14908. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14909. } else {
  14910. for _, i := range insutypes {
  14911. if i.Insutype == "390" {
  14912. is390 = 1
  14913. }
  14914. if i.Insutype == "310" {
  14915. is310 = 1
  14916. }
  14917. }
  14918. }
  14919. if is390 == 1 {
  14920. insutype = "390"
  14921. }
  14922. if is310 == 1 {
  14923. insutype = "310"
  14924. }
  14925. if len(insutypes) == 0 {
  14926. insutype = "310"
  14927. }
  14928. psn := &models.HisPsn{
  14929. PsnNo: res2.Output.Baseinfo.PsnNo,
  14930. PatientId: patient.ID,
  14931. Certno: res2.Output.Baseinfo.Certno,
  14932. Gend: res2.Output.Baseinfo.Gend,
  14933. Naty: res2.Output.Baseinfo.Naty,
  14934. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14935. PsnName: res2.Output.Baseinfo.PsnName,
  14936. Idetinfo: idetinfoStr,
  14937. Insuinfo: infoStr,
  14938. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14939. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14940. VerifyNumber: res.Output.EcToken,
  14941. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14942. }
  14943. if res.Output.MdtrtCertType == "01" {
  14944. psn.VerifyNumber = res.Output.EcToken
  14945. //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)
  14946. } else if res.Output.MdtrtCertType == "02" {
  14947. psn.VerifyNumber = res.Output.MdtrtCertNo
  14948. //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)
  14949. } else if res.Output.MdtrtCertType == "03" {
  14950. psn.VerifyNumber = res.Output.MdtrtCertNo
  14951. //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)
  14952. }
  14953. var balc float64
  14954. for _, item := range rf {
  14955. if item.Insutype == insutype {
  14956. balc = item.Balc
  14957. }
  14958. }
  14959. service.CreateHisPsn(psn)
  14960. c.ServeSuccessJSON(map[string]interface{}{
  14961. "patient": patient,
  14962. "number": res.Output.CardNo,
  14963. "insutype": insutype,
  14964. "blac": balc,
  14965. "desc": idetinfoStr,
  14966. })
  14967. }
  14968. } else {
  14969. c.ServeSuccessJSON(map[string]interface{}{
  14970. "failed_code": -10,
  14971. "msg": res2.ErrMsg,
  14972. })
  14973. }
  14974. } else {
  14975. c.ServeSuccessJSON(map[string]interface{}{
  14976. "failed_code": -10,
  14977. "msg": res.ErrMsg,
  14978. })
  14979. }
  14980. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14981. var api string
  14982. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14983. "&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
  14984. fmt.Println(api)
  14985. resp, requestErr := http.Get(api)
  14986. if requestErr != nil {
  14987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14988. return
  14989. }
  14990. body, ioErr := ioutil.ReadAll(resp.Body)
  14991. if ioErr != nil {
  14992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14994. return
  14995. }
  14996. var respJSON map[string]interface{}
  14997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15000. return
  15001. }
  15002. var status string
  15003. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15004. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15005. //console.log()
  15006. fmt.Println("type===")
  15007. fmt.Println(card_type)
  15008. var token string
  15009. var res ResultTwo //1101结果
  15010. //var res10265 ResultTwoesultTwo10265 //1101结果
  15011. var card_info string //卡信息
  15012. var busi_card_info string
  15013. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15014. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15015. if status == "0" { //读卡成功
  15016. if card_type == "1" {
  15017. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15018. result, _ := json.Marshal(respJSON)
  15019. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15020. utils.ErrorLog("解析失败:%v", err)
  15021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15022. return
  15023. }
  15024. } else {
  15025. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15026. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15027. result, _ := json.Marshal(respJSON)
  15028. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15029. utils.ErrorLog("解析失败:%v", err)
  15030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15031. return
  15032. }
  15033. }
  15034. if res.Infcode == 0 {
  15035. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15036. if err == gorm.ErrRecordNotFound {
  15037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15038. return
  15039. } else if err != nil {
  15040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15041. return
  15042. } else {
  15043. if card_type == "1" {
  15044. bas := strings.Split(card_info, "|")
  15045. basNumber := bas[2]
  15046. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15047. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15048. infoStr := string(Iinfos)
  15049. idetinfoStr := string(Idetinfos)
  15050. psn := &models.HisPsn{
  15051. PsnNo: res.Output.Baseinfo.PsnNo,
  15052. PatientId: patient.ID,
  15053. Certno: res.Output.Baseinfo.Certno,
  15054. Gend: res.Output.Baseinfo.Gend,
  15055. Naty: res.Output.Baseinfo.Naty,
  15056. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15057. PsnName: res.Output.Baseinfo.PsnName,
  15058. Idetinfo: idetinfoStr,
  15059. Insuinfo: infoStr,
  15060. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15061. CardInfo: card_info,
  15062. VerifyNumber: busi_card_info,
  15063. }
  15064. service.CreateHisPsn(psn)
  15065. var rf []*ResultFive
  15066. json.Unmarshal([]byte(infoStr), &rf)
  15067. var insutypes []*ResultFive
  15068. var insutype string
  15069. var is390 int = 0
  15070. var is310 int = 0
  15071. for _, item := range rf {
  15072. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15073. insutypes = append(insutypes, item)
  15074. }
  15075. }
  15076. if len(insutypes) == 1 {
  15077. insutype = insutypes[0].Insutype
  15078. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15079. } else {
  15080. for _, i := range insutypes {
  15081. if i.Insutype == "390" {
  15082. is390 = 1
  15083. }
  15084. if i.Insutype == "310" {
  15085. is310 = 1
  15086. }
  15087. }
  15088. }
  15089. if is390 == 1 {
  15090. insutype = "390"
  15091. }
  15092. if is310 == 1 {
  15093. insutype = "310"
  15094. }
  15095. if len(insutypes) == 0 {
  15096. insutype = "310"
  15097. }
  15098. c.ServeSuccessJSON(map[string]interface{}{
  15099. "patient": patient,
  15100. "number": basNumber,
  15101. "insutype": insutype,
  15102. })
  15103. } else {
  15104. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15105. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15106. infoStr := string(Iinfos)
  15107. idetinfoStr := string(Idetinfos)
  15108. psn := &models.HisPsn{
  15109. PsnNo: res.Output.Baseinfo.PsnNo,
  15110. PatientId: patient.ID,
  15111. Certno: res.Output.Baseinfo.Certno,
  15112. Gend: res.Output.Baseinfo.Gend,
  15113. Naty: res.Output.Baseinfo.Naty,
  15114. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15115. PsnName: res.Output.Baseinfo.PsnName,
  15116. Idetinfo: idetinfoStr,
  15117. Insuinfo: infoStr,
  15118. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15119. CardInfo: card_info,
  15120. VerifyNumber: token,
  15121. }
  15122. service.CreateHisPsn(psn)
  15123. c.ServeSuccessJSON(map[string]interface{}{
  15124. "patient": patient,
  15125. "number": token,
  15126. })
  15127. }
  15128. }
  15129. } else {
  15130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15131. return
  15132. }
  15133. } else { //读卡失败
  15134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15135. return
  15136. }
  15137. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15138. var api string
  15139. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15140. "&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
  15141. fmt.Println(api)
  15142. resp, requestErr := http.Get(api)
  15143. if requestErr != nil {
  15144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15145. return
  15146. }
  15147. body, ioErr := ioutil.ReadAll(resp.Body)
  15148. if ioErr != nil {
  15149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15151. return
  15152. }
  15153. var respJSON map[string]interface{}
  15154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15157. return
  15158. }
  15159. var status string
  15160. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15161. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15162. //console.log()
  15163. fmt.Println("type===")
  15164. fmt.Println(card_type)
  15165. var token string
  15166. var res ResultTwo //1101结果
  15167. //var res10265 ResultTwoesultTwo10265 //1101结果
  15168. var card_info string //卡信息
  15169. //var busi_card_info string
  15170. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15171. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15172. if status == "0" { //读卡成功
  15173. if card_type == "1" {
  15174. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15175. result, _ := json.Marshal(respJSON)
  15176. fmt.Println(result)
  15177. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15178. utils.ErrorLog("解析失败:%v", err)
  15179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15180. return
  15181. }
  15182. fmt.Println(res)
  15183. } else {
  15184. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15185. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15186. result, _ := json.Marshal(respJSON)
  15187. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15188. utils.ErrorLog("解析失败:%v", err)
  15189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15190. return
  15191. }
  15192. }
  15193. if res.Infcode == 0 {
  15194. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15195. if err == gorm.ErrRecordNotFound {
  15196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15197. return
  15198. } else if err != nil {
  15199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15200. return
  15201. } else {
  15202. if card_type == "1" {
  15203. bas := strings.Split(card_info, "|")
  15204. basNumber := bas[2]
  15205. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15206. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15207. infoStr := string(Iinfos)
  15208. idetinfoStr := string(Idetinfos)
  15209. psn := &models.HisPsn{
  15210. PsnNo: res.Output.Baseinfo.PsnNo,
  15211. PatientId: patient.ID,
  15212. Certno: res.Output.Baseinfo.Certno,
  15213. Gend: res.Output.Baseinfo.Gend,
  15214. Naty: res.Output.Baseinfo.Naty,
  15215. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15216. PsnName: res.Output.Baseinfo.PsnName,
  15217. Idetinfo: idetinfoStr,
  15218. Insuinfo: infoStr,
  15219. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15220. CardInfo: card_info,
  15221. //VerifyNumber: busi_card_info,
  15222. }
  15223. service.CreateHisPsn(psn)
  15224. var rf []*ResultFive
  15225. json.Unmarshal([]byte(infoStr), &rf)
  15226. var insutypes []*ResultFive
  15227. var insutype string
  15228. var is390 int = 0
  15229. var is310 int = 0
  15230. for _, item := range rf {
  15231. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15232. insutypes = append(insutypes, item)
  15233. }
  15234. }
  15235. if len(insutypes) == 1 {
  15236. insutype = insutypes[0].Insutype
  15237. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15238. } else {
  15239. for _, i := range insutypes {
  15240. if i.Insutype == "390" {
  15241. is390 = 1
  15242. }
  15243. if i.Insutype == "310" {
  15244. is310 = 1
  15245. }
  15246. }
  15247. }
  15248. if is390 == 1 {
  15249. insutype = "390"
  15250. }
  15251. if is310 == 1 {
  15252. insutype = "310"
  15253. }
  15254. if len(insutypes) == 0 {
  15255. insutype = "310"
  15256. }
  15257. c.ServeSuccessJSON(map[string]interface{}{
  15258. "patient": patient,
  15259. "number": basNumber,
  15260. "insutype": insutype,
  15261. })
  15262. } else {
  15263. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15264. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15265. infoStr := string(Iinfos)
  15266. idetinfoStr := string(Idetinfos)
  15267. psn := &models.HisPsn{
  15268. PsnNo: res.Output.Baseinfo.PsnNo,
  15269. PatientId: patient.ID,
  15270. Certno: res.Output.Baseinfo.Certno,
  15271. Gend: res.Output.Baseinfo.Gend,
  15272. Naty: res.Output.Baseinfo.Naty,
  15273. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15274. PsnName: res.Output.Baseinfo.PsnName,
  15275. Idetinfo: idetinfoStr,
  15276. Insuinfo: infoStr,
  15277. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15278. CardInfo: card_info,
  15279. VerifyNumber: token,
  15280. }
  15281. service.CreateHisPsn(psn)
  15282. c.ServeSuccessJSON(map[string]interface{}{
  15283. "patient": patient,
  15284. "number": token,
  15285. })
  15286. }
  15287. }
  15288. } else {
  15289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15290. return
  15291. }
  15292. } else { //读卡失败
  15293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15294. return
  15295. }
  15296. } else {
  15297. if initFlag == 0 {
  15298. c.TestGetBasBaseInit()
  15299. }
  15300. basStr := c.GetBasBaseInfo()
  15301. if len(basStr) == 0 {
  15302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15303. return
  15304. }
  15305. fmt.Println(basStr)
  15306. bas := strings.Split(basStr, "|")
  15307. basNumber := bas[1]
  15308. fmt.Println(basNumber)
  15309. card_sn := bas[3]
  15310. fmt.Println(card_sn)
  15311. cardNumber := bas[2]
  15312. fmt.Println(cardNumber)
  15313. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  15314. var result string
  15315. if bas[0][:2] == "44" {
  15316. 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)
  15317. } else {
  15318. 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)
  15319. }
  15320. var dat map[string]interface{}
  15321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15322. fmt.Println(dat)
  15323. } else {
  15324. fmt.Println(err)
  15325. }
  15326. userJSONBytes, _ := json.Marshal(dat)
  15327. var res ResultTwo
  15328. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15329. utils.ErrorLog("解析失败:%v", err)
  15330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15331. return
  15332. }
  15333. if res.Infcode == 0 {
  15334. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15335. if err == gorm.ErrRecordNotFound {
  15336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15337. return
  15338. } else if err != nil {
  15339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15340. return
  15341. } else {
  15342. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15343. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15344. infoStr := string(Iinfos)
  15345. idetinfoStr := string(Idetinfos)
  15346. var rf []*ResultFive
  15347. json.Unmarshal([]byte(infoStr), &rf)
  15348. var insutypes []*ResultFive
  15349. var insutype string
  15350. var is390 int = 0
  15351. var is310 int = 0
  15352. var insuplc_admdvs string
  15353. for _, item := range rf {
  15354. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15355. insutypes = append(insutypes, item)
  15356. }
  15357. }
  15358. if len(insutypes) == 1 {
  15359. insutype = insutypes[0].Insutype
  15360. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15361. } else {
  15362. for _, i := range insutypes {
  15363. if i.Insutype == "390" {
  15364. is390 = 1
  15365. }
  15366. if i.Insutype == "310" {
  15367. is310 = 1
  15368. }
  15369. }
  15370. }
  15371. if is390 == 1 {
  15372. insutype = "390"
  15373. }
  15374. if is310 == 1 {
  15375. insutype = "310"
  15376. }
  15377. if len(insutypes) == 0 {
  15378. insutype = "310"
  15379. }
  15380. for _, item := range rf {
  15381. if item.Insutype == insutype {
  15382. insuplc_admdvs = item.InsuplcAdmdvs
  15383. }
  15384. }
  15385. psn := &models.HisPsn{
  15386. PsnNo: res.Output.Baseinfo.PsnNo,
  15387. PatientId: patient.ID,
  15388. Certno: res.Output.Baseinfo.Certno,
  15389. Gend: res.Output.Baseinfo.Gend,
  15390. Naty: res.Output.Baseinfo.Naty,
  15391. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15392. PsnName: res.Output.Baseinfo.PsnName,
  15393. Idetinfo: idetinfoStr,
  15394. Insuinfo: infoStr,
  15395. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15396. CardInfo: basStr,
  15397. VerifyNumber: "",
  15398. InsuplcAdmdvs: insuplc_admdvs,
  15399. }
  15400. service.CreateHisPsn(psn)
  15401. c.ServeSuccessJSON(map[string]interface{}{
  15402. "patient": patient,
  15403. "insutype": insutype,
  15404. "number": basNumber,
  15405. })
  15406. }
  15407. } else {
  15408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15409. return
  15410. }
  15411. break
  15412. }
  15413. case 2:
  15414. if miConfig.MdtrtareaAdmvs == "430800" {
  15415. if initFlag == 0 {
  15416. c.TestGetHnBasBaseInit()
  15417. }
  15418. SFZStr := c.GetSFZBaseInfo()
  15419. if len(SFZStr) == 0 {
  15420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15421. return
  15422. }
  15423. fmt.Println(SFZStr)
  15424. id_card_str := strings.Split(SFZStr, "^")
  15425. card_no := id_card_str[0]
  15426. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15427. //name := id_card_str[1]
  15428. //name = ConvertToString(name, "gbk", "utf-8")
  15429. 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)
  15430. var dat map[string]interface{}
  15431. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15432. fmt.Println(dat)
  15433. } else {
  15434. fmt.Println(err)
  15435. }
  15436. userJSONBytes, _ := json.Marshal(dat)
  15437. var res ResultTwo
  15438. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15439. utils.ErrorLog("解析失败:%v", err)
  15440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15441. return
  15442. }
  15443. if res.Infcode == 0 {
  15444. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15445. if err == gorm.ErrRecordNotFound {
  15446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15447. return
  15448. } else if err != nil {
  15449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15450. return
  15451. } else {
  15452. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15453. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15454. infoStr := string(Iinfos)
  15455. idetinfoStr := string(Idetinfos)
  15456. var rf []*ResultFive
  15457. json.Unmarshal([]byte(infoStr), &rf)
  15458. var insutypes []*ResultFive
  15459. var insutype string
  15460. var is390 int = 0
  15461. var is310 int = 0
  15462. for _, item := range rf {
  15463. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15464. insutypes = append(insutypes, item)
  15465. }
  15466. }
  15467. if len(insutypes) == 1 {
  15468. insutype = insutypes[0].Insutype
  15469. } else {
  15470. for _, i := range insutypes {
  15471. if i.Insutype == "390" {
  15472. is390 = 1
  15473. }
  15474. if i.Insutype == "310" {
  15475. is310 = 1
  15476. }
  15477. }
  15478. }
  15479. if is390 == 1 {
  15480. insutype = "390"
  15481. }
  15482. if is310 == 1 {
  15483. insutype = "310"
  15484. }
  15485. if len(insutypes) == 0 {
  15486. insutype = "310"
  15487. }
  15488. var InsuplcAdmdvs string
  15489. for _, item := range rf {
  15490. if item.Insutype == insutype {
  15491. InsuplcAdmdvs = item.InsuplcAdmdvs
  15492. }
  15493. }
  15494. psn := &models.HisPsn{
  15495. PsnNo: res.Output.Baseinfo.PsnNo,
  15496. PatientId: patient.ID,
  15497. Certno: res.Output.Baseinfo.Certno,
  15498. Gend: res.Output.Baseinfo.Gend,
  15499. Naty: res.Output.Baseinfo.Naty,
  15500. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15501. PsnName: res.Output.Baseinfo.PsnName,
  15502. Idetinfo: idetinfoStr,
  15503. Insuinfo: infoStr,
  15504. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15505. CardInfo: SFZStr,
  15506. VerifyNumber: "",
  15507. InsuplcAdmdvs: InsuplcAdmdvs,
  15508. }
  15509. service.CreateHisPsn(psn)
  15510. c.ServeSuccessJSON(map[string]interface{}{
  15511. "patient": patient,
  15512. "number": card_no,
  15513. "insutype": insutype,
  15514. })
  15515. }
  15516. } else {
  15517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15518. return
  15519. }
  15520. } else if miConfig.MdtrtareaAdmvs == "420200" {
  15521. var res ResultTwo
  15522. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  15523. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15524. "&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)
  15525. resp, requestErr := http.Get(api)
  15526. if requestErr != nil {
  15527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15528. return
  15529. }
  15530. body, ioErr := ioutil.ReadAll(resp.Body)
  15531. if ioErr != nil {
  15532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15534. return
  15535. }
  15536. var respJSON map[string]interface{}
  15537. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15540. return
  15541. }
  15542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15543. result, _ := json.Marshal(respJSON)
  15544. fmt.Println("log")
  15545. fmt.Println(string(result))
  15546. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15547. utils.ErrorLog("解析失败:%v", err)
  15548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15549. return
  15550. }
  15551. if res.Infcode == 0 {
  15552. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15553. if err == gorm.ErrRecordNotFound {
  15554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15555. return
  15556. } else if err != nil {
  15557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15558. return
  15559. } else {
  15560. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15561. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15562. infoStr := string(Iinfos)
  15563. idetinfoStr := string(Idetinfos)
  15564. psn := &models.HisPsn{
  15565. PsnNo: res.Output.Baseinfo.PsnNo,
  15566. PatientId: patient.ID,
  15567. Certno: res.Output.Baseinfo.Certno,
  15568. Gend: res.Output.Baseinfo.Gend,
  15569. Naty: res.Output.Baseinfo.Naty,
  15570. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15571. PsnName: res.Output.Baseinfo.PsnName,
  15572. Idetinfo: idetinfoStr,
  15573. Insuinfo: infoStr,
  15574. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15575. }
  15576. service.CreateHisPsn(psn)
  15577. c.ServeSuccessJSON(map[string]interface{}{
  15578. "patient": patient,
  15579. "number": res.Output.Baseinfo.Certno,
  15580. })
  15581. }
  15582. } else {
  15583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15584. return
  15585. }
  15586. } else if miConfig.MdtrtareaAdmvs == "421182" {
  15587. var res ResultTwo
  15588. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15589. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15590. "&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)
  15591. resp, requestErr := http.Get(api)
  15592. if requestErr != nil {
  15593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15594. return
  15595. }
  15596. body, ioErr := ioutil.ReadAll(resp.Body)
  15597. if ioErr != nil {
  15598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15600. return
  15601. }
  15602. var respJSON map[string]interface{}
  15603. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15606. return
  15607. }
  15608. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15609. result, _ := json.Marshal(respJSON)
  15610. fmt.Println("log")
  15611. fmt.Println(string(result))
  15612. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15613. utils.ErrorLog("解析失败:%v", err)
  15614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15615. return
  15616. }
  15617. if res.Infcode == 0 {
  15618. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15619. if err == gorm.ErrRecordNotFound {
  15620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15621. return
  15622. } else if err != nil {
  15623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15624. return
  15625. } else {
  15626. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15627. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15628. infoStr := string(Iinfos)
  15629. idetinfoStr := string(Idetinfos)
  15630. psn := &models.HisPsn{
  15631. PsnNo: res.Output.Baseinfo.PsnNo,
  15632. PatientId: patient.ID,
  15633. Certno: res.Output.Baseinfo.Certno,
  15634. Gend: res.Output.Baseinfo.Gend,
  15635. Naty: res.Output.Baseinfo.Naty,
  15636. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15637. PsnName: res.Output.Baseinfo.PsnName,
  15638. Idetinfo: idetinfoStr,
  15639. Insuinfo: infoStr,
  15640. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15641. }
  15642. service.CreateHisPsn(psn)
  15643. c.ServeSuccessJSON(map[string]interface{}{
  15644. "patient": patient,
  15645. "number": res.Output.Baseinfo.Certno,
  15646. })
  15647. }
  15648. } else {
  15649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15650. return
  15651. }
  15652. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15653. var res ResultTwo
  15654. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15655. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15656. "&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)
  15657. resp, requestErr := http.Get(api)
  15658. if requestErr != nil {
  15659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15660. return
  15661. }
  15662. body, ioErr := ioutil.ReadAll(resp.Body)
  15663. if ioErr != nil {
  15664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15666. return
  15667. }
  15668. var respJSON map[string]interface{}
  15669. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15672. return
  15673. }
  15674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15675. result, _ := json.Marshal(respJSON)
  15676. fmt.Println("log")
  15677. fmt.Println(string(result))
  15678. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15679. utils.ErrorLog("解析失败:%v", err)
  15680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15681. return
  15682. }
  15683. if res.Infcode == 0 {
  15684. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15685. if err == gorm.ErrRecordNotFound {
  15686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15687. return
  15688. } else if err != nil {
  15689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15690. return
  15691. } else {
  15692. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15693. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15694. infoStr := string(Iinfos)
  15695. idetinfoStr := string(Idetinfos)
  15696. var rf []*ResultFive
  15697. json.Unmarshal([]byte(infoStr), &rf)
  15698. var insutypes []*ResultFive
  15699. var insutype string
  15700. var is390 int = 0
  15701. var is310 int = 0
  15702. for _, item := range rf {
  15703. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15704. insutypes = append(insutypes, item)
  15705. }
  15706. }
  15707. if len(insutypes) == 1 {
  15708. insutype = insutypes[0].Insutype
  15709. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15710. } else {
  15711. for _, i := range insutypes {
  15712. if i.Insutype == "390" {
  15713. is390 = 1
  15714. }
  15715. if i.Insutype == "310" {
  15716. is310 = 1
  15717. }
  15718. }
  15719. }
  15720. if is390 == 1 {
  15721. insutype = "390"
  15722. }
  15723. if is310 == 1 {
  15724. insutype = "310"
  15725. }
  15726. if len(insutypes) == 0 {
  15727. insutype = "390"
  15728. }
  15729. var insuplc_admdvs string
  15730. for _, item := range rf {
  15731. if item.Insutype == insutype {
  15732. insuplc_admdvs = item.InsuplcAdmdvs
  15733. }
  15734. }
  15735. psn := &models.HisPsn{
  15736. PsnNo: res.Output.Baseinfo.PsnNo,
  15737. PatientId: patient.ID,
  15738. Certno: res.Output.Baseinfo.Certno,
  15739. Gend: res.Output.Baseinfo.Gend,
  15740. Naty: res.Output.Baseinfo.Naty,
  15741. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15742. PsnName: res.Output.Baseinfo.PsnName,
  15743. Idetinfo: idetinfoStr,
  15744. Insuinfo: infoStr,
  15745. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15746. InsuplcAdmdvs: insuplc_admdvs,
  15747. }
  15748. service.CreateHisPsn(psn)
  15749. c.ServeSuccessJSON(map[string]interface{}{
  15750. "patient": patient,
  15751. "number": res.Output.Baseinfo.Certno,
  15752. })
  15753. }
  15754. } else {
  15755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15756. return
  15757. }
  15758. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15759. res := c.GetoleInfo()
  15760. if res.Infcode == 0 {
  15761. var result string
  15762. if res.Output.MdtrtCertType == "01" {
  15763. 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)
  15764. } else if res.Output.MdtrtCertType == "02" {
  15765. 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)
  15766. } else if res.Output.MdtrtCertType == "03" {
  15767. 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)
  15768. }
  15769. var dat map[string]interface{}
  15770. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15771. fmt.Println(dat)
  15772. } else {
  15773. fmt.Println(err)
  15774. }
  15775. userJSONBytes, _ := json.Marshal(dat)
  15776. var res2 ResultTwo
  15777. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15778. utils.ErrorLog("解析失败:%v", err)
  15779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15780. return
  15781. }
  15782. if res2.Infcode == 0 {
  15783. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15784. if err == gorm.ErrRecordNotFound {
  15785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15786. return
  15787. } else if err != nil {
  15788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15789. return
  15790. } else {
  15791. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15792. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15793. infoStr := string(Iinfos)
  15794. idetinfoStr := string(Idetinfos)
  15795. var rf []*ResultFive
  15796. json.Unmarshal([]byte(infoStr), &rf)
  15797. var insutypes []*ResultFive
  15798. var insutype string
  15799. var is390 int = 0
  15800. var is310 int = 0
  15801. //var insuplc_admdvs string
  15802. for _, item := range rf {
  15803. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15804. insutypes = append(insutypes, item)
  15805. }
  15806. }
  15807. if len(insutypes) == 1 {
  15808. insutype = insutypes[0].Insutype
  15809. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15810. } else {
  15811. for _, i := range insutypes {
  15812. if i.Insutype == "390" {
  15813. is390 = 1
  15814. }
  15815. if i.Insutype == "310" {
  15816. is310 = 1
  15817. }
  15818. }
  15819. }
  15820. if is390 == 1 {
  15821. insutype = "390"
  15822. }
  15823. if is310 == 1 {
  15824. insutype = "310"
  15825. }
  15826. if len(insutypes) == 0 {
  15827. insutype = "310"
  15828. }
  15829. psn := &models.HisPsn{
  15830. PsnNo: res2.Output.Baseinfo.PsnNo,
  15831. PatientId: patient.ID,
  15832. //Brdy: res2.Output.Baseinfo.Brdy,
  15833. Certno: res2.Output.Baseinfo.Certno,
  15834. Gend: res2.Output.Baseinfo.Gend,
  15835. Naty: res2.Output.Baseinfo.Naty,
  15836. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15837. PsnName: res2.Output.Baseinfo.PsnName,
  15838. Idetinfo: idetinfoStr,
  15839. Insuinfo: infoStr,
  15840. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15841. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15842. VerifyNumber: res.Output.EcToken,
  15843. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15844. }
  15845. service.CreateHisPsn(psn)
  15846. var balc float64
  15847. for _, item := range rf {
  15848. if item.Insutype == insutype {
  15849. balc = item.Balc
  15850. }
  15851. }
  15852. c.ServeSuccessJSON(map[string]interface{}{
  15853. "patient": patient,
  15854. "number": res.Output.CardNo,
  15855. "insutype": insutype,
  15856. "blac": balc,
  15857. "desc": idetinfoStr,
  15858. })
  15859. }
  15860. } else {
  15861. c.ServeSuccessJSON(map[string]interface{}{
  15862. "failed_code": -10,
  15863. "msg": res2.ErrMsg,
  15864. })
  15865. }
  15866. } else {
  15867. c.ServeSuccessJSON(map[string]interface{}{
  15868. "failed_code": -10,
  15869. "msg": res.ErrMsg,
  15870. })
  15871. }
  15872. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15873. var insuplc_admdvs string
  15874. if len(patient.InsuplcAdmdvs) > 0 {
  15875. insuplc_admdvs = patient.InsuplcAdmdvs
  15876. } else {
  15877. if len(insuplc_admdvs_str) > 0 {
  15878. insuplc_admdvs = insuplc_admdvs_str
  15879. } else {
  15880. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15881. }
  15882. }
  15883. //请求内网数据
  15884. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15885. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15886. "&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=" + ""
  15887. resp, requestErr := http.Get(api)
  15888. if requestErr != nil {
  15889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15890. return
  15891. }
  15892. body, ioErr := ioutil.ReadAll(resp.Body)
  15893. if ioErr != nil {
  15894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15896. return
  15897. }
  15898. var respJSON map[string]interface{}
  15899. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15902. return
  15903. }
  15904. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15905. if status == "0" {
  15906. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15907. c.ServeSuccessJSON(map[string]interface{}{
  15908. "failed_code": -10,
  15909. "msg": err_msg,
  15910. })
  15911. return
  15912. }
  15913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15914. var res ResultTwo
  15915. result, _ := json.Marshal(respJSON)
  15916. fmt.Println("log")
  15917. fmt.Println(string(result))
  15918. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15919. utils.ErrorLog("解析失败:%v", err)
  15920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15921. return
  15922. }
  15923. if res.Infcode == 0 {
  15924. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15925. if err == gorm.ErrRecordNotFound {
  15926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15927. return
  15928. } else if err != nil {
  15929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15930. return
  15931. } else {
  15932. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15933. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15934. infoStr := string(Iinfos)
  15935. idetinfoStr := string(Idetinfos)
  15936. psn := &models.HisPsn{
  15937. PsnNo: res.Output.Baseinfo.PsnNo,
  15938. PatientId: patient.ID,
  15939. Certno: res.Output.Baseinfo.Certno,
  15940. Gend: res.Output.Baseinfo.Gend,
  15941. Naty: res.Output.Baseinfo.Naty,
  15942. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15943. PsnName: res.Output.Baseinfo.PsnName,
  15944. Idetinfo: idetinfoStr,
  15945. Insuinfo: infoStr,
  15946. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15947. }
  15948. service.CreateHisPsn(psn)
  15949. var rf []*ResultFive
  15950. json.Unmarshal([]byte(infoStr), &rf)
  15951. var insutypes []*ResultFive
  15952. var is390 int = 0
  15953. var is310 int = 0
  15954. var insutype string
  15955. for _, item := range rf {
  15956. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15957. insutypes = append(insutypes, item)
  15958. }
  15959. }
  15960. if len(insutypes) == 1 {
  15961. insutype = insutypes[0].Insutype
  15962. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15963. } else {
  15964. for _, i := range insutypes {
  15965. if i.Insutype == "390" {
  15966. is390 = 1
  15967. }
  15968. if i.Insutype == "310" {
  15969. is310 = 1
  15970. }
  15971. }
  15972. }
  15973. if is390 == 1 {
  15974. insutype = "390"
  15975. }
  15976. if is310 == 1 {
  15977. insutype = "310"
  15978. }
  15979. if len(insutypes) == 0 {
  15980. insutype = "390"
  15981. }
  15982. c.ServeSuccessJSON(map[string]interface{}{
  15983. "patient": patient,
  15984. "insutype": insutype,
  15985. "number": res.Output.Baseinfo.Certno,
  15986. "info": res,
  15987. })
  15988. }
  15989. } else {
  15990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15991. return
  15992. }
  15993. } else {
  15994. SFZStr := c.GetSFZBaseInfo()
  15995. id_card_str := strings.Split(SFZStr, "^")
  15996. id_card_number := id_card_str[0]
  15997. card_sn := ""
  15998. 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)
  15999. var dat map[string]interface{}
  16000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16001. fmt.Println(dat)
  16002. } else {
  16003. fmt.Println(err)
  16004. }
  16005. userJSONBytes, _ := json.Marshal(dat)
  16006. var res ResultTwo
  16007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16008. utils.ErrorLog("解析失败:%v", err)
  16009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16010. return
  16011. }
  16012. if res.Infcode == 0 {
  16013. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  16014. if err == gorm.ErrRecordNotFound {
  16015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16016. return
  16017. } else if err != nil {
  16018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16019. return
  16020. } else {
  16021. c.ServeSuccessJSON(map[string]interface{}{
  16022. "patient": patient,
  16023. "number": id_card_number,
  16024. })
  16025. }
  16026. } else {
  16027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16028. return
  16029. }
  16030. }
  16031. break
  16032. case 3:
  16033. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16034. var api string
  16035. if miConfig.MdtrtareaAdmvs == "320830" {
  16036. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16037. "&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
  16038. fmt.Println(api)
  16039. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16040. 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 +
  16041. "&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
  16042. fmt.Println(api)
  16043. } else {
  16044. 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 +
  16045. "&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)
  16046. }
  16047. resp, requestErr := http.Get(api)
  16048. if requestErr != nil {
  16049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16050. return
  16051. }
  16052. body, ioErr := ioutil.ReadAll(resp.Body)
  16053. if ioErr != nil {
  16054. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16056. return
  16057. }
  16058. var respJSON map[string]interface{}
  16059. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16060. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16062. return
  16063. }
  16064. var status string
  16065. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16066. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16067. var token string
  16068. var res ResultTwo //1101结果
  16069. var res10265 ResultTwo10265 //1101结果
  16070. var card_info string //卡信息
  16071. var busi_card_info string
  16072. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16073. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16074. if status == "0" { //读卡成功
  16075. if card_type == "1" {
  16076. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16077. result, _ := json.Marshal(respJSON)
  16078. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16079. utils.ErrorLog("解析失败:%v", err)
  16080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16081. return
  16082. }
  16083. res.ErrMsg = res10265.ErrMsg
  16084. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16085. res.Infcode = infocode
  16086. res.Output = res10265.Output
  16087. res.InfRefmsgid = res10265.InfRefmsgid
  16088. } else {
  16089. //var card_info string //卡信息
  16090. //var busi_card_info string
  16091. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16092. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16093. //fmt.Println(card_info)
  16094. //fmt.Println(busi_card_info)
  16095. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16096. result, _ := json.Marshal(respJSON)
  16097. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16098. utils.ErrorLog("解析失败:%v", err)
  16099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16100. return
  16101. }
  16102. res.ErrMsg = res10265.ErrMsg
  16103. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16104. res.Infcode = infocode
  16105. res.Output = res10265.Output
  16106. res.InfRefmsgid = res10265.InfRefmsgid
  16107. }
  16108. if res.Infcode == 0 {
  16109. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16110. if err == gorm.ErrRecordNotFound {
  16111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16112. return
  16113. } else if err != nil {
  16114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16115. return
  16116. } else {
  16117. if card_type == "1" {
  16118. bas := strings.Split(card_info, "|")
  16119. basNumber := bas[2]
  16120. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16121. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16122. infoStr := string(Iinfos)
  16123. idetinfoStr := string(Idetinfos)
  16124. psn := &models.HisPsn{
  16125. PsnNo: res.Output.Baseinfo.PsnNo,
  16126. PatientId: patient.ID,
  16127. Certno: res.Output.Baseinfo.Certno,
  16128. //Brdy: res.Output.Baseinfo.Brdy,
  16129. Gend: res.Output.Baseinfo.Gend,
  16130. Naty: res.Output.Baseinfo.Naty,
  16131. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16132. PsnName: res.Output.Baseinfo.PsnName,
  16133. Idetinfo: idetinfoStr,
  16134. Insuinfo: infoStr,
  16135. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16136. CardInfo: card_info,
  16137. VerifyNumber: busi_card_info,
  16138. }
  16139. service.CreateHisPsn(psn)
  16140. c.ServeSuccessJSON(map[string]interface{}{
  16141. "patient": patient,
  16142. "number": basNumber,
  16143. })
  16144. } else {
  16145. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16146. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16147. infoStr := string(Iinfos)
  16148. idetinfoStr := string(Idetinfos)
  16149. psn := &models.HisPsn{
  16150. PsnNo: res.Output.Baseinfo.PsnNo,
  16151. PatientId: patient.ID,
  16152. Certno: res.Output.Baseinfo.Certno,
  16153. Gend: res.Output.Baseinfo.Gend,
  16154. Naty: res.Output.Baseinfo.Naty,
  16155. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16156. PsnName: res.Output.Baseinfo.PsnName,
  16157. Idetinfo: idetinfoStr,
  16158. Insuinfo: infoStr,
  16159. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16160. CardInfo: card_info,
  16161. VerifyNumber: token,
  16162. }
  16163. service.CreateHisPsn(psn)
  16164. var rf []*ResultFive
  16165. json.Unmarshal([]byte(infoStr), &rf)
  16166. var insutypes []*ResultFive
  16167. var insutype string
  16168. var is390 int = 0
  16169. var is310 int = 0
  16170. for _, item := range rf {
  16171. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16172. insutypes = append(insutypes, item)
  16173. }
  16174. }
  16175. if len(insutypes) == 1 {
  16176. insutype = insutypes[0].Insutype
  16177. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16178. } else {
  16179. for _, i := range insutypes {
  16180. if i.Insutype == "390" {
  16181. is390 = 1
  16182. }
  16183. if i.Insutype == "310" {
  16184. is310 = 1
  16185. }
  16186. }
  16187. }
  16188. if is390 == 1 {
  16189. insutype = "390"
  16190. }
  16191. if is310 == 1 {
  16192. insutype = "310"
  16193. }
  16194. if len(insutypes) == 0 {
  16195. insutype = "310"
  16196. }
  16197. c.ServeSuccessJSON(map[string]interface{}{
  16198. "patient": patient,
  16199. "number": token,
  16200. "insutype": insutype,
  16201. })
  16202. }
  16203. }
  16204. } else {
  16205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16206. return
  16207. }
  16208. } else { //读卡失败
  16209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16210. return
  16211. }
  16212. }
  16213. break
  16214. case 4:
  16215. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16216. var api string
  16217. if miConfig.MdtrtareaAdmvs == "320830" {
  16218. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16219. "&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
  16220. fmt.Println(api)
  16221. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16222. 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 +
  16223. "&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
  16224. fmt.Println(api)
  16225. } else {
  16226. 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 +
  16227. "&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)
  16228. }
  16229. resp, requestErr := http.Get(api)
  16230. if requestErr != nil {
  16231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16232. return
  16233. }
  16234. body, ioErr := ioutil.ReadAll(resp.Body)
  16235. if ioErr != nil {
  16236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16238. return
  16239. }
  16240. var respJSON map[string]interface{}
  16241. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16244. return
  16245. }
  16246. var status string
  16247. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16248. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16249. var token string
  16250. var res ResultTwo //1101结果
  16251. var res10265 ResultTwo10265 //1101结果
  16252. if status == "0" { //读卡成功
  16253. var card_info string //卡信息
  16254. var busi_card_info string
  16255. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16256. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16257. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16258. fmt.Println(card_info)
  16259. fmt.Println(busi_card_info)
  16260. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16261. result, _ := json.Marshal(respJSON)
  16262. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16263. utils.ErrorLog("解析失败:%v", err)
  16264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16265. return
  16266. }
  16267. res.ErrMsg = res10265.ErrMsg
  16268. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16269. res.Infcode = infocode
  16270. res.Output = res10265.Output
  16271. res.InfRefmsgid = res10265.InfRefmsgid
  16272. if res.Infcode == 0 {
  16273. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16274. if err == gorm.ErrRecordNotFound {
  16275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16276. return
  16277. } else if err != nil {
  16278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16279. return
  16280. } else {
  16281. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16282. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16283. infoStr := string(Iinfos)
  16284. idetinfoStr := string(Idetinfos)
  16285. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16286. psn := &models.HisPsn{
  16287. PsnNo: res.Output.Baseinfo.PsnNo,
  16288. PatientId: patient.ID,
  16289. Certno: res.Output.Baseinfo.Certno,
  16290. Brdy: b,
  16291. Age: float64(age),
  16292. //Brdy: res.Output.Baseinfo.Brdy,
  16293. Gend: res.Output.Baseinfo.Gend,
  16294. Naty: res.Output.Baseinfo.Naty,
  16295. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16296. PsnName: res.Output.Baseinfo.PsnName,
  16297. Idetinfo: idetinfoStr,
  16298. Insuinfo: infoStr,
  16299. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16300. CardInfo: card_info,
  16301. VerifyNumber: token,
  16302. }
  16303. var rf []*ResultFive
  16304. json.Unmarshal([]byte(infoStr), &rf)
  16305. var insutypes []*ResultFive
  16306. var insutype string
  16307. var is390 int = 0
  16308. var is310 int = 0
  16309. for _, item := range rf {
  16310. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16311. insutypes = append(insutypes, item)
  16312. }
  16313. }
  16314. if len(insutypes) == 1 {
  16315. insutype = insutypes[0].Insutype
  16316. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16317. } else {
  16318. for _, i := range insutypes {
  16319. if i.Insutype == "390" {
  16320. is390 = 1
  16321. }
  16322. if i.Insutype == "310" {
  16323. is310 = 1
  16324. }
  16325. }
  16326. }
  16327. if is390 == 1 {
  16328. insutype = "390"
  16329. }
  16330. if is310 == 1 {
  16331. insutype = "310"
  16332. }
  16333. if len(insutypes) == 0 {
  16334. insutype = "310"
  16335. }
  16336. service.CreateHisPsn(psn)
  16337. c.ServeSuccessJSON(map[string]interface{}{
  16338. "patient": patient,
  16339. "number": token,
  16340. "insutype": insutype,
  16341. })
  16342. }
  16343. } else {
  16344. c.ServeSuccessJSON(map[string]interface{}{
  16345. "failed_code": -10,
  16346. "msg": res.ErrMsg,
  16347. })
  16348. }
  16349. } else { //读卡失败
  16350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16351. return
  16352. }
  16353. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16354. var api string
  16355. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16356. "&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
  16357. resp, requestErr := http.Get(api)
  16358. if requestErr != nil {
  16359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16360. return
  16361. }
  16362. body, ioErr := ioutil.ReadAll(resp.Body)
  16363. if ioErr != nil {
  16364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16366. return
  16367. }
  16368. var respJSON map[string]interface{}
  16369. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16372. return
  16373. }
  16374. var status string
  16375. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16376. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16377. var token string
  16378. var res ResultTwo //1101结果
  16379. if status == "1" { //读卡成功
  16380. var card_info string //卡信息
  16381. var busi_card_info string
  16382. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16383. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16384. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16385. fmt.Println(card_info)
  16386. fmt.Println(busi_card_info)
  16387. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16388. result, _ := json.Marshal(respJSON)
  16389. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16390. utils.ErrorLog("解析失败:%v", err)
  16391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16392. return
  16393. }
  16394. if res.Infcode == 0 {
  16395. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16396. if err == gorm.ErrRecordNotFound {
  16397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16398. return
  16399. } else if err != nil {
  16400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16401. return
  16402. } else {
  16403. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16404. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16405. infoStr := string(Iinfos)
  16406. idetinfoStr := string(Idetinfos)
  16407. psn := &models.HisPsn{
  16408. PsnNo: res.Output.Baseinfo.PsnNo,
  16409. PatientId: patient.ID,
  16410. Certno: res.Output.Baseinfo.Certno,
  16411. Gend: res.Output.Baseinfo.Gend,
  16412. Naty: res.Output.Baseinfo.Naty,
  16413. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16414. PsnName: res.Output.Baseinfo.PsnName,
  16415. Idetinfo: idetinfoStr,
  16416. Insuinfo: infoStr,
  16417. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16418. CardInfo: card_info,
  16419. VerifyNumber: token,
  16420. }
  16421. var rf []*ResultFive
  16422. json.Unmarshal([]byte(infoStr), &rf)
  16423. var insutypes []*ResultFive
  16424. var insutype string
  16425. var is390 int = 0
  16426. var is310 int = 0
  16427. for _, item := range rf {
  16428. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16429. insutypes = append(insutypes, item)
  16430. }
  16431. }
  16432. if len(insutypes) == 1 {
  16433. insutype = insutypes[0].Insutype
  16434. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16435. } else {
  16436. for _, i := range insutypes {
  16437. if i.Insutype == "390" {
  16438. is390 = 1
  16439. }
  16440. if i.Insutype == "310" {
  16441. is310 = 1
  16442. }
  16443. }
  16444. }
  16445. if is390 == 1 {
  16446. insutype = "390"
  16447. }
  16448. if is310 == 1 {
  16449. insutype = "310"
  16450. }
  16451. if len(insutypes) == 0 {
  16452. insutype = "310"
  16453. }
  16454. service.CreateHisPsn(psn)
  16455. c.ServeSuccessJSON(map[string]interface{}{
  16456. "patient": patient,
  16457. "number": token,
  16458. "insutype": insutype,
  16459. })
  16460. }
  16461. } else {
  16462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16463. return
  16464. }
  16465. } else { //读卡失败
  16466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16467. return
  16468. }
  16469. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16470. var api string
  16471. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16472. "&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
  16473. resp, requestErr := http.Get(api)
  16474. if requestErr != nil {
  16475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16476. return
  16477. }
  16478. body, ioErr := ioutil.ReadAll(resp.Body)
  16479. if ioErr != nil {
  16480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16482. return
  16483. }
  16484. var respJSON map[string]interface{}
  16485. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16488. return
  16489. }
  16490. var status string
  16491. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16492. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16493. var token string
  16494. var res ResultTwo //1101结果
  16495. if status == "1" { //读卡成功
  16496. var card_info string //卡信息
  16497. var busi_card_info string
  16498. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16499. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16500. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16501. fmt.Println(card_info)
  16502. fmt.Println(busi_card_info)
  16503. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16504. result, _ := json.Marshal(respJSON)
  16505. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16506. utils.ErrorLog("解析失败:%v", err)
  16507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16508. return
  16509. }
  16510. if res.Infcode == 0 {
  16511. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16512. if err == gorm.ErrRecordNotFound {
  16513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16514. return
  16515. } else if err != nil {
  16516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16517. return
  16518. } else {
  16519. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16520. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16521. infoStr := string(Iinfos)
  16522. idetinfoStr := string(Idetinfos)
  16523. psn := &models.HisPsn{
  16524. PsnNo: res.Output.Baseinfo.PsnNo,
  16525. PatientId: patient.ID,
  16526. Certno: res.Output.Baseinfo.Certno,
  16527. Gend: res.Output.Baseinfo.Gend,
  16528. Naty: res.Output.Baseinfo.Naty,
  16529. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16530. PsnName: res.Output.Baseinfo.PsnName,
  16531. Idetinfo: idetinfoStr,
  16532. Insuinfo: infoStr,
  16533. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16534. CardInfo: card_info,
  16535. VerifyNumber: token,
  16536. }
  16537. var rf []*ResultFive
  16538. json.Unmarshal([]byte(infoStr), &rf)
  16539. var insutypes []*ResultFive
  16540. var insutype string
  16541. var is390 int = 0
  16542. var is310 int = 0
  16543. for _, item := range rf {
  16544. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16545. insutypes = append(insutypes, item)
  16546. }
  16547. }
  16548. if len(insutypes) == 1 {
  16549. insutype = insutypes[0].Insutype
  16550. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16551. } else {
  16552. for _, i := range insutypes {
  16553. if i.Insutype == "390" {
  16554. is390 = 1
  16555. }
  16556. if i.Insutype == "310" {
  16557. is310 = 1
  16558. }
  16559. }
  16560. }
  16561. if is390 == 1 {
  16562. insutype = "390"
  16563. }
  16564. if is310 == 1 {
  16565. insutype = "310"
  16566. }
  16567. if len(insutypes) == 0 {
  16568. insutype = "390"
  16569. }
  16570. service.CreateHisPsn(psn)
  16571. c.ServeSuccessJSON(map[string]interface{}{
  16572. "patient": patient,
  16573. "number": token,
  16574. "insutype": insutype,
  16575. })
  16576. }
  16577. } else {
  16578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16579. return
  16580. }
  16581. } else { //读卡失败
  16582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16583. return
  16584. }
  16585. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16586. //idNo := c.GetString("idNo")
  16587. //userName := c.GetString("userName")
  16588. //ecToken := c.GetString("ecToken")
  16589. //insuOrg := c.GetString("insuOrg")
  16590. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  16591. utils.ErrorLog("解析失败:%v", json_result)
  16592. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16593. type ELeData struct {
  16594. Data struct {
  16595. IdNo string `json:"idNo"`
  16596. IdType string `json:"idType"`
  16597. UserName string `json:"userName"`
  16598. EcToken string `json:"ecToken"`
  16599. InsuOrg string `json:"insuOrg"`
  16600. Gender string `json:"gender"`
  16601. Birthday string `json:"birthday"`
  16602. Nationality string `json:"nationality"`
  16603. Email string `json:"email"`
  16604. Extra string `json:"extra"`
  16605. } `json:"data"`
  16606. Code int `json:"code"`
  16607. Message string `json:"message"`
  16608. }
  16609. var ele ELeData
  16610. err := json.Unmarshal([]byte(json_result), &ele)
  16611. if err != nil {
  16612. utils.ErrorLog("解析失败:%v", err)
  16613. }
  16614. token := ele.Data.EcToken
  16615. token = Remove0000(token)
  16616. 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)
  16617. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16618. var res ResultTwo
  16619. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16620. utils.ErrorLog("解析失败:%v", err)
  16621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16622. return
  16623. }
  16624. if res.Infcode == 0 {
  16625. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16626. if err == gorm.ErrRecordNotFound {
  16627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16628. return
  16629. } else if err != nil {
  16630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16631. return
  16632. } else {
  16633. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16634. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16635. infoStr := string(Iinfos)
  16636. idetinfoStr := string(Idetinfos)
  16637. psn := &models.HisPsn{
  16638. PsnNo: res.Output.Baseinfo.PsnNo,
  16639. PatientId: patient.ID,
  16640. Certno: res.Output.Baseinfo.Certno,
  16641. Gend: res.Output.Baseinfo.Gend,
  16642. Naty: res.Output.Baseinfo.Naty,
  16643. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16644. PsnName: res.Output.Baseinfo.PsnName,
  16645. Idetinfo: idetinfoStr,
  16646. Insuinfo: infoStr,
  16647. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16648. CardInfo: "",
  16649. Stage: "1",
  16650. VerifyNumber: token,
  16651. InsuplcAdmdvs: ele.Data.InsuOrg,
  16652. }
  16653. service.CreateHisPsn(psn)
  16654. var rf []*ResultFive
  16655. json.Unmarshal([]byte(infoStr), &rf)
  16656. var insutypes []*ResultFive
  16657. var insutype string
  16658. var is390 int = 0
  16659. var is310 int = 0
  16660. for _, item := range rf {
  16661. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16662. insutypes = append(insutypes, item)
  16663. }
  16664. }
  16665. if len(insutypes) == 1 {
  16666. insutype = insutypes[0].Insutype
  16667. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16668. } else {
  16669. for _, i := range insutypes {
  16670. if i.Insutype == "390" {
  16671. is390 = 1
  16672. }
  16673. if i.Insutype == "310" {
  16674. is310 = 1
  16675. }
  16676. }
  16677. }
  16678. if is390 == 1 {
  16679. insutype = "390"
  16680. }
  16681. if is310 == 1 {
  16682. insutype = "310"
  16683. }
  16684. if len(insutypes) == 0 {
  16685. insutype = "310"
  16686. }
  16687. c.ServeSuccessJSON(map[string]interface{}{
  16688. "patient": patient,
  16689. "number": token,
  16690. "insutype": insutype,
  16691. })
  16692. }
  16693. } else {
  16694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16695. return
  16696. }
  16697. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16698. //if initFlag == 0 {
  16699. //c.TestGetJiangXiBasBaseInit()
  16700. //}
  16701. //if initEleFlag == 0 {
  16702. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16703. //}
  16704. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16705. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16706. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16707. type ELeData struct {
  16708. Data struct {
  16709. IdNo string `json:"idNo"`
  16710. IdType string `json:"idType"`
  16711. UserName string `json:"userName"`
  16712. EcToken string `json:"ecToken"`
  16713. InsuOrg string `json:"insuOrg"`
  16714. Gender string `json:"gender"`
  16715. Birthday string `json:"birthday"`
  16716. Nationality string `json:"nationality"`
  16717. Email string `json:"email"`
  16718. Extra string `json:"extra"`
  16719. } `json:"data"`
  16720. Code int `json:"code"`
  16721. Message string `json:"message"`
  16722. }
  16723. var ele ELeData
  16724. err := json.Unmarshal([]byte(result), &ele)
  16725. if err != nil {
  16726. utils.ErrorLog("解析失败:%v", err)
  16727. }
  16728. token := ele.Data.EcToken
  16729. token = Remove0000(token)
  16730. 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)
  16731. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16732. var res ResultTwo
  16733. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16734. utils.ErrorLog("解析失败:%v", err)
  16735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16736. return
  16737. }
  16738. if res.Infcode == 0 {
  16739. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16740. if err == gorm.ErrRecordNotFound {
  16741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16742. return
  16743. } else if err != nil {
  16744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16745. return
  16746. } else {
  16747. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16748. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16749. infoStr := string(Iinfos)
  16750. idetinfoStr := string(Idetinfos)
  16751. psn := &models.HisPsn{
  16752. PsnNo: res.Output.Baseinfo.PsnNo,
  16753. PatientId: patient.ID,
  16754. Certno: res.Output.Baseinfo.Certno,
  16755. Gend: res.Output.Baseinfo.Gend,
  16756. Naty: res.Output.Baseinfo.Naty,
  16757. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16758. PsnName: res.Output.Baseinfo.PsnName,
  16759. Idetinfo: idetinfoStr,
  16760. Insuinfo: infoStr,
  16761. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16762. CardInfo: "",
  16763. VerifyNumber: token,
  16764. InsuplcAdmdvs: ele.Data.InsuOrg,
  16765. }
  16766. service.CreateHisPsn(psn)
  16767. var rf []*ResultFive
  16768. json.Unmarshal([]byte(infoStr), &rf)
  16769. var insutypes []*ResultFive
  16770. var insutype string
  16771. var is390 int = 0
  16772. var is310 int = 0
  16773. for _, item := range rf {
  16774. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16775. insutypes = append(insutypes, item)
  16776. }
  16777. }
  16778. if len(insutypes) == 1 {
  16779. insutype = insutypes[0].Insutype
  16780. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16781. } else {
  16782. for _, i := range insutypes {
  16783. if i.Insutype == "390" {
  16784. is390 = 1
  16785. }
  16786. if i.Insutype == "310" {
  16787. is310 = 1
  16788. }
  16789. }
  16790. }
  16791. if is390 == 1 {
  16792. insutype = "390"
  16793. }
  16794. if is310 == 1 {
  16795. insutype = "310"
  16796. }
  16797. if len(insutypes) == 0 {
  16798. insutype = "310"
  16799. }
  16800. c.ServeSuccessJSON(map[string]interface{}{
  16801. "patient": patient,
  16802. "number": token,
  16803. "insutype": insutype,
  16804. })
  16805. }
  16806. } else {
  16807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16808. return
  16809. }
  16810. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16811. //if initFlag == 0 {
  16812. //c.TestGetJiangXiBasBaseInit()
  16813. //}
  16814. //if initEleFlag == 0 {
  16815. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16816. //}
  16817. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16818. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16819. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16820. type ELeData struct {
  16821. Data struct {
  16822. IdNo string `json:"idNo"`
  16823. IdType string `json:"idType"`
  16824. UserName string `json:"userName"`
  16825. EcToken string `json:"ecToken"`
  16826. InsuOrg string `json:"insuOrg"`
  16827. Gender string `json:"gender"`
  16828. Birthday string `json:"birthday"`
  16829. Nationality string `json:"nationality"`
  16830. Email string `json:"email"`
  16831. Extra string `json:"extra"`
  16832. } `json:"data"`
  16833. Code int `json:"code"`
  16834. Message string `json:"message"`
  16835. }
  16836. var ele ELeData
  16837. err := json.Unmarshal([]byte(result), &ele)
  16838. if err != nil {
  16839. utils.ErrorLog("解析失败:%v", err)
  16840. }
  16841. token := ele.Data.EcToken
  16842. token = Remove0000(token)
  16843. 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)
  16844. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16845. var res ResultTwo
  16846. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16847. utils.ErrorLog("解析失败:%v", err)
  16848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16849. return
  16850. }
  16851. if res.Infcode == 0 {
  16852. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16853. if err == gorm.ErrRecordNotFound {
  16854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16855. return
  16856. } else if err != nil {
  16857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16858. return
  16859. } else {
  16860. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16861. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16862. infoStr := string(Iinfos)
  16863. idetinfoStr := string(Idetinfos)
  16864. psn := &models.HisPsn{
  16865. PsnNo: res.Output.Baseinfo.PsnNo,
  16866. PatientId: patient.ID,
  16867. Certno: res.Output.Baseinfo.Certno,
  16868. Gend: res.Output.Baseinfo.Gend,
  16869. Naty: res.Output.Baseinfo.Naty,
  16870. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16871. PsnName: res.Output.Baseinfo.PsnName,
  16872. Idetinfo: idetinfoStr,
  16873. Insuinfo: infoStr,
  16874. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16875. CardInfo: "",
  16876. VerifyNumber: token,
  16877. InsuplcAdmdvs: ele.Data.InsuOrg,
  16878. }
  16879. service.CreateHisPsn(psn)
  16880. var rf []*ResultFive
  16881. json.Unmarshal([]byte(infoStr), &rf)
  16882. var insutypes []*ResultFive
  16883. var insutype string
  16884. var is390 int = 0
  16885. var is310 int = 0
  16886. for _, item := range rf {
  16887. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16888. insutypes = append(insutypes, item)
  16889. }
  16890. }
  16891. if len(insutypes) == 1 {
  16892. insutype = insutypes[0].Insutype
  16893. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16894. } else {
  16895. for _, i := range insutypes {
  16896. if i.Insutype == "390" {
  16897. is390 = 1
  16898. }
  16899. if i.Insutype == "310" {
  16900. is310 = 1
  16901. }
  16902. }
  16903. }
  16904. if is390 == 1 {
  16905. insutype = "390"
  16906. }
  16907. if is310 == 1 {
  16908. insutype = "310"
  16909. }
  16910. if len(insutypes) == 0 {
  16911. insutype = "310"
  16912. }
  16913. c.ServeSuccessJSON(map[string]interface{}{
  16914. "patient": patient,
  16915. "number": token,
  16916. "insutype": insutype,
  16917. })
  16918. }
  16919. } else {
  16920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16921. return
  16922. }
  16923. } else if miConfig.MdtrtareaAdmvs == "360100" {
  16924. //if initFlag == 0 {
  16925. //c.TestGetJiangXiBasBaseInit()
  16926. //}
  16927. //if initEleFlag == 0 {
  16928. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16929. //}
  16930. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16931. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16932. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16933. type ELeData struct {
  16934. Data struct {
  16935. IdNo string `json:"idNo"`
  16936. IdType string `json:"idType"`
  16937. UserName string `json:"userName"`
  16938. EcToken string `json:"ecToken"`
  16939. InsuOrg string `json:"insuOrg"`
  16940. Gender string `json:"gender"`
  16941. Birthday string `json:"birthday"`
  16942. Nationality string `json:"nationality"`
  16943. Email string `json:"email"`
  16944. Extra string `json:"extra"`
  16945. } `json:"data"`
  16946. Code int `json:"code"`
  16947. Message string `json:"message"`
  16948. }
  16949. var ele ELeData
  16950. err := json.Unmarshal([]byte(result), &ele)
  16951. if err != nil {
  16952. utils.ErrorLog("解析失败:%v", err)
  16953. }
  16954. token := ele.Data.EcToken
  16955. token = Remove0000(token)
  16956. 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)
  16957. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16958. var res ResultTwo
  16959. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16960. utils.ErrorLog("解析失败:%v", err)
  16961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16962. return
  16963. }
  16964. if res.Infcode == 0 {
  16965. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16966. if err == gorm.ErrRecordNotFound {
  16967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16968. return
  16969. } else if err != nil {
  16970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16971. return
  16972. } else {
  16973. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16974. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16975. infoStr := string(Iinfos)
  16976. idetinfoStr := string(Idetinfos)
  16977. psn := &models.HisPsn{
  16978. PsnNo: res.Output.Baseinfo.PsnNo,
  16979. PatientId: patient.ID,
  16980. Certno: res.Output.Baseinfo.Certno,
  16981. Gend: res.Output.Baseinfo.Gend,
  16982. Naty: res.Output.Baseinfo.Naty,
  16983. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16984. PsnName: res.Output.Baseinfo.PsnName,
  16985. Idetinfo: idetinfoStr,
  16986. Insuinfo: infoStr,
  16987. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16988. CardInfo: "",
  16989. VerifyNumber: token,
  16990. InsuplcAdmdvs: ele.Data.InsuOrg,
  16991. }
  16992. service.CreateHisPsn(psn)
  16993. var rf []*ResultFive
  16994. json.Unmarshal([]byte(infoStr), &rf)
  16995. var insutypes []*ResultFive
  16996. var insutype string
  16997. var is390 int = 0
  16998. var is310 int = 0
  16999. for _, item := range rf {
  17000. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17001. insutypes = append(insutypes, item)
  17002. }
  17003. }
  17004. if len(insutypes) == 1 {
  17005. insutype = insutypes[0].Insutype
  17006. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17007. } else {
  17008. for _, i := range insutypes {
  17009. if i.Insutype == "390" {
  17010. is390 = 1
  17011. }
  17012. if i.Insutype == "310" {
  17013. is310 = 1
  17014. }
  17015. }
  17016. }
  17017. if is390 == 1 {
  17018. insutype = "390"
  17019. }
  17020. if is310 == 1 {
  17021. insutype = "310"
  17022. }
  17023. if len(insutypes) == 0 {
  17024. insutype = "310"
  17025. }
  17026. c.ServeSuccessJSON(map[string]interface{}{
  17027. "patient": patient,
  17028. "number": token,
  17029. "insutype": insutype,
  17030. })
  17031. }
  17032. } else {
  17033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17034. return
  17035. }
  17036. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17037. //if initFlag == 0 {
  17038. c.TestGetJiangXiBasBaseInit()
  17039. //}
  17040. //if initEleFlag == 0 {
  17041. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17042. //}
  17043. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17044. type ELeData struct {
  17045. Data struct {
  17046. IdNo string `json:"idNo"`
  17047. IdType string `json:"idType"`
  17048. UserName string `json:"userName"`
  17049. EcToken string `json:"ecToken"`
  17050. InsuOrg string `json:"insuOrg"`
  17051. Gender string `json:"gender"`
  17052. Birthday string `json:"birthday"`
  17053. Nationality string `json:"nationality"`
  17054. Email string `json:"email"`
  17055. Extra string `json:"extra"`
  17056. } `json:"data"`
  17057. Code int `json:"code"`
  17058. Message string `json:"message"`
  17059. }
  17060. var ele ELeData
  17061. err := json.Unmarshal([]byte(json_result), &ele)
  17062. if err != nil {
  17063. utils.ErrorLog("解析失败:%v", err)
  17064. }
  17065. token := ele.Data.EcToken
  17066. token = Remove0000(token)
  17067. 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)
  17068. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17069. var res ResultTwo
  17070. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17071. utils.ErrorLog("解析失败:%v", err)
  17072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17073. return
  17074. }
  17075. if res.Infcode == 0 {
  17076. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17077. if err == gorm.ErrRecordNotFound {
  17078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17079. return
  17080. } else if err != nil {
  17081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17082. return
  17083. } else {
  17084. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17085. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17086. infoStr := string(Iinfos)
  17087. idetinfoStr := string(Idetinfos)
  17088. psn := &models.HisPsn{
  17089. PsnNo: res.Output.Baseinfo.PsnNo,
  17090. PatientId: patient.ID,
  17091. Certno: res.Output.Baseinfo.Certno,
  17092. Gend: res.Output.Baseinfo.Gend,
  17093. Naty: res.Output.Baseinfo.Naty,
  17094. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17095. PsnName: res.Output.Baseinfo.PsnName,
  17096. Idetinfo: idetinfoStr,
  17097. Insuinfo: infoStr,
  17098. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17099. CardInfo: "",
  17100. VerifyNumber: token,
  17101. }
  17102. service.CreateHisPsn(psn)
  17103. var rf []*ResultFive
  17104. json.Unmarshal([]byte(infoStr), &rf)
  17105. var insutypes []*ResultFive
  17106. var insutype string
  17107. var is390 int = 0
  17108. var is310 int = 0
  17109. for _, item := range rf {
  17110. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17111. insutypes = append(insutypes, item)
  17112. }
  17113. }
  17114. if len(insutypes) == 1 {
  17115. insutype = insutypes[0].Insutype
  17116. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17117. } else {
  17118. for _, i := range insutypes {
  17119. if i.Insutype == "390" {
  17120. is390 = 1
  17121. }
  17122. if i.Insutype == "310" {
  17123. is310 = 1
  17124. }
  17125. }
  17126. }
  17127. if is390 == 1 {
  17128. insutype = "390"
  17129. }
  17130. if is310 == 1 {
  17131. insutype = "310"
  17132. }
  17133. if len(insutypes) == 0 {
  17134. insutype = "310"
  17135. }
  17136. c.ServeSuccessJSON(map[string]interface{}{
  17137. "patient": patient,
  17138. "number": token,
  17139. "insutype": insutype,
  17140. })
  17141. }
  17142. } else {
  17143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17144. return
  17145. }
  17146. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17147. type ELeData struct {
  17148. Code string `json:"code"`
  17149. Data struct {
  17150. Aac002 string `json:"aac002"`
  17151. Aaz500 string `json:"aaz500"`
  17152. ActCardNo string `json:"actCardNo"`
  17153. Bab520 string `json:"bab520"`
  17154. Bkz543 string `json:"bkz543"`
  17155. BusinessType string `json:"businessType"`
  17156. CertfCodg string `json:"certfCodg"`
  17157. EcIndexNo string `json:"ecIndexNo"`
  17158. EcToken string `json:"ecToken"`
  17159. ID0000 string `json:"id0000"`
  17160. IDNo string `json:"idNo"`
  17161. IDType string `json:"idType"`
  17162. Idcode string `json:"idcode"`
  17163. IdentityToken string `json:"identity_token"`
  17164. InsuOrg string `json:"insuOrg"`
  17165. OfficeID string `json:"officeId"`
  17166. OfficeName string `json:"officeName"`
  17167. OperatorID string `json:"operatorId"`
  17168. OperatorName string `json:"operatorName"`
  17169. OrgID string `json:"orgId"`
  17170. UserName string `json:"userName"`
  17171. } `json:"data"`
  17172. Infno interface{} `json:"infno"`
  17173. Message string `json:"message"`
  17174. OrgID string `json:"orgId"`
  17175. TransType string `json:"transType"`
  17176. }
  17177. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  17178. outPutInfo = Remove0000(outPutInfo)
  17179. if len(outPutInfo) > 0 {
  17180. var ele ELeData
  17181. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17182. if err != nil {
  17183. utils.ErrorLog("解析失败:%v", err)
  17184. }
  17185. token := ele.Data.EcToken
  17186. fmt.Println(inputInfo)
  17187. fmt.Println(outPutInfo)
  17188. 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)
  17189. saveLog(result, requestLog, "1101", "获取人员信息")
  17190. var dat map[string]interface{}
  17191. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17192. fmt.Println(dat)
  17193. } else {
  17194. fmt.Println(err)
  17195. }
  17196. userJSONBytes, _ := json.Marshal(dat)
  17197. var res ResultTwo
  17198. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17199. utils.ErrorLog("解析失败:%v", err)
  17200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17201. return
  17202. }
  17203. res.ErrMsg = errMsgLog
  17204. if res.Infcode == 0 {
  17205. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17206. if err == gorm.ErrRecordNotFound {
  17207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17208. return
  17209. } else if err != nil {
  17210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17211. return
  17212. } else {
  17213. fmt.Println(res)
  17214. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17215. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17216. infoStr := string(Iinfos)
  17217. idetinfoStr := string(Idetinfos)
  17218. psn := &models.HisPsn{
  17219. PsnNo: res.Output.Baseinfo.PsnNo,
  17220. PatientId: patient.ID,
  17221. Certno: res.Output.Baseinfo.Certno,
  17222. Gend: res.Output.Baseinfo.Gend,
  17223. Naty: res.Output.Baseinfo.Naty,
  17224. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17225. PsnName: res.Output.Baseinfo.PsnName,
  17226. Idetinfo: idetinfoStr,
  17227. Insuinfo: infoStr,
  17228. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17229. CardInfo: outPutInfo,
  17230. VerifyNumber: token,
  17231. InsuplcAdmdvs: ele.Data.InsuOrg,
  17232. }
  17233. service.CreateHisPsn(psn)
  17234. var rf []*ResultFive
  17235. json.Unmarshal([]byte(infoStr), &rf)
  17236. var insutypes []*ResultFive
  17237. var insutype string
  17238. var is390 int = 0
  17239. var is310 int = 0
  17240. for _, item := range rf {
  17241. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17242. insutypes = append(insutypes, item)
  17243. }
  17244. }
  17245. if len(insutypes) == 1 {
  17246. insutype = insutypes[0].Insutype
  17247. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17248. } else {
  17249. for _, i := range insutypes {
  17250. if i.Insutype == "390" {
  17251. is390 = 1
  17252. }
  17253. if i.Insutype == "310" {
  17254. is310 = 1
  17255. }
  17256. }
  17257. }
  17258. if is390 == 1 {
  17259. insutype = "390"
  17260. }
  17261. if is310 == 1 {
  17262. insutype = "310"
  17263. }
  17264. if len(insutypes) == 0 {
  17265. insutype = "310"
  17266. }
  17267. c.ServeSuccessJSON(map[string]interface{}{
  17268. "patient": patient,
  17269. "number": token,
  17270. "insutype": insutype,
  17271. })
  17272. }
  17273. } else {
  17274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17275. return
  17276. }
  17277. }
  17278. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17279. var api string
  17280. 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 +
  17281. "&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
  17282. resp, requestErr := http.Get(api)
  17283. if requestErr != nil {
  17284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17285. return
  17286. }
  17287. body, ioErr := ioutil.ReadAll(resp.Body)
  17288. if ioErr != nil {
  17289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17291. return
  17292. }
  17293. var respJSON map[string]interface{}
  17294. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17297. return
  17298. }
  17299. var status string
  17300. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17301. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17302. var token string
  17303. var res ResultTwo //1101结果
  17304. var res10265 ResultTwo10265 //1101结果
  17305. if status == "0" { //读卡成功
  17306. var card_info string //卡信息
  17307. var busi_card_info string
  17308. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17309. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17310. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17311. fmt.Println(card_info)
  17312. fmt.Println(busi_card_info)
  17313. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17314. result, _ := json.Marshal(respJSON)
  17315. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17316. utils.ErrorLog("解析失败:%v", err)
  17317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17318. return
  17319. }
  17320. res.ErrMsg = res10265.ErrMsg
  17321. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17322. res.Infcode = infocode
  17323. res.Output = res10265.Output
  17324. res.InfRefmsgid = res10265.InfRefmsgid
  17325. if res.Infcode == 0 {
  17326. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17327. if err == gorm.ErrRecordNotFound {
  17328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17329. return
  17330. } else if err != nil {
  17331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17332. return
  17333. } else {
  17334. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17335. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17336. infoStr := string(Iinfos)
  17337. idetinfoStr := string(Idetinfos)
  17338. psn := &models.HisPsn{
  17339. PsnNo: res.Output.Baseinfo.PsnNo,
  17340. PatientId: patient.ID,
  17341. Certno: res.Output.Baseinfo.Certno,
  17342. Gend: res.Output.Baseinfo.Gend,
  17343. Naty: res.Output.Baseinfo.Naty,
  17344. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17345. PsnName: res.Output.Baseinfo.PsnName,
  17346. Idetinfo: idetinfoStr,
  17347. Insuinfo: infoStr,
  17348. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17349. CardInfo: card_info,
  17350. VerifyNumber: token,
  17351. }
  17352. var rf []*ResultFive
  17353. json.Unmarshal([]byte(infoStr), &rf)
  17354. var insutypes []*ResultFive
  17355. var insutype string
  17356. var is390 int = 0
  17357. var is310 int = 0
  17358. for _, item := range rf {
  17359. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17360. insutypes = append(insutypes, item)
  17361. }
  17362. }
  17363. if len(insutypes) == 1 {
  17364. insutype = insutypes[0].Insutype
  17365. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17366. } else {
  17367. for _, i := range insutypes {
  17368. if i.Insutype == "390" {
  17369. is390 = 1
  17370. }
  17371. if i.Insutype == "310" {
  17372. is310 = 1
  17373. }
  17374. }
  17375. }
  17376. if is390 == 1 {
  17377. insutype = "390"
  17378. }
  17379. if is310 == 1 {
  17380. insutype = "310"
  17381. }
  17382. if len(insutypes) == 0 {
  17383. insutype = "310"
  17384. }
  17385. service.CreateHisPsn(psn)
  17386. c.ServeSuccessJSON(map[string]interface{}{
  17387. "patient": patient,
  17388. "number": token,
  17389. "insutype": insutype,
  17390. })
  17391. }
  17392. } else {
  17393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17394. return
  17395. }
  17396. } else { //读卡失败
  17397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17398. return
  17399. }
  17400. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17401. res := c.GetoleInfo()
  17402. if res.Infcode == 0 {
  17403. var result string
  17404. if res.Output.MdtrtCertType == "01" {
  17405. 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)
  17406. } else if res.Output.MdtrtCertType == "02" {
  17407. 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)
  17408. } else if res.Output.MdtrtCertType == "03" {
  17409. 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)
  17410. }
  17411. var dat map[string]interface{}
  17412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17413. fmt.Println(dat)
  17414. } else {
  17415. fmt.Println(err)
  17416. }
  17417. userJSONBytes, _ := json.Marshal(dat)
  17418. var res2 ResultTwo
  17419. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17420. utils.ErrorLog("解析失败:%v", err)
  17421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17422. return
  17423. }
  17424. if res2.Infcode == 0 {
  17425. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  17426. if err == gorm.ErrRecordNotFound {
  17427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17428. return
  17429. } else if err != nil {
  17430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17431. return
  17432. } else {
  17433. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  17434. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  17435. infoStr := string(Iinfos)
  17436. idetinfoStr := string(Idetinfos)
  17437. var rf []*ResultFive
  17438. json.Unmarshal([]byte(infoStr), &rf)
  17439. var insutypes []*ResultFive
  17440. var insutype string
  17441. var is390 int = 0
  17442. var is310 int = 0
  17443. //var insuplc_admdvs string
  17444. for _, item := range rf {
  17445. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17446. insutypes = append(insutypes, item)
  17447. }
  17448. }
  17449. if len(insutypes) == 1 {
  17450. insutype = insutypes[0].Insutype
  17451. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17452. } else {
  17453. for _, i := range insutypes {
  17454. if i.Insutype == "390" {
  17455. is390 = 1
  17456. }
  17457. if i.Insutype == "310" {
  17458. is310 = 1
  17459. }
  17460. }
  17461. }
  17462. if is390 == 1 {
  17463. insutype = "390"
  17464. }
  17465. if is310 == 1 {
  17466. insutype = "310"
  17467. }
  17468. if len(insutypes) == 0 {
  17469. insutype = "310"
  17470. }
  17471. psn := &models.HisPsn{
  17472. PsnNo: res2.Output.Baseinfo.PsnNo,
  17473. PatientId: patient.ID,
  17474. Certno: res2.Output.Baseinfo.Certno,
  17475. Gend: res2.Output.Baseinfo.Gend,
  17476. Naty: res2.Output.Baseinfo.Naty,
  17477. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  17478. PsnName: res2.Output.Baseinfo.PsnName,
  17479. Idetinfo: idetinfoStr,
  17480. Insuinfo: infoStr,
  17481. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17482. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  17483. VerifyNumber: res.Output.EcToken,
  17484. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  17485. }
  17486. if res.Output.MdtrtCertType == "01" {
  17487. psn.VerifyNumber = res.Output.EcToken
  17488. //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)
  17489. } else if res.Output.MdtrtCertType == "02" {
  17490. psn.VerifyNumber = res.Output.CardNo
  17491. //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)
  17492. } else if res.Output.MdtrtCertType == "03" {
  17493. psn.VerifyNumber = res.Output.MdtrtCertNo
  17494. //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)
  17495. }
  17496. service.CreateHisPsn(psn)
  17497. var balc float64
  17498. for _, item := range rf {
  17499. if item.Insutype == insutype {
  17500. balc = item.Balc
  17501. }
  17502. }
  17503. c.ServeSuccessJSON(map[string]interface{}{
  17504. "patient": patient,
  17505. "number": res.Output.CardNo,
  17506. "insutype": insutype,
  17507. "blac": balc,
  17508. "desc": idetinfoStr,
  17509. })
  17510. }
  17511. } else {
  17512. c.ServeSuccessJSON(map[string]interface{}{
  17513. "failed_code": -10,
  17514. "msg": res2.ErrMsg,
  17515. })
  17516. }
  17517. } else {
  17518. c.ServeSuccessJSON(map[string]interface{}{
  17519. "failed_code": -10,
  17520. "msg": res.ErrMsg,
  17521. })
  17522. }
  17523. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17524. var res ResultTwo
  17525. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  17526. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17527. "&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)
  17528. resp, requestErr := http.Get(api)
  17529. if requestErr != nil {
  17530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17531. return
  17532. }
  17533. body, ioErr := ioutil.ReadAll(resp.Body)
  17534. if ioErr != nil {
  17535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17537. return
  17538. }
  17539. var respJSON map[string]interface{}
  17540. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17543. return
  17544. }
  17545. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17546. result, _ := json.Marshal(respJSON)
  17547. fmt.Println("log")
  17548. fmt.Println(string(result))
  17549. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17550. utils.ErrorLog("解析失败:%v", err)
  17551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17552. return
  17553. }
  17554. if res.Infcode == 0 {
  17555. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17556. if err == gorm.ErrRecordNotFound {
  17557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17558. return
  17559. } else if err != nil {
  17560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17561. return
  17562. } else {
  17563. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17564. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17565. infoStr := string(Iinfos)
  17566. idetinfoStr := string(Idetinfos)
  17567. var rf []*ResultFive
  17568. json.Unmarshal([]byte(infoStr), &rf)
  17569. var insutypes []*ResultFive
  17570. var insutype string
  17571. var is390 int = 0
  17572. var is310 int = 0
  17573. for _, item := range rf {
  17574. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17575. insutypes = append(insutypes, item)
  17576. }
  17577. }
  17578. if len(insutypes) == 1 {
  17579. insutype = insutypes[0].Insutype
  17580. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17581. } else {
  17582. for _, i := range insutypes {
  17583. if i.Insutype == "390" {
  17584. is390 = 1
  17585. }
  17586. if i.Insutype == "310" {
  17587. is310 = 1
  17588. }
  17589. }
  17590. }
  17591. if is390 == 1 {
  17592. insutype = "390"
  17593. }
  17594. if is310 == 1 {
  17595. insutype = "310"
  17596. }
  17597. if len(insutypes) == 0 {
  17598. insutype = "390"
  17599. }
  17600. var insuplc_admdvs string
  17601. for _, item := range rf {
  17602. if item.Insutype == insutype {
  17603. insuplc_admdvs = item.InsuplcAdmdvs
  17604. }
  17605. }
  17606. psn := &models.HisPsn{
  17607. PsnNo: res.Output.Baseinfo.PsnNo,
  17608. PatientId: patient.ID,
  17609. Certno: res.Output.Baseinfo.Certno,
  17610. Gend: res.Output.Baseinfo.Gend,
  17611. Naty: res.Output.Baseinfo.Naty,
  17612. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17613. PsnName: res.Output.Baseinfo.PsnName,
  17614. Idetinfo: idetinfoStr,
  17615. Insuinfo: infoStr,
  17616. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17617. InsuplcAdmdvs: insuplc_admdvs,
  17618. }
  17619. service.CreateHisPsn(psn)
  17620. c.ServeSuccessJSON(map[string]interface{}{
  17621. "patient": patient,
  17622. "number": res.Output.Baseinfo.Certno,
  17623. })
  17624. }
  17625. } else {
  17626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17627. return
  17628. }
  17629. } else {
  17630. type ELeData struct {
  17631. Code string `json:"code"`
  17632. Data struct {
  17633. Aac002 string `json:"aac002"`
  17634. Aaz500 string `json:"aaz500"`
  17635. ActCardNo string `json:"actCardNo"`
  17636. Bab520 string `json:"bab520"`
  17637. Bkz543 string `json:"bkz543"`
  17638. BusinessType string `json:"businessType"`
  17639. CertfCodg string `json:"certfCodg"`
  17640. EcIndexNo string `json:"ecIndexNo"`
  17641. EcToken string `json:"ecToken"`
  17642. ID0000 string `json:"id0000"`
  17643. IDNo string `json:"idNo"`
  17644. IDType string `json:"idType"`
  17645. Idcode string `json:"idcode"`
  17646. IdentityToken string `json:"identity_token"`
  17647. InsuOrg string `json:"insuOrg"`
  17648. OfficeID string `json:"officeId"`
  17649. OfficeName string `json:"officeName"`
  17650. OperatorID string `json:"operatorId"`
  17651. OperatorName string `json:"operatorName"`
  17652. OrgID string `json:"orgId"`
  17653. UserName string `json:"userName"`
  17654. } `json:"data"`
  17655. Infno interface{} `json:"infno"`
  17656. Message string `json:"message"`
  17657. OrgID string `json:"orgId"`
  17658. TransType string `json:"transType"`
  17659. }
  17660. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17661. fmt.Println(result)
  17662. outPutInfo := Remove0000(result)
  17663. fmt.Println(outPutInfo)
  17664. if len(outPutInfo) > 0 {
  17665. var ele ELeData
  17666. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17667. if err != nil {
  17668. utils.ErrorLog("解析失败:%v", err)
  17669. }
  17670. token := ele.Data.EcToken
  17671. fmt.Println(outPutInfo)
  17672. 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)
  17673. saveLog(result, requestLog, "1101", "获取人员信息")
  17674. var dat map[string]interface{}
  17675. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17676. fmt.Println(dat)
  17677. } else {
  17678. fmt.Println(err)
  17679. }
  17680. userJSONBytes, _ := json.Marshal(dat)
  17681. var res ResultTwo
  17682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17683. utils.ErrorLog("解析失败:%v", err)
  17684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17685. return
  17686. }
  17687. if res.Infcode == 0 {
  17688. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17689. if err == gorm.ErrRecordNotFound {
  17690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17691. return
  17692. } else if err != nil {
  17693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17694. return
  17695. } else {
  17696. fmt.Println(res)
  17697. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17698. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17699. infoStr := string(Iinfos)
  17700. idetinfoStr := string(Idetinfos)
  17701. psn := &models.HisPsn{
  17702. PsnNo: res.Output.Baseinfo.PsnNo,
  17703. PatientId: patient.ID,
  17704. Certno: res.Output.Baseinfo.Certno,
  17705. Gend: res.Output.Baseinfo.Gend,
  17706. Naty: res.Output.Baseinfo.Naty,
  17707. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17708. PsnName: res.Output.Baseinfo.PsnName,
  17709. Idetinfo: idetinfoStr,
  17710. Insuinfo: infoStr,
  17711. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17712. CardInfo: outPutInfo,
  17713. VerifyNumber: token,
  17714. InsuplcAdmdvs: ele.Data.InsuOrg,
  17715. }
  17716. service.CreateHisPsn(psn)
  17717. var rf []*ResultFive
  17718. json.Unmarshal([]byte(infoStr), &rf)
  17719. var insutypes []*ResultFive
  17720. var insutype string
  17721. var is390 int = 0
  17722. var is310 int = 0
  17723. for _, item := range rf {
  17724. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17725. insutypes = append(insutypes, item)
  17726. }
  17727. }
  17728. if len(insutypes) == 1 {
  17729. insutype = insutypes[0].Insutype
  17730. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17731. } else {
  17732. for _, i := range insutypes {
  17733. if i.Insutype == "390" {
  17734. is390 = 1
  17735. }
  17736. if i.Insutype == "310" {
  17737. is310 = 1
  17738. }
  17739. }
  17740. }
  17741. if is390 == 1 {
  17742. insutype = "390"
  17743. }
  17744. if is310 == 1 {
  17745. insutype = "310"
  17746. }
  17747. if len(insutypes) == 0 {
  17748. insutype = "310"
  17749. }
  17750. c.ServeSuccessJSON(map[string]interface{}{
  17751. "patient": patient,
  17752. "number": token,
  17753. "insutype": insutype,
  17754. })
  17755. }
  17756. } else {
  17757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17758. return
  17759. }
  17760. }
  17761. //fmt.Println(result)
  17762. //
  17763. //if initFlag == 0 {
  17764. // c.TestGetBasBaseInit()
  17765. //}
  17766. //token := c.GetEleBaseInfo()
  17767. //
  17768. //token = Remove0000(token)
  17769. //
  17770. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17771. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17772. ////
  17773. //var res ResultTwo
  17774. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17775. // utils.ErrorLog("解析失败:%v", err)
  17776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17777. // return
  17778. //}
  17779. //
  17780. //if res.Infcode == 0 {
  17781. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17782. // if err == gorm.ErrRecordNotFound {
  17783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17784. // return
  17785. // } else if err != nil {
  17786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17787. // return
  17788. //
  17789. // } else {
  17790. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17791. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17792. // infoStr := string(Iinfos)
  17793. // idetinfoStr := string(Idetinfos)
  17794. //
  17795. //
  17796. //
  17797. //
  17798. // var rf []*ResultFive
  17799. // json.Unmarshal([]byte(infoStr), &rf)
  17800. //
  17801. // var insutypes []*ResultFive
  17802. // var insutype string
  17803. // var is390 int = 0
  17804. // var is310 int = 0
  17805. // var insuplc_admdvs string
  17806. //
  17807. // for _, item := range rf {
  17808. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17809. // insutypes = append(insutypes, item)
  17810. // }
  17811. // }
  17812. //
  17813. // if len(insutypes) == 1 {
  17814. // insutype = insutypes[0].Insutype
  17815. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17816. // } else {
  17817. // for _, i := range insutypes {
  17818. // if i.Insutype == "390" {
  17819. // is390 = 1
  17820. // }
  17821. //
  17822. // if i.Insutype == "310" {
  17823. // is310 = 1
  17824. // }
  17825. // }
  17826. // }
  17827. // if is390 == 1 {
  17828. // insutype = "390"
  17829. // }
  17830. //
  17831. // if is310 == 1 {
  17832. // insutype = "310"
  17833. // }
  17834. // if len(insutypes) == 0 {
  17835. // insutype = "310"
  17836. // }
  17837. // for _, item := range rf {
  17838. // if item.Insutype == insutype {
  17839. // insuplc_admdvs = item.InsuplcAdmdvs
  17840. // }
  17841. // }
  17842. // psn := &models.HisPsn{
  17843. // PsnNo: res.Output.Baseinfo.PsnNo,
  17844. // Age: res.Output.Baseinfo.Age,
  17845. // PatientId: patient.ID,
  17846. // Certno: res.Output.Baseinfo.Certno,
  17847. // Brdy: res.Output.Baseinfo.Brdy,
  17848. // Gend: res.Output.Baseinfo.Gend,
  17849. // Naty: res.Output.Baseinfo.Naty,
  17850. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17851. // PsnName: res.Output.Baseinfo.PsnName,
  17852. // Idetinfo: idetinfoStr,
  17853. // Insuinfo: infoStr,
  17854. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17855. // CardInfo: "",
  17856. // VerifyNumber: token,
  17857. // InsuplcAdmdvs: insuplc_admdvs,
  17858. // }
  17859. // service.CreateHisPsn(psn)
  17860. //
  17861. // c.ServeSuccessJSON(map[string]interface{}{
  17862. // "patient": patient,
  17863. // "number": token,
  17864. // })
  17865. // }
  17866. //} else {
  17867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17868. // return
  17869. //}
  17870. }
  17871. break
  17872. case 5:
  17873. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  17874. var api string
  17875. if miConfig.MdtrtareaAdmvs == "320830" {
  17876. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  17877. "&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
  17878. fmt.Println(api)
  17879. } else if miConfig.MdtrtareaAdmvs == "320921" {
  17880. 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 +
  17881. "&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
  17882. fmt.Println(api)
  17883. } else {
  17884. 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 +
  17885. "&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)
  17886. }
  17887. resp, requestErr := http.Get(api)
  17888. if requestErr != nil {
  17889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17890. return
  17891. }
  17892. body, ioErr := ioutil.ReadAll(resp.Body)
  17893. if ioErr != nil {
  17894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17896. return
  17897. }
  17898. var respJSON map[string]interface{}
  17899. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17902. return
  17903. }
  17904. var status string
  17905. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17906. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17907. var token string
  17908. var res ResultTwo //1101结果
  17909. var res10265 ResultTwo10265 //1101结果
  17910. if status == "0" { //读卡成功
  17911. var card_info string //卡信息
  17912. //var busi_card_info string
  17913. var auth_info string
  17914. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17915. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17916. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17917. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17918. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17919. result, _ := json.Marshal(respJSON)
  17920. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17921. utils.ErrorLog("解析失败:%v", err)
  17922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17923. return
  17924. }
  17925. res.ErrMsg = res10265.ErrMsg
  17926. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17927. res.Infcode = infocode
  17928. res.Output = res10265.Output
  17929. res.InfRefmsgid = res10265.InfRefmsgid
  17930. if res.Infcode == 0 {
  17931. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17932. if err == gorm.ErrRecordNotFound {
  17933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17934. return
  17935. } else if err != nil {
  17936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17937. return
  17938. } else {
  17939. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17940. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17941. infoStr := string(Iinfos)
  17942. idetinfoStr := string(Idetinfos)
  17943. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  17944. psn := &models.HisPsn{
  17945. PsnNo: res.Output.Baseinfo.PsnNo,
  17946. PatientId: patient.ID,
  17947. Certno: res.Output.Baseinfo.Certno,
  17948. Gend: res.Output.Baseinfo.Gend,
  17949. Brdy: b,
  17950. Age: float64(age),
  17951. Naty: res.Output.Baseinfo.Naty,
  17952. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17953. PsnName: res.Output.Baseinfo.PsnName,
  17954. Idetinfo: idetinfoStr,
  17955. Insuinfo: infoStr,
  17956. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17957. CardInfo: card_info,
  17958. VerifyNumber: token,
  17959. AuthInfo: auth_info,
  17960. }
  17961. var rf []*ResultFive
  17962. json.Unmarshal([]byte(infoStr), &rf)
  17963. var insutypes []*ResultFive
  17964. var insutype string
  17965. var is390 int = 0
  17966. var is310 int = 0
  17967. for _, item := range rf {
  17968. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17969. insutypes = append(insutypes, item)
  17970. }
  17971. }
  17972. if len(insutypes) == 1 {
  17973. insutype = insutypes[0].Insutype
  17974. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17975. } else {
  17976. for _, i := range insutypes {
  17977. if i.Insutype == "390" {
  17978. is390 = 1
  17979. }
  17980. if i.Insutype == "310" {
  17981. is310 = 1
  17982. }
  17983. }
  17984. }
  17985. if is390 == 1 {
  17986. insutype = "390"
  17987. }
  17988. if is310 == 1 {
  17989. insutype = "310"
  17990. }
  17991. if len(insutypes) == 0 {
  17992. insutype = "310"
  17993. }
  17994. service.CreateHisPsn(psn)
  17995. c.ServeSuccessJSON(map[string]interface{}{
  17996. "patient": patient,
  17997. "number": token,
  17998. "insutype": insutype,
  17999. })
  18000. }
  18001. } else {
  18002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18003. return
  18004. }
  18005. } else { //读卡失败
  18006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18007. return
  18008. }
  18009. }
  18010. break
  18011. }
  18012. }
  18013. var initFlag int64 = 0
  18014. var initEleFlag int64 = 0
  18015. func (c *HisApiController) TestGetBasBaseInit() {
  18016. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18017. Iinit := DllDef.MustFindProc("Init")
  18018. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18019. url := ""
  18020. if miConfig.InsuplcAdmdvs[:4] == "4403" {
  18021. url = "http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"
  18022. } else if miConfig.InsuplcAdmdvs[:4] == "4401" {
  18023. url = ""
  18024. } else {
  18025. url = "http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"
  18026. }
  18027. fmt.Println("SSCard的报错原因:", url)
  18028. fmt.Println("SSCard的报错原因:", miConfig.InsuplcAdmdvs)
  18029. ret, _, err := Iinit.Call(StrPtr(url), StrPtr(miConfig.InsuplcAdmdvs))
  18030. if ret != 0 {
  18031. fmt.Println("SSCard的报错原因:", err)
  18032. fmt.Println("SSCard的运算结果为:", ret)
  18033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18034. return
  18035. }
  18036. result := int(ret)
  18037. fmt.Println("SSCard的运算结果为1:", result)
  18038. initFlag = 1
  18039. return
  18040. }
  18041. func (c *HisApiController) HandleJiangXiReadCard() {
  18042. fmt.Println("~~~~~~")
  18043. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18044. admin_user_id, _ := c.GetInt64("admin_user_id")
  18045. id_card_type, _ := c.GetInt64("id_card_type")
  18046. //certificates, _ := c.GetInt64("certificates")
  18047. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18048. if initFlag == 0 {
  18049. c.TestGetJiangXiBasBaseInit()
  18050. }
  18051. basStr := c.GetBasBaseInfo()
  18052. if len(basStr) == 0 {
  18053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18054. return
  18055. }
  18056. fmt.Println(basStr)
  18057. bas := strings.Split(basStr, "|")
  18058. basNumber := bas[1]
  18059. fmt.Println(basNumber)
  18060. card_sn := bas[3]
  18061. fmt.Println(card_sn)
  18062. 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, "")
  18063. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  18064. var dat map[string]interface{}
  18065. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18066. fmt.Println(dat)
  18067. } else {
  18068. fmt.Println(err)
  18069. }
  18070. userJSONBytes, _ := json.Marshal(dat)
  18071. var res ResultTwo
  18072. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18073. utils.ErrorLog("解析失败:%v", err)
  18074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18075. return
  18076. }
  18077. if res.Infcode == 0 {
  18078. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  18079. if err == gorm.ErrRecordNotFound {
  18080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18081. return
  18082. } else if err != nil {
  18083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18084. return
  18085. } else {
  18086. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18087. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18088. infoStr := string(Iinfos)
  18089. idetinfoStr := string(Idetinfos)
  18090. psn := &models.HisPsn{
  18091. PsnNo: res.Output.Baseinfo.PsnNo,
  18092. PatientId: patient.ID,
  18093. Certno: res.Output.Baseinfo.Certno,
  18094. Gend: res.Output.Baseinfo.Gend,
  18095. Naty: res.Output.Baseinfo.Naty,
  18096. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18097. PsnName: res.Output.Baseinfo.PsnName,
  18098. Idetinfo: idetinfoStr,
  18099. Insuinfo: infoStr,
  18100. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18101. CardInfo: basStr,
  18102. VerifyNumber: "",
  18103. }
  18104. service.CreateHisPsn(psn)
  18105. c.ServeSuccessJSON(map[string]interface{}{
  18106. "patient": patient,
  18107. "number": basNumber,
  18108. })
  18109. }
  18110. } else {
  18111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18112. return
  18113. }
  18114. }
  18115. func (c *HisApiController) TestGetHnBasBaseInit() {
  18116. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18117. Iinit := DllDef.MustFindProc("Init")
  18118. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18119. //http://10.77.211.236/CSB/hsa-fsi-1303
  18120. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  18121. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  18122. // 调用 Init 函数
  18123. 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"))))
  18124. //if ret != 0 {
  18125. fmt.Println("SSCard的报错原因:", err)
  18126. fmt.Println("SSCard的运算结果为:", ret)
  18127. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18128. // return
  18129. //}
  18130. result := int(ret)
  18131. fmt.Println("SSCard的运算结果为1:", result)
  18132. initFlag = 1
  18133. return
  18134. }
  18135. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  18136. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18137. Iinit := DllDef.MustFindProc("Init")
  18138. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18139. //http://10.77.211.236/CSB/hsa-fsi-1303
  18140. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  18141. if ret != 0 {
  18142. fmt.Println("SSCard的报错原因:", err)
  18143. fmt.Println("SSCard的运算结果为:", ret)
  18144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18145. return
  18146. }
  18147. result := int(ret)
  18148. fmt.Println("SSCard的运算结果为1:", result)
  18149. initFlag = 1
  18150. return
  18151. }
  18152. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  18153. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18154. Iinit := DllDef.MustFindProc("Init")
  18155. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18156. //http://10.77.211.236/CSB/hsa-fsi-1303
  18157. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  18158. if ret != 0 {
  18159. fmt.Println("SSCard的报错原因:", err)
  18160. fmt.Println("SSCard的运算结果为:", ret)
  18161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18162. return
  18163. }
  18164. result := int(ret)
  18165. fmt.Println("SSCard的运算结果为1:", result)
  18166. initFlag = 1
  18167. return
  18168. }
  18169. func (c *HisApiController) GetSFZBaseInfo() string {
  18170. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18171. readCard := DllDef.MustFindProc("ReadSFZ")
  18172. if readCard == nil {
  18173. fmt.Println("readcard is nil")
  18174. readCard = DllDef.MustFindProc("ReadSFZ")
  18175. }
  18176. str := make([]byte, 8096)
  18177. str1 := make([]byte, 8096)
  18178. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  18179. fmt.Println(r)
  18180. return Remove0000(string(str))
  18181. }
  18182. func (c *HisApiController) GetEleBaseInfo() string {
  18183. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18184. readCard := DllDef.MustFindProc("GetQRBase")
  18185. fmt.Println(readCard)
  18186. if readCard == nil {
  18187. fmt.Println("readcard is nil")
  18188. readCard = DllDef.MustFindProc("GetQRBase")
  18189. }
  18190. str := make([]byte, 1024)
  18191. str1 := make([]byte, 1024)
  18192. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18193. fmt.Println(ret2)
  18194. fmt.Println(string(str1))
  18195. fmt.Println(string(str))
  18196. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18197. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18198. if ret2 != 0 {
  18199. return ""
  18200. }
  18201. return string(str)
  18202. }
  18203. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18204. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18205. readCard := DllDef.MustFindProc("NationEcTrans")
  18206. fmt.Println(readCard)
  18207. fmt.Println("!!!!!")
  18208. pBusiCardInfo := make([]byte, 2048)
  18209. input := make(map[string]interface{})
  18210. inputData := make(map[string]interface{})
  18211. inputData["orgId"] = code
  18212. inputData["businessType"] = "01101"
  18213. inputData["operatorId"] = "1"
  18214. inputData["operatorName"] = "admin"
  18215. inputData["officeId"] = "001"
  18216. inputData["officeName"] = "血透室"
  18217. inputData["deviceType"] = ""
  18218. input["data"] = inputData
  18219. input["orgId"] = code
  18220. input["transType"] = "ec.query"
  18221. bytesData, _ := json.Marshal(input)
  18222. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18223. fmt.Println(ret2)
  18224. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18225. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18226. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  18227. }
  18228. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18229. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18230. readCard := DllDef.MustFindProc("NationEcTrans")
  18231. fmt.Println(readCard)
  18232. fmt.Println("!!!!!")
  18233. pBusiCardInfo := make([]byte, 2048)
  18234. input := make(map[string]interface{})
  18235. inputData := make(map[string]interface{})
  18236. inputData["orgId"] = code
  18237. inputData["businessType"] = "01101"
  18238. inputData["operatorId"] = "9"
  18239. inputData["operatorName"] = "admin"
  18240. inputData["officeId"] = "001"
  18241. inputData["officeName"] = "血透室"
  18242. inputData["deviceType"] = ""
  18243. input["data"] = inputData
  18244. input["orgId"] = code
  18245. input["transType"] = "ec.query"
  18246. bytesData, _ := json.Marshal(input)
  18247. 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])))
  18248. fmt.Println(ret2)
  18249. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18250. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18251. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18252. }
  18253. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  18254. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18255. readCard := DllDef.MustFindProc("NationEcTrans")
  18256. fmt.Println(readCard)
  18257. fmt.Println("!!!!!")
  18258. pBusiCardInfo := make([]byte, 2048)
  18259. input := make(map[string]interface{})
  18260. inputData := make(map[string]interface{})
  18261. inputData["orgId"] = code
  18262. inputData["businessType"] = "01301"
  18263. inputData["operatorId"] = "9"
  18264. inputData["operatorName"] = "admin"
  18265. inputData["officeId"] = "001"
  18266. inputData["officeName"] = "血透室"
  18267. inputData["deviceType"] = ""
  18268. input["data"] = inputData
  18269. input["orgId"] = code
  18270. input["transType"] = "ec.query"
  18271. bytesData, _ := json.Marshal(input)
  18272. 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])))
  18273. fmt.Println(ret2)
  18274. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18275. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18276. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18277. }
  18278. func GetJxEleBaseInfo(org_id int64) string {
  18279. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18280. readCard := DllDef.MustFindProc("NationEcTrans")
  18281. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18282. if readCard == nil {
  18283. fmt.Println("readcard is nil")
  18284. readCard = DllDef.MustFindProc("NationEcTrans")
  18285. }
  18286. str1 := make([]byte, 1024)
  18287. data := make(map[string]interface{})
  18288. inputData := make(map[string]interface{})
  18289. inputData["orgId"] = miConfig.Code
  18290. inputData["businessType"] = "01101"
  18291. inputData["operatorId"] = "test001"
  18292. inputData["operatorName"] = "cn"
  18293. inputData["officeId"] = "32760"
  18294. inputData["officeName"] = "waike"
  18295. inputData["deviceType"] = ""
  18296. data["data"] = inputData
  18297. data["transType"] = "ec.query"
  18298. data["extra "] = ""
  18299. data["orgId"] = miConfig.Code
  18300. bytesData, _ := json.Marshal(data)
  18301. //bytesData, _ := json.Marshal(data)
  18302. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18303. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18304. fmt.Println(ret2)
  18305. fmt.Println(string(str1))
  18306. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18307. if ret2 != 0 {
  18308. return ""
  18309. }
  18310. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18311. }
  18312. //func GetJxEleBaseInfoTWO(org_id int64) string {
  18313. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  18314. // readCard := DllDef.MustFindProc("NationEcTrans")
  18315. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18316. //
  18317. // if readCard == nil {
  18318. // fmt.Println("readcard is nil")
  18319. // readCard = DllDef.MustFindProc("NationEcTrans")
  18320. // }
  18321. // str1 := make([]byte, 1024)
  18322. //
  18323. // data := make(map[string]interface{})
  18324. //
  18325. // inputData := make(map[string]interface{})
  18326. // inputData["orgId"] = miConfig.Code
  18327. // inputData["businessType"] = "01101"
  18328. // inputData["operatorId"] = "test001"
  18329. // inputData["operatorName"] = "cn"
  18330. // inputData["officeId"] = "32760"
  18331. // inputData["officeName"] = "waike"
  18332. // inputData["deviceType"] = ""
  18333. //
  18334. // data["data"] = inputData
  18335. // data["transType"] = "ec.query"
  18336. // data["extra "] = ""
  18337. // data["orgId"] = miConfig.Code
  18338. // bytesData, _ := json.Marshal(data)
  18339. // //bytesData, _ := json.Marshal(data)
  18340. //
  18341. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18342. //
  18343. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18344. // fmt.Println(ret2)
  18345. // fmt.Println(string(str1))
  18346. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18347. //
  18348. // if ret2 != 0 {
  18349. // return ""
  18350. // }
  18351. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18352. //}
  18353. func GetJxEleBaseInitInfo(org_id int64) string {
  18354. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18355. readCard := DllDef.MustFindProc("NationEcTrans")
  18356. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18357. if readCard == nil {
  18358. fmt.Println("readcard is nil")
  18359. readCard = DllDef.MustFindProc("NationEcTrans")
  18360. }
  18361. str1 := make([]byte, 2048)
  18362. data := make(map[string]interface{})
  18363. inputData := make(map[string]interface{})
  18364. inputData["orgId"] = miConfig.Code
  18365. inputData["businessType"] = "01101"
  18366. inputData["operatorId"] = "1"
  18367. inputData["operatorName"] = "huangchuang"
  18368. inputData["officeId"] = "101"
  18369. inputData["officeName"] = "xuetou"
  18370. inputData["deviceType"] = ""
  18371. data["data"] = inputData
  18372. data["transType"] = "ec.query"
  18373. data["orgId"] = miConfig.Code
  18374. bytesData, _ := json.Marshal(data)
  18375. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18376. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18377. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  18378. fmt.Println(ret2)
  18379. fmt.Println(string(str1))
  18380. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18381. if ret2 != 0 {
  18382. return ""
  18383. }
  18384. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  18385. initEleFlag = 1
  18386. }
  18387. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18388. }
  18389. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  18390. // // 构建命令
  18391. // cmd := exec.Command("python", "b.py")
  18392. //
  18393. // // 执行命令并等待完成
  18394. // output, err := cmd.CombinedOutput()
  18395. // if err != nil {
  18396. // fmt.Println("Error executing Python script:", err)
  18397. // return
  18398. // }
  18399. //
  18400. // // 打印Python脚本的输出
  18401. // fmt.Println(string(output))
  18402. //}
  18403. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  18404. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  18405. readCard := DllDef.MustFindProc("gxyb_call")
  18406. if readCard == nil {
  18407. fmt.Println("readcard is nil")
  18408. readCard = DllDef.MustFindProc("gxyb_call")
  18409. }
  18410. str := make([]byte, 1024)
  18411. str1 := make([]byte, 1024)
  18412. //data := make(map[string]interface{})
  18413. currentTime := time.Now()
  18414. // 格式化时间为 "YYYYMMDDHH24MISS"
  18415. formattedTime := currentTime.Format("20060102150405")
  18416. inputData := make(map[string]interface{})
  18417. inputData2 := make(map[string]interface{})
  18418. inputData["transNo"] = "1401"
  18419. inputData["transType"] = "passwordCheck"
  18420. inputData["timestamp"] = formattedTime
  18421. inputData2["fixmedinsCode"] = code
  18422. inputData2["psnNo"] = ""
  18423. inputData["data"] = inputData2
  18424. jsonBytes, err := json.Marshal(inputData)
  18425. if err != nil {
  18426. fmt.Println("Error encoding map to JSON:", err)
  18427. }
  18428. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18429. fmt.Println(string(str1))
  18430. fmt.Println(string(str))
  18431. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18432. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18433. if ret2 != 0 {
  18434. return ""
  18435. }
  18436. return string(str)
  18437. }
  18438. func (c *HisApiController) GetoleInfo() Response {
  18439. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  18440. defer ole.CoUninitialize()
  18441. // Replace with the ProgID or CLSID of your COM object
  18442. progID := "YinHai.XJ.Actual.Interface.New"
  18443. // Create COM object
  18444. unknown, err := oleutil.CreateObject(progID)
  18445. if err != nil {
  18446. fmt.Println("Unable to create COM object:", err)
  18447. }
  18448. defer unknown.Release()
  18449. // Query for the IDispatch interface
  18450. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  18451. if err != nil {
  18452. fmt.Println("Unable to get IDispatch interface:", err)
  18453. }
  18454. defer dispatch.Release()
  18455. // Prepare parameters
  18456. transNo := "1401"
  18457. transType := "passwordCheck"
  18458. timestamp := time.Now().Unix()
  18459. fixmedinsCode := "H45072101171"
  18460. psnNo := ""
  18461. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  18462. result2 := ""
  18463. // Call COM object's method using the IDispatch interface
  18464. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  18465. fmt.Println(resulr)
  18466. fmt.Println(result2)
  18467. if err != nil {
  18468. fmt.Println("调用COM对象方法失败:", err)
  18469. }
  18470. var response Response
  18471. err2 := json.Unmarshal([]byte(result2), &response)
  18472. if err2 != nil {
  18473. fmt.Println("解析JSON失败:", err)
  18474. }
  18475. return response
  18476. }
  18477. func (c *HisApiController) GetBasBaseInfo() string {
  18478. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18479. readCard := DllDef.MustFindProc("ReadCardBas")
  18480. if readCard == nil {
  18481. fmt.Println("readcard is nil")
  18482. readCard = DllDef.MustFindProc("ReadCardBas")
  18483. }
  18484. str := make([]byte, 1024)
  18485. str1 := make([]byte, 1024)
  18486. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18487. fmt.Println(string(str1))
  18488. fmt.Println(string(str))
  18489. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18490. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18491. if ret2 != 0 {
  18492. return ""
  18493. }
  18494. return string(str)
  18495. }
  18496. type Program struct {
  18497. FunctionID string `xml:"function_id"`
  18498. CardInfo string `xml:"cardinfo"`
  18499. User string `xml:"user"`
  18500. }
  18501. func (c *HisApiController) GetBasBaseInfo1111() string {
  18502. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  18503. readCard := DllDef.MustFindProc("ReadSICardInfo")
  18504. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  18505. if readCard == nil {
  18506. fmt.Println("readcard is nil")
  18507. readCard = DllDef.MustFindProc("ReadSICardInfo")
  18508. }
  18509. if readCard2 == nil {
  18510. fmt.Println("readcard is nil")
  18511. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  18512. }
  18513. str := make([]byte, 1024)
  18514. str1 := make([]byte, 1024)
  18515. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18516. str3 := make([]byte, 1024)
  18517. str4 := make([]byte, 1024)
  18518. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  18519. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18520. //if err != nil {
  18521. // fmt.Println("Error opening file:", err)
  18522. //}
  18523. //defer file.Close()
  18524. //
  18525. //var lastProgram Program
  18526. //scanner := bufio.NewScanner(file)
  18527. //inProgram := false
  18528. //
  18529. //for scanner.Scan() {
  18530. // line := scanner.Text()
  18531. // if strings.Contains(line, "<program>") {
  18532. // inProgram = true
  18533. // programXML := "<program>"
  18534. // for scanner.Scan() {
  18535. // line = scanner.Text()
  18536. // programXML += line
  18537. // if strings.Contains(line, "</program>") {
  18538. // programXML += "</program>"
  18539. // break
  18540. // }
  18541. // }
  18542. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18543. // // 解析成功,更新最后的 Program
  18544. // }
  18545. // inProgram = false
  18546. // }
  18547. //}
  18548. //
  18549. // fmt.Println("Error reading file:", inProgram)
  18550. //
  18551. //if err := scanner.Err(); err != nil {
  18552. // fmt.Println("Error reading file:", err)
  18553. //}
  18554. // 输出最后一次的 Program
  18555. //fmt.Printf("最后一次的 <program>:\n")
  18556. //fmt.Printf("<program>\n")
  18557. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18558. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18559. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18560. //fmt.Printf("</program>\n")
  18561. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18562. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18563. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18564. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18565. return ConvertToString(string(str), "gbk", "utf-8")
  18566. }
  18567. func (c *HisApiController) GetBasBaseInfo22222() string {
  18568. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18569. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18570. if readCard == nil {
  18571. fmt.Println("readcard is nil")
  18572. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18573. }
  18574. str := make([]byte, 1024)
  18575. str1 := make([]byte, 1024)
  18576. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  18577. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18578. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18579. //if err != nil {
  18580. // fmt.Println("Error opening file:", err)
  18581. //}
  18582. //defer file.Close()
  18583. //
  18584. //var lastProgram Program
  18585. //scanner := bufio.NewScanner(file)
  18586. //inProgram := false
  18587. //
  18588. //for scanner.Scan() {
  18589. // line := scanner.Text()
  18590. // if strings.Contains(line, "<program>") {
  18591. // inProgram = true
  18592. // programXML := "<program>"
  18593. // for scanner.Scan() {
  18594. // line = scanner.Text()
  18595. // programXML += line
  18596. // if strings.Contains(line, "</program>") {
  18597. // programXML += "</program>"
  18598. // break
  18599. // }
  18600. // }
  18601. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18602. // // 解析成功,更新最后的 Program
  18603. // }
  18604. // inProgram = false
  18605. // }
  18606. //}
  18607. //
  18608. // fmt.Println("Error reading file:", inProgram)
  18609. //
  18610. //if err := scanner.Err(); err != nil {
  18611. // fmt.Println("Error reading file:", err)
  18612. //}
  18613. // 输出最后一次的 Program
  18614. //fmt.Printf("最后一次的 <program>:\n")
  18615. //fmt.Printf("<program>\n")
  18616. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18617. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18618. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18619. //fmt.Printf("</program>\n")
  18620. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18621. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18622. return ConvertToString(string(str1), "gbk", "utf-8")
  18623. }
  18624. func (c *HisApiController) GetahBasBaseInfo() string {
  18625. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18626. readCard := DllDef.MustFindProc("iReadCardBas")
  18627. if readCard == nil {
  18628. fmt.Println("readcard is nil")
  18629. readCard = DllDef.MustFindProc("iReadCardBas")
  18630. }
  18631. //str := make([]byte, 1024)
  18632. str1 := make([]byte, 1024)
  18633. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18634. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18635. //if err != nil {
  18636. // fmt.Println("Error opening file:", err)
  18637. //}
  18638. //defer file.Close()
  18639. //
  18640. //var lastProgram Program
  18641. //scanner := bufio.NewScanner(file)
  18642. //inProgram := false
  18643. //
  18644. //for scanner.Scan() {
  18645. // line := scanner.Text()
  18646. // if strings.Contains(line, "<program>") {
  18647. // inProgram = true
  18648. // programXML := "<program>"
  18649. // for scanner.Scan() {
  18650. // line = scanner.Text()
  18651. // programXML += line
  18652. // if strings.Contains(line, "</program>") {
  18653. // programXML += "</program>"
  18654. // break
  18655. // }
  18656. // }
  18657. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18658. // // 解析成功,更新最后的 Program
  18659. // }
  18660. // inProgram = false
  18661. // }
  18662. //}
  18663. //
  18664. // fmt.Println("Error reading file:", inProgram)
  18665. //
  18666. //if err := scanner.Err(); err != nil {
  18667. // fmt.Println("Error reading file:", err)
  18668. //}
  18669. // 输出最后一次的 Program
  18670. //fmt.Printf("最后一次的 <program>:\n")
  18671. //fmt.Printf("<program>\n")
  18672. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18673. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18674. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18675. //fmt.Printf("</program>\n")
  18676. fmt.Println(string(str1))
  18677. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18678. if ret2 != 0 {
  18679. return ""
  18680. }
  18681. return string(str1)
  18682. }
  18683. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18684. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18685. readCard := DllDef.MustFindProc("read_cardinfo")
  18686. if readCard == nil {
  18687. fmt.Println("readcard is nil")
  18688. readCard = DllDef.MustFindProc("read_cardinfo")
  18689. }
  18690. str := make([]byte, 1024) //卡号
  18691. str1 := make([]byte, 1024) //卡识别码
  18692. str2 := make([]byte, 1024) //身份证号
  18693. str3 := make([]byte, 1024) //姓名
  18694. str4 := make([]byte, 1024) //错误信息
  18695. 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])))
  18696. fmt.Println(string(str1))
  18697. fmt.Println(string(str))
  18698. fmt.Println(string(str2))
  18699. fmt.Println(string(str3))
  18700. fmt.Println(string(str4))
  18701. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18702. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18703. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18704. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18705. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18706. if ret2 != 0 {
  18707. return "", "", "", "", ""
  18708. }
  18709. return string(str), string(str1), string(str2), string(str3), string(str4)
  18710. }
  18711. type CustomFundPay struct {
  18712. FundPayType string `json:"fund_pay_type"`
  18713. FundPayamt float64 `json:"fund_payamt"`
  18714. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18715. }
  18716. //func (c *HisApiController) GetBatchSettleList() {
  18717. // start_time_str := c.GetString("start_time")
  18718. // //end_time_str := c.GetString("end_time")
  18719. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18720. //
  18721. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18722. //
  18723. // for _, item := range orders {
  18724. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18725. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18726. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18727. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18728. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18729. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18730. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18731. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18732. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18733. //
  18734. // if order.ID == 0 {
  18735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18736. // return
  18737. // }
  18738. //
  18739. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18740. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18741. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18742. // //fmt.Println(count)
  18743. // //var zero string
  18744. // //number := count + 1
  18745. // //if number >= 1000 {
  18746. // // zero = "0000" + strconv.FormatInt(number, 10)
  18747. // //} else if number >= 10000 {
  18748. // // zero = "000" + strconv.FormatInt(number, 10)
  18749. // //} else if number >= 100000 {
  18750. // // zero = "00" + strconv.FormatInt(number, 10)
  18751. // //} else if number >= 1000000 {
  18752. // // zero = "0" + strconv.FormatInt(number, 10)
  18753. // //} else {
  18754. // // zero = strconv.FormatInt(number, 10)
  18755. // //}
  18756. // //fmt.Println(zero)
  18757. //
  18758. // struct4101 := service.Struct4101{
  18759. // PsnNo: order.PsnNo,
  18760. // MdtrtId: order.MdtrtId,
  18761. // SetlId: order.SetlId,
  18762. // PsnName: order.PsnName,
  18763. // Gend: order.Gend,
  18764. // Brdy: his.Brdy,
  18765. // Age: his.Age,
  18766. // Naty: order.Naty,
  18767. // PatnCertType: "01",
  18768. // Certno: order.Certno,
  18769. // Prfs: "90",
  18770. // ConerName: roles[0].UserName,
  18771. // PatnRlts: "99",
  18772. // ConerAddr: miConfig.OrgName,
  18773. // ConerTel: admin.Mobile,
  18774. // HiType: order.Insutype,
  18775. // Insuplc: miConfig.InsuplcAdmdvs,
  18776. // MaindiagFlag: "1",
  18777. // BillCode: order.SetlId,
  18778. // BillNo: order.SetlId,
  18779. // BizSn: order.Number,
  18780. // PsnSelfPay: order.PsnPartAmt,
  18781. // PsnOwnPay: order.PsnPartAmt,
  18782. // AcctPay: order.AcctPay,
  18783. // PsnCashpay: order.PsnCashPay,
  18784. // HiPaymtd: "1",
  18785. // Hsorg: miConfig.InsuplcAdmdvs,
  18786. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18787. // MedinsFillPsn: curRoles.UserName,
  18788. // MedinsFillDept: miConfig.OrgName,
  18789. // IptMedType: "2",
  18790. // }
  18791. // struct4101.SetlBegnDate = order.SetlTime
  18792. // struct4101.SetlEndDate = order.SetlTime
  18793. // time_arr := strings.Split(order.SetlTime, " ")
  18794. // struct4101.AdmTime = time_arr[0]
  18795. // struct4101.AdmEndTime = time_arr[0]
  18796. //
  18797. // var rf []CustomFundPay
  18798. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18799. //
  18800. // var tempFunPays []service.CustomStruct
  18801. // for _, item := range rf {
  18802. // var tempFunPay service.CustomStruct
  18803. // tempFunPay.FundPayamt = item.FundPayamt
  18804. // tempFunPay.FundPayType = item.FundPayType
  18805. // tempFunPays = append(tempFunPays, tempFunPay)
  18806. // }
  18807. // struct4101.CustomStruct = tempFunPays
  18808. //
  18809. // var tempDiaginfos []service.DiaginfoStructTwo
  18810. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18811. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18812. //
  18813. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18814. // var config []*models.HisXtDiagnoseConfig
  18815. // for _, item := range diagnosis_ids {
  18816. // id, _ := strconv.ParseInt(item, 10, 64)
  18817. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18818. // config = append(config, &diagnosisConfig)
  18819. // }
  18820. //
  18821. // for index, item := range config {
  18822. // if index == 0 {
  18823. // var tempDiaginfo service.DiaginfoStructTwo
  18824. // tempDiaginfo.DiagCode = item.CountryCode
  18825. // tempDiaginfo.DiagName = item.CountryContentName
  18826. // tempDiaginfo.DiagType = "1"
  18827. // tempDiaginfo.MaindiagFlag = "1"
  18828. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18829. // } else {
  18830. // var tempDiaginfo service.DiaginfoStructTwo
  18831. // tempDiaginfo.DiagCode = item.CountryCode
  18832. // tempDiaginfo.DiagName = item.CountryContentName
  18833. // tempDiaginfo.DiagType = "1"
  18834. // tempDiaginfo.MaindiagFlag = "0"
  18835. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18836. // }
  18837. // }
  18838. // struct4101.Diseinfo = tempDiaginfos
  18839. //
  18840. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18841. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18842. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18843. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18844. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18845. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18846. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18847. //
  18848. // var iteminfo service.IteminfoStruct
  18849. //
  18850. // var bedCostTotal float64 = 0 //床位总费
  18851. // var bedCostSelfTotal float64 = 0 //床位自费
  18852. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18853. //
  18854. // var operationCostTotal float64 = 0 //手术费
  18855. // var operationCostSelfTotal float64 = 0 //手术费
  18856. // var operationCostPartSelfTotal float64 = 0 //手术费
  18857. //
  18858. // var otherCostTotal float64 = 0 //其他费用
  18859. // var otherCostSelfTotal float64 = 0 //其他费用
  18860. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18861. //
  18862. // var materialCostTotal float64 = 0 //材料费
  18863. // var materialCostSelfTotal float64 = 0 //材料费
  18864. // var materialCostPartSelfTotal float64 = 0 //材料费
  18865. //
  18866. // var westernMedicineCostTotal float64 = 0 //西药费
  18867. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18868. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18869. //
  18870. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18871. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18872. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18873. //
  18874. // var checkCostTotal float64 = 0 //检查费
  18875. // var checkCostSelfTotal float64 = 0 //检查费
  18876. // var checkCostPartSelfTotal float64 = 0 //检查费
  18877. //
  18878. // var laboratoryCostTotal float64 = 0 //化验费
  18879. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18880. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18881. //
  18882. // var treatCostTotal float64 = 0 //治疗费用
  18883. // var treatCostSelfTotal float64 = 0 //治疗费用
  18884. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18885. //
  18886. // decimal.DivisionPrecision = 2
  18887. //
  18888. // var bed_fulamt_ownpay_amt float64 = 0
  18889. // var operation_fulamt_ownpay_amt float64 = 0
  18890. // var other_fulamt_ownpay_amt float64 = 0
  18891. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18892. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18893. // var check_fulamt_ownpay_amt float64 = 0
  18894. // var material_fulamt_ownpay_amt float64 = 0
  18895. // var laboratory_fulamt_ownpay_amt float64 = 0
  18896. // var treat_fulamt_ownpay_amt float64 = 0
  18897. //
  18898. // var bed_claa_sunmfee float64 = 0
  18899. // var bed_clab_amt float64 = 0
  18900. // var bed_other_amt float64 = 0
  18901. //
  18902. // var operation_claa_sunmfee float64 = 0
  18903. // var operation_clab_amt float64 = 0
  18904. // var operation_other_amt float64 = 0
  18905. //
  18906. // var other_claa_sunmfee float64 = 0
  18907. // var other_clab_amt float64 = 0
  18908. // var other_other_amt float64 = 0
  18909. //
  18910. // var westernMedicine_claa_sunmfee float64 = 0
  18911. // var westernMedicine_clab_amt float64 = 0
  18912. // var westernMedicine_other_amt float64 = 0
  18913. //
  18914. // var chineseTraditional_claa_sunmfee float64 = 0
  18915. // var chineseTraditional_clab_amt float64 = 0
  18916. // var chineseTraditional_other_amt float64 = 0
  18917. //
  18918. // var check_claa_sunmfee float64 = 0
  18919. // var check_clab_amt float64 = 0
  18920. // var check_other_amt float64 = 0
  18921. //
  18922. // var material_claa_sunmfee float64 = 0
  18923. // var material_clab_amt float64 = 0
  18924. // var material_other_amt float64 = 0
  18925. //
  18926. // var laboratory_claa_sunmfee float64 = 0
  18927. // var laboratory_clab_amt float64 = 0
  18928. // var laboratory_other_amt float64 = 0
  18929. //
  18930. // var treat_claa_sunmfee float64 = 0
  18931. // var treat_clab_amt float64 = 0
  18932. // var treat_other_amt float64 = 0
  18933. //
  18934. // for _, item := range order.HisOrderInfo {
  18935. // if item.MedChrgitmType == "01" { //床位费
  18936. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18937. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18938. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18939. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18940. // if item.ChrgitmLv == "1" {
  18941. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18942. // }
  18943. // if item.ChrgitmLv == "2" {
  18944. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18945. //
  18946. // }
  18947. // if item.ChrgitmLv == "3" {
  18948. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18949. // }
  18950. //
  18951. // }
  18952. //
  18953. // if item.MedChrgitmType == "03" { //检查费
  18954. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18955. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18956. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18957. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18958. // if item.ChrgitmLv == "1" {
  18959. //
  18960. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18961. //
  18962. // }
  18963. // if item.ChrgitmLv == "2" {
  18964. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18965. //
  18966. // }
  18967. // if item.ChrgitmLv == "3" {
  18968. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18969. // }
  18970. // }
  18971. //
  18972. // if item.MedChrgitmType == "04" { //化验费
  18973. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18974. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18975. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18976. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18977. // if item.ChrgitmLv == "1" {
  18978. //
  18979. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18980. //
  18981. // }
  18982. // if item.ChrgitmLv == "2" {
  18983. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18984. //
  18985. // }
  18986. // if item.ChrgitmLv == "3" {
  18987. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18988. // }
  18989. // }
  18990. //
  18991. // if item.MedChrgitmType == "05" { //治疗费
  18992. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18993. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18994. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18995. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18996. // if item.ChrgitmLv == "1" {
  18997. //
  18998. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18999. //
  19000. // }
  19001. // if item.ChrgitmLv == "2" {
  19002. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19003. //
  19004. // }
  19005. // if item.ChrgitmLv == "3" {
  19006. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19007. // }
  19008. // }
  19009. //
  19010. // if item.MedChrgitmType == "06" { //手术费
  19011. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19012. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19013. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19014. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19015. //
  19016. // if item.ChrgitmLv == "1" {
  19017. //
  19018. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19019. //
  19020. // }
  19021. // if item.ChrgitmLv == "2" {
  19022. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19023. //
  19024. // }
  19025. // if item.ChrgitmLv == "3" {
  19026. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19027. // }
  19028. // }
  19029. //
  19030. // if item.MedChrgitmType == "08" { //材料费
  19031. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19032. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19033. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19034. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19035. // if item.ChrgitmLv == "1" {
  19036. //
  19037. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19038. //
  19039. // }
  19040. // if item.ChrgitmLv == "2" {
  19041. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19042. //
  19043. // }
  19044. // if item.ChrgitmLv == "3" {
  19045. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19046. // }
  19047. // }
  19048. //
  19049. // if item.MedChrgitmType == "09" { //西药费
  19050. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19051. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19052. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19053. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19054. // if item.ChrgitmLv == "1" {
  19055. //
  19056. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19057. //
  19058. // }
  19059. // if item.ChrgitmLv == "2" {
  19060. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19061. //
  19062. // }
  19063. // if item.ChrgitmLv == "3" {
  19064. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19065. // }
  19066. // }
  19067. //
  19068. // if item.MedChrgitmType == "11" { //中成费
  19069. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19070. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19071. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19072. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19073. // if item.ChrgitmLv == "1" {
  19074. //
  19075. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19076. //
  19077. // }
  19078. // if item.ChrgitmLv == "2" {
  19079. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19080. //
  19081. // }
  19082. // if item.ChrgitmLv == "3" {
  19083. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19084. // }
  19085. // }
  19086. //
  19087. // if item.MedChrgitmType == "14" { //其他费
  19088. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19089. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19090. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19091. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19092. // if item.ChrgitmLv == "1" {
  19093. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19094. //
  19095. // }
  19096. // if item.ChrgitmLv == "2" {
  19097. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19098. //
  19099. // }
  19100. // if item.ChrgitmLv == "3" {
  19101. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19102. // }
  19103. // }
  19104. //
  19105. // }
  19106. //
  19107. // var iteminfoStructs []service.IteminfoStruct
  19108. //
  19109. // if bedCostTotal != 0 {
  19110. // iteminfo.MedChrgitm = "01"
  19111. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19112. // iteminfo.Amt = bedCostTotal
  19113. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19114. // iteminfo.ClabAmt = bed_clab_amt
  19115. // iteminfo.OthAmt = bed_other_amt
  19116. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19117. // }
  19118. //
  19119. // if checkCostTotal != 0 {
  19120. // iteminfo.MedChrgitm = "03"
  19121. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19122. // iteminfo.Amt = checkCostTotal
  19123. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19124. // iteminfo.ClabAmt = check_clab_amt
  19125. // iteminfo.OthAmt = check_other_amt
  19126. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19127. //
  19128. // }
  19129. //
  19130. // if laboratoryCostTotal != 0 {
  19131. // iteminfo.MedChrgitm = "04"
  19132. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19133. // iteminfo.Amt = laboratoryCostTotal
  19134. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19135. // iteminfo.ClabAmt = laboratory_clab_amt
  19136. // iteminfo.OthAmt = laboratory_other_amt
  19137. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19138. //
  19139. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19140. //
  19141. // }
  19142. //
  19143. // if treatCostTotal != 0 {
  19144. // iteminfo.MedChrgitm = "05"
  19145. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19146. // iteminfo.Amt = treatCostTotal
  19147. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19148. // iteminfo.ClabAmt = treat_clab_amt
  19149. // iteminfo.OthAmt = treat_other_amt
  19150. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19151. // //(struct4101.IteminfoStruct, iteminfo)
  19152. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19153. // }
  19154. //
  19155. // if operationCostTotal != 0 {
  19156. // iteminfo.MedChrgitm = "06"
  19157. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19158. // iteminfo.Amt = operationCostTotal
  19159. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19160. // iteminfo.ClabAmt = operation_clab_amt
  19161. // iteminfo.OthAmt = operation_other_amt
  19162. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19163. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19164. // }
  19165. //
  19166. // if materialCostTotal != 0 {
  19167. // iteminfo.MedChrgitm = "08"
  19168. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19169. // iteminfo.Amt = materialCostTotal
  19170. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19171. // iteminfo.ClabAmt = material_clab_amt
  19172. // iteminfo.OthAmt = material_other_amt
  19173. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19174. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19175. // }
  19176. //
  19177. // if westernMedicineCostTotal != 0 {
  19178. // iteminfo.MedChrgitm = "09"
  19179. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19180. // iteminfo.Amt = westernMedicineCostTotal
  19181. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19182. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19183. // iteminfo.OthAmt = westernMedicine_other_amt
  19184. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19185. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19186. //
  19187. // }
  19188. // if chineseTraditionalMedicineCostTotal != 0 {
  19189. // iteminfo.MedChrgitm = "11"
  19190. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19191. // iteminfo.Amt = westernMedicineCostTotal
  19192. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19193. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19194. // iteminfo.OthAmt = westernMedicine_other_amt
  19195. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19196. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19197. //
  19198. // }
  19199. // if otherCostTotal != 0 {
  19200. // iteminfo.MedChrgitm = "14"
  19201. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19202. // iteminfo.Amt = otherCostTotal
  19203. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19204. // iteminfo.ClabAmt = other_clab_amt
  19205. // iteminfo.OthAmt = other_other_amt
  19206. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19207. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19208. //
  19209. // }
  19210. // struct4101.IteminfoStruct = iteminfoStructs
  19211. // struct4101.Ntly = "中国"
  19212. // struct4101.AdmCaty = "A03.06"
  19213. //
  19214. // struct4101.DoctorName = doctor.UserName
  19215. // struct4101.DoctorCode = doctor.DoctorNumber
  19216. //
  19217. // var res ResultSeventeen
  19218. //
  19219. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19220. // struct4101.BillCode = order.Number
  19221. // struct4101.BillNo = order.SetlId
  19222. // var resOther ResultSeventeenOther
  19223. // var pp models.PublicParams
  19224. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19225. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19226. // pp.FixmedinsName = miConfig.OrgName
  19227. // pp.FixmedinsCode = miConfig.Code
  19228. // pp.RequestUrl = miConfig.Url
  19229. // pp.Cainfo = miConfig.Cainfo
  19230. // pp.SecretKey = miConfig.SecretKey
  19231. // pp.AccessKey = miConfig.AccessKey
  19232. // pp.OpterName = curRoles.UserName
  19233. //
  19234. // client := &http.Client{}
  19235. // var req *http.Request
  19236. // data := make(map[string]interface{})
  19237. // data["struct4101"] = struct4101
  19238. // data["pp"] = pp
  19239. // bytesData, _ := json.Marshal(data)
  19240. // if miConfig.MdtrtareaAdmvs == "320921" {
  19241. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19242. // } else {
  19243. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19244. // }
  19245. // resp, _ := client.Do(req)
  19246. // defer resp.Body.Close()
  19247. // body, ioErr := ioutil.ReadAll(resp.Body)
  19248. // if ioErr != nil {
  19249. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19251. // return
  19252. // }
  19253. // var respJSON map[string]interface{}
  19254. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19255. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19257. // return
  19258. // }
  19259. //
  19260. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19261. // userJSONBytes, _ := json.Marshal(respJSON)
  19262. // fmt.Println("log")
  19263. // fmt.Println(string(userJSONBytes))
  19264. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19265. // utils.ErrorLog("解析失败:%v", err)
  19266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19267. // return
  19268. // }
  19269. // res.InfRefmsgid = resOther.InfRefmsgid
  19270. // res.Output = resOther.Output
  19271. // res.ErrMsg = resOther.ErrMsg
  19272. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19273. // res.Infcode = infocode
  19274. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  19275. //
  19276. // var pp models.PublicParams
  19277. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19278. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19279. // pp.FixmedinsName = miConfig.OrgName
  19280. // pp.FixmedinsCode = miConfig.Code
  19281. // pp.RequestUrl = miConfig.Url
  19282. // pp.Cainfo = miConfig.Cainfo
  19283. // pp.SecretKey = miConfig.SecretKey
  19284. // pp.AccessKey = miConfig.AccessKey
  19285. // pp.OpterName = curRoles.UserName
  19286. // result, _ := service.Jxyb4101(struct4101, pp)
  19287. // var dat map[string]interface{}
  19288. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19289. // fmt.Println(dat)
  19290. // } else {
  19291. // fmt.Println(err)
  19292. // }
  19293. // userJSONBytes, _ := json.Marshal(dat)
  19294. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19295. // utils.ErrorLog("解析失败:%v", err)
  19296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19297. // return
  19298. // }
  19299. //
  19300. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  19301. // var pp models.PublicParams
  19302. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19303. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19304. // pp.FixmedinsName = miConfig.OrgName
  19305. // pp.FixmedinsCode = miConfig.Code
  19306. // pp.RequestUrl = miConfig.Url
  19307. // pp.Cainfo = miConfig.Cainfo
  19308. // pp.SecretKey = miConfig.SecretKey
  19309. // pp.AccessKey = miConfig.AccessKey
  19310. // pp.OpterName = curRoles.UserName
  19311. // result, _ := service.Hnyb4101(struct4101, pp)
  19312. // var dat map[string]interface{}
  19313. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19314. // fmt.Println(dat)
  19315. // } else {
  19316. // fmt.Println(err)
  19317. // }
  19318. // userJSONBytes, _ := json.Marshal(dat)
  19319. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19320. // utils.ErrorLog("解析失败:%v", err)
  19321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19322. // return
  19323. // }
  19324. //
  19325. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  19326. // var resOther ResultSeventeenOther
  19327. //
  19328. // var pp models.PublicParams
  19329. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19330. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19331. // pp.FixmedinsName = miConfig.OrgName
  19332. // pp.FixmedinsCode = miConfig.Code
  19333. // pp.RequestUrl = miConfig.Url
  19334. // pp.Cainfo = miConfig.Cainfo
  19335. // pp.SecretKey = miConfig.SecretKey
  19336. // pp.AccessKey = miConfig.AccessKey
  19337. // pp.OpterName = curRoles.UserName
  19338. // client := &http.Client{}
  19339. // var req *http.Request
  19340. // data := make(map[string]interface{})
  19341. // data["struct4101"] = struct4101
  19342. // data["pp"] = pp
  19343. // bytesData, _ := json.Marshal(data)
  19344. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19345. // resp, _ := client.Do(req)
  19346. // defer resp.Body.Close()
  19347. // body, ioErr := ioutil.ReadAll(resp.Body)
  19348. // if ioErr != nil {
  19349. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19350. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19351. // return
  19352. // }
  19353. // var respJSON map[string]interface{}
  19354. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19355. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19357. // return
  19358. // }
  19359. //
  19360. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19361. // userJSONBytes, _ := json.Marshal(respJSON)
  19362. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19363. // utils.ErrorLog("解析失败:%v", err)
  19364. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19365. // return
  19366. // }
  19367. // res.InfRefmsgid = resOther.InfRefmsgid
  19368. // res.Output = resOther.Output
  19369. // res.ErrMsg = resOther.ErrMsg
  19370. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19371. // res.Infcode = infocode
  19372. //
  19373. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  19374. // var pp models.PublicParams
  19375. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19376. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19377. // pp.FixmedinsName = miConfig.OrgName
  19378. // pp.FixmedinsCode = miConfig.Code
  19379. // pp.RequestUrl = miConfig.Url
  19380. // pp.Cainfo = miConfig.Cainfo
  19381. // pp.SecretKey = miConfig.SecretKey
  19382. // pp.AccessKey = miConfig.AccessKey
  19383. // pp.OpterName = curRoles.UserName
  19384. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19385. // fmt.Println(requestLog)
  19386. // fmt.Println(errMsgLog)
  19387. //
  19388. // saveLog(result, requestLog, "4101a", "上传清单")
  19389. //
  19390. // var dat map[string]interface{}
  19391. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19392. // fmt.Println(dat)
  19393. // } else {
  19394. // fmt.Println(err)
  19395. // }
  19396. // userJSONBytes, _ := json.Marshal(dat)
  19397. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19398. // utils.ErrorLog("解析失败:%v", err)
  19399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19400. // return
  19401. // }
  19402. //
  19403. // } else {
  19404. //
  19405. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  19406. // var dat map[string]interface{}
  19407. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19408. // fmt.Println(dat)
  19409. // } else {
  19410. // fmt.Println(err)
  19411. // }
  19412. // userJSONBytes, _ := json.Marshal(dat)
  19413. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19414. // utils.ErrorLog("解析失败:%v", err)
  19415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19416. // return
  19417. // }
  19418. // }
  19419. //
  19420. // if res.Infcode != 0 {
  19421. // adminUser := c.GetAdminUserInfo()
  19422. // errlog := &models.HisOrderError{
  19423. // UserOrgId: adminUser.CurrentOrgId,
  19424. // Ctime: time.Now().Unix(),
  19425. // Mtime: time.Now().Unix(),
  19426. // ErrMsg: res.ErrMsg,
  19427. // Status: 1,
  19428. // PatientId: order.ID,
  19429. // Stage: 10265,
  19430. // }
  19431. // service.CreateErrMsgLog(errlog)
  19432. // continue
  19433. // } else {
  19434. // //order.FaPiaoNumber = zero
  19435. // //order.FaPiaoCode = last_order.FaPiaoCode
  19436. // //service.UpdateOrder(order)
  19437. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19438. // Number: res.Output.SetlListId,
  19439. // Status: 1,
  19440. // Ctime: time.Now().Unix(),
  19441. // Mtime: time.Now().Unix(),
  19442. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19443. // IsUpload: 1,
  19444. // OrderId: order.ID,
  19445. // }
  19446. // service.CreateUploadRecord(hisFundSettleListResult)
  19447. // c.ServeSuccessJSON(map[string]interface{}{
  19448. // "msg": "上传成功",
  19449. // "result": hisFundSettleListResult,
  19450. // })
  19451. // continue
  19452. // }
  19453. // }
  19454. //}
  19455. func (c *HisApiController) GetbatchSettleList() {
  19456. //order_id, _ := c.GetInt64("order_id")
  19457. admin_user_id, _ := c.GetInt64("admin_user_id")
  19458. orders, _ := service.GetAllHisOrderTwo10485()
  19459. for _, item := range orders {
  19460. order, _ := service.GetHisOrderByIDTwo(item.ID)
  19461. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19462. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19463. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19464. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19465. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19466. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19467. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19468. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19469. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19470. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19471. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19472. //fmt.Println(count)
  19473. //var zero string
  19474. //number := count + 1
  19475. //if number >= 1000 {
  19476. // zero = "0000" + strconv.FormatInt(number, 10)
  19477. //} else if number >= 10000 {
  19478. // zero = "000" + strconv.FormatInt(number, 10)
  19479. //} else if number >= 100000 {
  19480. // zero = "00" + strconv.FormatInt(number, 10)
  19481. //} else if number >= 1000000 {
  19482. // zero = "0" + strconv.FormatInt(number, 10)
  19483. //} else {
  19484. // zero = strconv.FormatInt(number, 10)
  19485. //}
  19486. //fmt.Println(zero)
  19487. struct4101 := service.Struct4101{
  19488. PsnNo: order.PsnNo,
  19489. MdtrtId: order.MdtrtId,
  19490. SetlId: order.SetlId,
  19491. PsnName: order.PsnName,
  19492. Gend: order.Gend,
  19493. Brdy: his.Brdy,
  19494. Age: his.Age,
  19495. Naty: order.Naty,
  19496. PatnCertType: "01",
  19497. Certno: order.Certno,
  19498. Prfs: "90",
  19499. ConerName: roles[0].UserName,
  19500. PatnRlts: "99",
  19501. ConerAddr: miConfig.OrgName,
  19502. ConerTel: admin.Mobile,
  19503. HiType: order.Insutype,
  19504. Insuplc: miConfig.InsuplcAdmdvs,
  19505. MaindiagFlag: "1",
  19506. BillCode: order.SetlId,
  19507. BillNo: order.SetlId,
  19508. BizSn: order.Number,
  19509. PsnSelfPay: order.PsnPartAmt,
  19510. PsnOwnPay: order.PsnPartAmt,
  19511. AcctPay: order.AcctPay,
  19512. PsnCashpay: order.PsnCashPay,
  19513. HiPaymtd: "1",
  19514. Hsorg: miConfig.InsuplcAdmdvs,
  19515. HsorgOpter: miConfig.InsuplcAdmdvs,
  19516. MedinsFillPsn: curRoles.UserName,
  19517. MedinsFillDept: miConfig.OrgName,
  19518. IptMedType: "2",
  19519. }
  19520. struct4101.SetlBegnDate = order.SetlTime
  19521. struct4101.SetlEndDate = order.SetlTime
  19522. time_arr := strings.Split(order.SetlTime, " ")
  19523. struct4101.AdmTime = time_arr[0]
  19524. struct4101.AdmEndTime = time_arr[0]
  19525. //var rf []CustomFundPay
  19526. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19527. //
  19528. //var tempFunPays []service.CustomStruct
  19529. //for _, item := range rf {
  19530. // var tempFunPay service.CustomStruct
  19531. // tempFunPay.FundPayamt = item.FundPayamt
  19532. // tempFunPay.FundPayType = item.FundPayType
  19533. // tempFunPays = append(tempFunPays, tempFunPay)
  19534. //}
  19535. //struct4101.CustomStruct = tempFunPays
  19536. var tempDiaginfos []service.DiaginfoStructTwo
  19537. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19538. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19539. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19540. var config []*models.HisXtDiagnoseConfig
  19541. for _, item := range diagnosis_ids {
  19542. id, _ := strconv.ParseInt(item, 10, 64)
  19543. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19544. config = append(config, &diagnosisConfig)
  19545. }
  19546. for index, item := range config {
  19547. if index == 0 {
  19548. var tempDiaginfo service.DiaginfoStructTwo
  19549. tempDiaginfo.DiagCode = item.CountryCode
  19550. tempDiaginfo.DiagName = item.CountryContentName
  19551. tempDiaginfo.DiagType = "1"
  19552. tempDiaginfo.MaindiagFlag = "1"
  19553. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19554. } else {
  19555. var tempDiaginfo service.DiaginfoStructTwo
  19556. tempDiaginfo.DiagCode = item.CountryCode
  19557. tempDiaginfo.DiagName = item.CountryContentName
  19558. tempDiaginfo.DiagType = "1"
  19559. tempDiaginfo.MaindiagFlag = "0"
  19560. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19561. }
  19562. }
  19563. struct4101.Diseinfo = tempDiaginfos
  19564. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19565. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19566. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19567. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19568. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19569. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19570. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19571. var iteminfo service.IteminfoStruct
  19572. var bedCostTotal float64 = 0 //床位总费
  19573. var bedCostSelfTotal float64 = 0 //床位自费
  19574. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19575. var operationCostTotal float64 = 0 //手术费
  19576. var operationCostSelfTotal float64 = 0 //手术费
  19577. var operationCostPartSelfTotal float64 = 0 //手术费
  19578. var otherCostTotal float64 = 0 //其他费用
  19579. var otherCostSelfTotal float64 = 0 //其他费用
  19580. var otherCostPartSelfTotal float64 = 0 //其他费用
  19581. var materialCostTotal float64 = 0 //材料费
  19582. var materialCostSelfTotal float64 = 0 //材料费
  19583. var materialCostPartSelfTotal float64 = 0 //材料费
  19584. var westernMedicineCostTotal float64 = 0 //西药费
  19585. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19586. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19587. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19588. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19589. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19590. var checkCostTotal float64 = 0 //检查费
  19591. var checkCostSelfTotal float64 = 0 //检查费
  19592. var checkCostPartSelfTotal float64 = 0 //检查费
  19593. var laboratoryCostTotal float64 = 0 //化验费
  19594. var laboratoryCostSelfTotal float64 = 0 //化验费
  19595. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19596. var treatCostTotal float64 = 0 //治疗费用
  19597. var treatCostSelfTotal float64 = 0 //治疗费用
  19598. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19599. decimal.DivisionPrecision = 2
  19600. var bed_fulamt_ownpay_amt float64 = 0
  19601. var operation_fulamt_ownpay_amt float64 = 0
  19602. var other_fulamt_ownpay_amt float64 = 0
  19603. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19604. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19605. var check_fulamt_ownpay_amt float64 = 0
  19606. var material_fulamt_ownpay_amt float64 = 0
  19607. var laboratory_fulamt_ownpay_amt float64 = 0
  19608. var treat_fulamt_ownpay_amt float64 = 0
  19609. var bed_claa_sunmfee float64 = 0
  19610. var bed_clab_amt float64 = 0
  19611. var bed_other_amt float64 = 0
  19612. var operation_claa_sunmfee float64 = 0
  19613. var operation_clab_amt float64 = 0
  19614. var operation_other_amt float64 = 0
  19615. var other_claa_sunmfee float64 = 0
  19616. var other_clab_amt float64 = 0
  19617. var other_other_amt float64 = 0
  19618. var westernMedicine_claa_sunmfee float64 = 0
  19619. var westernMedicine_clab_amt float64 = 0
  19620. var westernMedicine_other_amt float64 = 0
  19621. var chineseTraditional_claa_sunmfee float64 = 0
  19622. var chineseTraditional_clab_amt float64 = 0
  19623. var chineseTraditional_other_amt float64 = 0
  19624. var check_claa_sunmfee float64 = 0
  19625. var check_clab_amt float64 = 0
  19626. var check_other_amt float64 = 0
  19627. var material_claa_sunmfee float64 = 0
  19628. var material_clab_amt float64 = 0
  19629. var material_other_amt float64 = 0
  19630. var laboratory_claa_sunmfee float64 = 0
  19631. var laboratory_clab_amt float64 = 0
  19632. var laboratory_other_amt float64 = 0
  19633. var treat_claa_sunmfee float64 = 0
  19634. var treat_clab_amt float64 = 0
  19635. var treat_other_amt float64 = 0
  19636. for _, item := range order.HisOrderInfo {
  19637. if item.MedChrgitmType == "01" { //床位费
  19638. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19639. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19640. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19641. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19642. if item.ChrgitmLv == "1" {
  19643. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19644. }
  19645. if item.ChrgitmLv == "2" {
  19646. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19647. }
  19648. if item.ChrgitmLv == "3" {
  19649. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19650. }
  19651. }
  19652. if item.MedChrgitmType == "03" { //检查费
  19653. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19654. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19655. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19656. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19657. if item.ChrgitmLv == "1" {
  19658. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19659. }
  19660. if item.ChrgitmLv == "2" {
  19661. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19662. }
  19663. if item.ChrgitmLv == "3" {
  19664. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19665. }
  19666. }
  19667. if item.MedChrgitmType == "04" { //化验费
  19668. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19669. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19670. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19671. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19672. if item.ChrgitmLv == "1" {
  19673. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19674. }
  19675. if item.ChrgitmLv == "2" {
  19676. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19677. }
  19678. if item.ChrgitmLv == "3" {
  19679. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19680. }
  19681. }
  19682. if item.MedChrgitmType == "05" { //治疗费
  19683. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19684. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19685. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19686. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19687. if item.ChrgitmLv == "1" {
  19688. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19689. }
  19690. if item.ChrgitmLv == "2" {
  19691. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19692. }
  19693. if item.ChrgitmLv == "3" {
  19694. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19695. }
  19696. }
  19697. if item.MedChrgitmType == "06" { //手术费
  19698. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19699. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19700. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19701. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19702. if item.ChrgitmLv == "1" {
  19703. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19704. }
  19705. if item.ChrgitmLv == "2" {
  19706. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19707. }
  19708. if item.ChrgitmLv == "3" {
  19709. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19710. }
  19711. }
  19712. if item.MedChrgitmType == "08" { //材料费
  19713. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19714. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19715. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19716. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19717. if item.ChrgitmLv == "1" {
  19718. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19719. }
  19720. if item.ChrgitmLv == "2" {
  19721. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19722. }
  19723. if item.ChrgitmLv == "3" {
  19724. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19725. }
  19726. }
  19727. if item.MedChrgitmType == "09" { //西药费
  19728. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19729. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19730. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19731. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19732. if item.ChrgitmLv == "1" {
  19733. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19734. }
  19735. if item.ChrgitmLv == "2" {
  19736. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19737. }
  19738. if item.ChrgitmLv == "3" {
  19739. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19740. }
  19741. }
  19742. if item.MedChrgitmType == "11" { //中成费
  19743. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19744. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19745. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19746. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19747. if item.ChrgitmLv == "1" {
  19748. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19749. }
  19750. if item.ChrgitmLv == "2" {
  19751. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19752. }
  19753. if item.ChrgitmLv == "3" {
  19754. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19755. }
  19756. }
  19757. if item.MedChrgitmType == "14" { //其他费
  19758. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19759. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19760. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19761. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19762. if item.ChrgitmLv == "1" {
  19763. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19764. }
  19765. if item.ChrgitmLv == "2" {
  19766. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19767. }
  19768. if item.ChrgitmLv == "3" {
  19769. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19770. }
  19771. }
  19772. }
  19773. var iteminfoStructs []service.IteminfoStruct
  19774. if bedCostTotal != 0 {
  19775. iteminfo.MedChrgitm = "01"
  19776. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19777. iteminfo.Amt = bedCostTotal
  19778. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19779. iteminfo.ClabAmt = bed_clab_amt
  19780. iteminfo.OthAmt = bed_other_amt
  19781. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19782. }
  19783. if checkCostTotal != 0 {
  19784. iteminfo.MedChrgitm = "03"
  19785. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19786. iteminfo.Amt = checkCostTotal
  19787. iteminfo.ClaaSumfee = check_claa_sunmfee
  19788. iteminfo.ClabAmt = check_clab_amt
  19789. iteminfo.OthAmt = check_other_amt
  19790. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19791. }
  19792. if laboratoryCostTotal != 0 {
  19793. iteminfo.MedChrgitm = "04"
  19794. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19795. iteminfo.Amt = laboratoryCostTotal
  19796. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19797. iteminfo.ClabAmt = laboratory_clab_amt
  19798. iteminfo.OthAmt = laboratory_other_amt
  19799. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19800. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19801. }
  19802. if treatCostTotal != 0 {
  19803. iteminfo.MedChrgitm = "05"
  19804. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19805. iteminfo.Amt = treatCostTotal
  19806. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19807. iteminfo.ClabAmt = treat_clab_amt
  19808. iteminfo.OthAmt = treat_other_amt
  19809. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19810. //(struct4101.IteminfoStruct, iteminfo)
  19811. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19812. }
  19813. if operationCostTotal != 0 {
  19814. iteminfo.MedChrgitm = "06"
  19815. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19816. iteminfo.Amt = operationCostTotal
  19817. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19818. iteminfo.ClabAmt = operation_clab_amt
  19819. iteminfo.OthAmt = operation_other_amt
  19820. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19821. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19822. }
  19823. if materialCostTotal != 0 {
  19824. iteminfo.MedChrgitm = "08"
  19825. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19826. iteminfo.Amt = materialCostTotal
  19827. iteminfo.ClaaSumfee = material_claa_sunmfee
  19828. iteminfo.ClabAmt = material_clab_amt
  19829. iteminfo.OthAmt = material_other_amt
  19830. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19831. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19832. }
  19833. if westernMedicineCostTotal != 0 {
  19834. iteminfo.MedChrgitm = "09"
  19835. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19836. iteminfo.Amt = westernMedicineCostTotal
  19837. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19838. iteminfo.ClabAmt = westernMedicine_clab_amt
  19839. iteminfo.OthAmt = westernMedicine_other_amt
  19840. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19841. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19842. }
  19843. if chineseTraditionalMedicineCostTotal != 0 {
  19844. iteminfo.MedChrgitm = "11"
  19845. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19846. iteminfo.Amt = westernMedicineCostTotal
  19847. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19848. iteminfo.ClabAmt = westernMedicine_clab_amt
  19849. iteminfo.OthAmt = westernMedicine_other_amt
  19850. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19851. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19852. }
  19853. if otherCostTotal != 0 {
  19854. iteminfo.MedChrgitm = "14"
  19855. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19856. iteminfo.Amt = otherCostTotal
  19857. iteminfo.ClaaSumfee = other_claa_sunmfee
  19858. iteminfo.ClabAmt = other_clab_amt
  19859. iteminfo.OthAmt = other_other_amt
  19860. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19861. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19862. }
  19863. struct4101.IteminfoStruct = iteminfoStructs
  19864. struct4101.Ntly = "中国"
  19865. struct4101.AdmCaty = "A03.06"
  19866. struct4101.DoctorName = doctor.UserName
  19867. struct4101.DoctorCode = doctor.DoctorNumber
  19868. var res ResultSeventeen
  19869. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  19870. struct4101.BillCode = order.Number
  19871. struct4101.BillNo = order.SetlId
  19872. var resOther ResultSeventeenOther
  19873. var pp models.PublicParams
  19874. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19875. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19876. pp.FixmedinsName = miConfig.OrgName
  19877. pp.FixmedinsCode = miConfig.Code
  19878. pp.RequestUrl = miConfig.Url
  19879. pp.Cainfo = miConfig.Cainfo
  19880. pp.SecretKey = miConfig.SecretKey
  19881. pp.AccessKey = miConfig.AccessKey
  19882. pp.OpterName = curRoles.UserName
  19883. client := &http.Client{}
  19884. var req *http.Request
  19885. data := make(map[string]interface{})
  19886. data["struct4101"] = struct4101
  19887. data["pp"] = pp
  19888. bytesData, _ := json.Marshal(data)
  19889. if miConfig.MdtrtareaAdmvs == "320830" {
  19890. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  19891. } else if miConfig.MdtrtareaAdmvs == "320921" {
  19892. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19893. } else {
  19894. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19895. }
  19896. resp, _ := client.Do(req)
  19897. defer resp.Body.Close()
  19898. body, ioErr := ioutil.ReadAll(resp.Body)
  19899. if ioErr != nil {
  19900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19902. return
  19903. }
  19904. var respJSON map[string]interface{}
  19905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19908. return
  19909. }
  19910. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19911. userJSONBytes, _ := json.Marshal(respJSON)
  19912. fmt.Println("log")
  19913. fmt.Println(string(userJSONBytes))
  19914. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19915. utils.ErrorLog("解析失败:%v", err)
  19916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19917. return
  19918. }
  19919. res.InfRefmsgid = resOther.InfRefmsgid
  19920. res.Output = resOther.Output
  19921. res.ErrMsg = resOther.ErrMsg
  19922. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19923. res.Infcode = infocode
  19924. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19925. var pp models.PublicParams
  19926. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19927. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19928. pp.FixmedinsName = miConfig.OrgName
  19929. pp.FixmedinsCode = miConfig.Code
  19930. pp.RequestUrl = miConfig.Url
  19931. pp.Cainfo = miConfig.Cainfo
  19932. pp.SecretKey = miConfig.SecretKey
  19933. pp.AccessKey = miConfig.AccessKey
  19934. pp.OpterName = curRoles.UserName
  19935. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19936. result, _ := service.Jxyb4101(struct4101, pp)
  19937. var dat map[string]interface{}
  19938. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19939. fmt.Println(dat)
  19940. } else {
  19941. fmt.Println(err)
  19942. }
  19943. userJSONBytes, _ := json.Marshal(dat)
  19944. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19945. utils.ErrorLog("解析失败:%v", err)
  19946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19947. return
  19948. }
  19949. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19950. var pp models.PublicParams
  19951. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19952. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19953. pp.FixmedinsName = miConfig.OrgName
  19954. pp.FixmedinsCode = miConfig.Code
  19955. pp.RequestUrl = miConfig.Url
  19956. pp.Cainfo = miConfig.Cainfo
  19957. pp.SecretKey = miConfig.SecretKey
  19958. pp.AccessKey = miConfig.AccessKey
  19959. pp.OpterName = curRoles.UserName
  19960. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19961. result, _ := service.Jxyb4101(struct4101, pp)
  19962. var dat map[string]interface{}
  19963. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19964. fmt.Println(dat)
  19965. } else {
  19966. fmt.Println(err)
  19967. }
  19968. userJSONBytes, _ := json.Marshal(dat)
  19969. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19970. utils.ErrorLog("解析失败:%v", err)
  19971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19972. return
  19973. }
  19974. } else if miConfig.MdtrtareaAdmvs == "360100" {
  19975. var pp models.PublicParams
  19976. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19977. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19978. pp.FixmedinsName = miConfig.OrgName
  19979. pp.FixmedinsCode = miConfig.Code
  19980. pp.RequestUrl = miConfig.Url
  19981. pp.Cainfo = miConfig.Cainfo
  19982. pp.SecretKey = miConfig.SecretKey
  19983. pp.AccessKey = miConfig.AccessKey
  19984. pp.OpterName = curRoles.UserName
  19985. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19986. result, _ := service.Jxyb4101(struct4101, pp)
  19987. var dat map[string]interface{}
  19988. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19989. fmt.Println(dat)
  19990. } else {
  19991. fmt.Println(err)
  19992. }
  19993. userJSONBytes, _ := json.Marshal(dat)
  19994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19995. utils.ErrorLog("解析失败:%v", err)
  19996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19997. return
  19998. }
  19999. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20000. var pp models.PublicParams
  20001. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20002. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20003. pp.FixmedinsName = miConfig.OrgName
  20004. pp.FixmedinsCode = miConfig.Code
  20005. pp.RequestUrl = miConfig.Url
  20006. pp.Cainfo = miConfig.Cainfo
  20007. pp.SecretKey = miConfig.SecretKey
  20008. pp.AccessKey = miConfig.AccessKey
  20009. pp.OpterName = curRoles.UserName
  20010. result, _ := service.Hnyb4101(struct4101, pp)
  20011. var dat map[string]interface{}
  20012. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20013. fmt.Println(dat)
  20014. } else {
  20015. fmt.Println(err)
  20016. }
  20017. userJSONBytes, _ := json.Marshal(dat)
  20018. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20019. utils.ErrorLog("解析失败:%v", err)
  20020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20021. return
  20022. }
  20023. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20024. var resOther ResultSeventeenOther
  20025. var pp models.PublicParams
  20026. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20027. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20028. pp.FixmedinsName = miConfig.OrgName
  20029. pp.FixmedinsCode = miConfig.Code
  20030. pp.RequestUrl = miConfig.Url
  20031. pp.Cainfo = miConfig.Cainfo
  20032. pp.SecretKey = miConfig.SecretKey
  20033. pp.AccessKey = miConfig.AccessKey
  20034. pp.OpterName = curRoles.UserName
  20035. client := &http.Client{}
  20036. var req *http.Request
  20037. data := make(map[string]interface{})
  20038. data["struct4101"] = struct4101
  20039. data["pp"] = pp
  20040. bytesData, _ := json.Marshal(data)
  20041. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20042. resp, _ := client.Do(req)
  20043. defer resp.Body.Close()
  20044. body, ioErr := ioutil.ReadAll(resp.Body)
  20045. if ioErr != nil {
  20046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20048. return
  20049. }
  20050. var respJSON map[string]interface{}
  20051. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20054. return
  20055. }
  20056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20057. userJSONBytes, _ := json.Marshal(respJSON)
  20058. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20059. utils.ErrorLog("解析失败:%v", err)
  20060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20061. return
  20062. }
  20063. res.InfRefmsgid = resOther.InfRefmsgid
  20064. res.Output = resOther.Output
  20065. res.ErrMsg = resOther.ErrMsg
  20066. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20067. res.Infcode = infocode
  20068. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20069. var pp models.PublicParams
  20070. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20071. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20072. pp.FixmedinsName = miConfig.OrgName
  20073. pp.FixmedinsCode = miConfig.Code
  20074. pp.RequestUrl = miConfig.Url
  20075. pp.Cainfo = miConfig.Cainfo
  20076. pp.SecretKey = miConfig.SecretKey
  20077. pp.AccessKey = miConfig.AccessKey
  20078. pp.OpterName = curRoles.UserName
  20079. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20080. fmt.Println(requestLog)
  20081. fmt.Println(errMsgLog)
  20082. saveLog(result, requestLog, "4101a", "上传清单")
  20083. var dat map[string]interface{}
  20084. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20085. fmt.Println(dat)
  20086. } else {
  20087. fmt.Println(err)
  20088. }
  20089. userJSONBytes, _ := json.Marshal(dat)
  20090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20091. utils.ErrorLog("解析失败:%v", err)
  20092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20093. return
  20094. }
  20095. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20096. var pp models.PublicParams
  20097. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20098. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20099. pp.FixmedinsName = miConfig.OrgName
  20100. pp.FixmedinsCode = miConfig.Code
  20101. pp.RequestUrl = miConfig.Url
  20102. pp.Cainfo = miConfig.Cainfo
  20103. pp.SecretKey = miConfig.SecretKey
  20104. pp.AccessKey = miConfig.AccessKey
  20105. pp.OpterName = curRoles.UserName
  20106. client := &http.Client{}
  20107. var req *http.Request
  20108. data := make(map[string]interface{})
  20109. data["struct4101"] = struct4101
  20110. data["pp"] = pp
  20111. bytesData, _ := json.Marshal(data)
  20112. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20113. resp, _ := client.Do(req)
  20114. defer resp.Body.Close()
  20115. body, ioErr := ioutil.ReadAll(resp.Body)
  20116. if ioErr != nil {
  20117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20119. return
  20120. }
  20121. var respJSON map[string]interface{}
  20122. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20125. return
  20126. }
  20127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20128. userJSONBytes, _ := json.Marshal(respJSON)
  20129. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20130. utils.ErrorLog("解析失败:%v", err)
  20131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20132. return
  20133. }
  20134. } else {
  20135. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20136. var dat map[string]interface{}
  20137. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20138. fmt.Println(dat)
  20139. } else {
  20140. fmt.Println(err)
  20141. }
  20142. userJSONBytes, _ := json.Marshal(dat)
  20143. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20144. utils.ErrorLog("解析失败:%v", err)
  20145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20146. return
  20147. }
  20148. }
  20149. if res.Infcode != 0 {
  20150. errlog := &models.HisOrderError{
  20151. UserOrgId: order.UserOrgId,
  20152. Ctime: time.Now().Unix(),
  20153. Mtime: time.Now().Unix(),
  20154. ErrMsg: res.ErrMsg + "解析失败",
  20155. Status: 1,
  20156. PatientId: order.ID,
  20157. Stage: 10485,
  20158. }
  20159. service.CreateErrMsgLog(errlog)
  20160. continue
  20161. //c.ServeSuccessJSON(map[string]interface{}{
  20162. // "failed_code": -10,
  20163. // "msg": res.ErrMsg,
  20164. //})
  20165. } else {
  20166. //order.FaPiaoNumber = zero
  20167. //order.FaPiaoCode = last_order.FaPiaoCode
  20168. //service.UpdateOrder(order)
  20169. hisFundSettleListResult := &models.HisFundSettleListResult{
  20170. Number: res.Output.SetlListId,
  20171. Status: 1,
  20172. Ctime: time.Now().Unix(),
  20173. Mtime: time.Now().Unix(),
  20174. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20175. IsUpload: 1,
  20176. OrderId: order.ID,
  20177. }
  20178. service.CreateUploadRecord(hisFundSettleListResult)
  20179. continue
  20180. }
  20181. }
  20182. }
  20183. func (c *HisApiController) GetSettleList() {
  20184. order_id, _ := c.GetInt64("order_id")
  20185. admin_user_id, _ := c.GetInt64("admin_user_id")
  20186. order, _ := service.GetHisOrderByIDTwo(order_id)
  20187. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20188. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20189. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20190. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20191. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20192. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20193. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20194. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20195. if order.ID == 0 {
  20196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20197. return
  20198. }
  20199. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20200. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20201. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20202. //fmt.Println(count)
  20203. //var zero string
  20204. //number := count + 1
  20205. //if number >= 1000 {
  20206. // zero = "0000" + strconv.FormatInt(number, 10)
  20207. //} else if number >= 10000 {
  20208. // zero = "000" + strconv.FormatInt(number, 10)
  20209. //} else if number >= 100000 {
  20210. // zero = "00" + strconv.FormatInt(number, 10)
  20211. //} else if number >= 1000000 {
  20212. // zero = "0" + strconv.FormatInt(number, 10)
  20213. //} else {
  20214. // zero = strconv.FormatInt(number, 10)
  20215. //}
  20216. //fmt.Println(zero)
  20217. struct4101 := service.Struct4101{
  20218. PsnNo: order.PsnNo,
  20219. MdtrtId: order.MdtrtId,
  20220. SetlId: order.SetlId,
  20221. PsnName: order.PsnName,
  20222. Gend: order.Gend,
  20223. Brdy: his.Brdy,
  20224. Age: his.Age,
  20225. Naty: order.Naty,
  20226. PatnCertType: "01",
  20227. Certno: order.Certno,
  20228. Prfs: "90",
  20229. ConerName: roles[0].UserName,
  20230. PatnRlts: "99",
  20231. ConerAddr: miConfig.OrgName,
  20232. ConerTel: admin.Mobile,
  20233. HiType: order.Insutype,
  20234. Insuplc: miConfig.InsuplcAdmdvs,
  20235. MaindiagFlag: "1",
  20236. BillCode: order.SetlId,
  20237. BillNo: order.SetlId,
  20238. BizSn: order.Number,
  20239. PsnSelfPay: order.PsnPartAmt,
  20240. PsnOwnPay: order.PsnPartAmt,
  20241. AcctPay: order.AcctPay,
  20242. PsnCashpay: order.PsnCashPay,
  20243. HiPaymtd: "1",
  20244. Hsorg: miConfig.InsuplcAdmdvs,
  20245. HsorgOpter: miConfig.InsuplcAdmdvs,
  20246. MedinsFillPsn: curRoles.UserName,
  20247. MedinsFillDept: miConfig.OrgName,
  20248. IptMedType: "2",
  20249. }
  20250. struct4101.SetlBegnDate = order.SetlTime
  20251. struct4101.SetlEndDate = order.SetlTime
  20252. time_arr := strings.Split(order.SetlTime, " ")
  20253. struct4101.AdmTime = time_arr[0]
  20254. struct4101.AdmEndTime = time_arr[0]
  20255. //
  20256. //var rf []CustomFundPay
  20257. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20258. //
  20259. //var tempFunPays []service.CustomStruct
  20260. //for _, item := range rf {
  20261. // var tempFunPay service.CustomStruct
  20262. // tempFunPay.FundPayamt = item.FundPayamt
  20263. // tempFunPay.FundPayType = item.FundPayType
  20264. // tempFunPays = append(tempFunPays, tempFunPay)
  20265. //}
  20266. //struct4101.CustomStruct = tempFunPays
  20267. var tempDiaginfos []service.DiaginfoStructTwo
  20268. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20269. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20270. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  20271. var config []*models.HisXtDiagnoseConfig
  20272. for _, item := range diagnosis_ids {
  20273. id, _ := strconv.ParseInt(item, 10, 64)
  20274. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20275. config = append(config, &diagnosisConfig)
  20276. }
  20277. if miConfig.Code == "H15049901371" {
  20278. //for _, item := range config {
  20279. // if item.ID == 138 {
  20280. diagnosisConfig, _ := service.FindDiagnoseById(138)
  20281. var tempDiaginfo service.DiaginfoStructTwo
  20282. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  20283. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  20284. tempDiaginfo.DiagType = "1"
  20285. tempDiaginfo.MaindiagFlag = "1"
  20286. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20287. //}
  20288. //}
  20289. for _, item := range config {
  20290. if item.ID != 138 {
  20291. var tempDiaginfo service.DiaginfoStructTwo
  20292. tempDiaginfo.DiagCode = item.CountryCode
  20293. tempDiaginfo.DiagName = item.CountryContentName
  20294. tempDiaginfo.DiagType = "1"
  20295. tempDiaginfo.MaindiagFlag = "0"
  20296. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20297. }
  20298. }
  20299. } else {
  20300. for index, item := range config {
  20301. if index == 0 {
  20302. var tempDiaginfo service.DiaginfoStructTwo
  20303. tempDiaginfo.DiagCode = item.CountryCode
  20304. tempDiaginfo.DiagName = item.CountryContentName
  20305. tempDiaginfo.DiagType = "1"
  20306. tempDiaginfo.MaindiagFlag = "1"
  20307. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20308. } else {
  20309. var tempDiaginfo service.DiaginfoStructTwo
  20310. tempDiaginfo.DiagCode = item.CountryCode
  20311. tempDiaginfo.DiagName = item.CountryContentName
  20312. tempDiaginfo.DiagType = "1"
  20313. tempDiaginfo.MaindiagFlag = "0"
  20314. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20315. }
  20316. }
  20317. }
  20318. struct4101.Diseinfo = tempDiaginfos
  20319. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20320. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20321. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20322. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  20323. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  20324. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20325. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20326. var iteminfo service.IteminfoStruct
  20327. var bedCostTotal float64 = 0 //床位总费
  20328. var bedCostSelfTotal float64 = 0 //床位自费
  20329. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20330. var operationCostTotal float64 = 0 //手术费
  20331. var operationCostSelfTotal float64 = 0 //手术费
  20332. var operationCostPartSelfTotal float64 = 0 //手术费
  20333. var otherCostTotal float64 = 0 //其他费用
  20334. var otherCostSelfTotal float64 = 0 //其他费用
  20335. var otherCostPartSelfTotal float64 = 0 //其他费用
  20336. var materialCostTotal float64 = 0 //材料费
  20337. var materialCostSelfTotal float64 = 0 //材料费
  20338. var materialCostPartSelfTotal float64 = 0 //材料费
  20339. var westernMedicineCostTotal float64 = 0 //西药费
  20340. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20341. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20342. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20343. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20344. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20345. var checkCostTotal float64 = 0 //检查费
  20346. var checkCostSelfTotal float64 = 0 //检查费
  20347. var checkCostPartSelfTotal float64 = 0 //检查费
  20348. var laboratoryCostTotal float64 = 0 //化验费
  20349. var laboratoryCostSelfTotal float64 = 0 //化验费
  20350. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20351. var treatCostTotal float64 = 0 //治疗费用
  20352. var treatCostSelfTotal float64 = 0 //治疗费用
  20353. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20354. decimal.DivisionPrecision = 2
  20355. var bed_fulamt_ownpay_amt float64 = 0
  20356. var operation_fulamt_ownpay_amt float64 = 0
  20357. var other_fulamt_ownpay_amt float64 = 0
  20358. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20359. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20360. var check_fulamt_ownpay_amt float64 = 0
  20361. var material_fulamt_ownpay_amt float64 = 0
  20362. var laboratory_fulamt_ownpay_amt float64 = 0
  20363. var treat_fulamt_ownpay_amt float64 = 0
  20364. var bed_claa_sunmfee float64 = 0
  20365. var bed_clab_amt float64 = 0
  20366. var bed_other_amt float64 = 0
  20367. var operation_claa_sunmfee float64 = 0
  20368. var operation_clab_amt float64 = 0
  20369. var operation_other_amt float64 = 0
  20370. var other_claa_sunmfee float64 = 0
  20371. var other_clab_amt float64 = 0
  20372. var other_other_amt float64 = 0
  20373. var westernMedicine_claa_sunmfee float64 = 0
  20374. var westernMedicine_clab_amt float64 = 0
  20375. var westernMedicine_other_amt float64 = 0
  20376. var chineseTraditional_claa_sunmfee float64 = 0
  20377. var chineseTraditional_clab_amt float64 = 0
  20378. var chineseTraditional_other_amt float64 = 0
  20379. var check_claa_sunmfee float64 = 0
  20380. var check_clab_amt float64 = 0
  20381. var check_other_amt float64 = 0
  20382. var material_claa_sunmfee float64 = 0
  20383. var material_clab_amt float64 = 0
  20384. var material_other_amt float64 = 0
  20385. var laboratory_claa_sunmfee float64 = 0
  20386. var laboratory_clab_amt float64 = 0
  20387. var laboratory_other_amt float64 = 0
  20388. var treat_claa_sunmfee float64 = 0
  20389. var treat_clab_amt float64 = 0
  20390. var treat_other_amt float64 = 0
  20391. for _, item := range order.HisOrderInfo {
  20392. if item.MedChrgitmType == "01" { //床位费
  20393. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20394. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20395. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20396. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20397. if item.ChrgitmLv == "1" {
  20398. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20399. }
  20400. if item.ChrgitmLv == "2" {
  20401. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20402. }
  20403. if item.ChrgitmLv == "3" {
  20404. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20405. }
  20406. }
  20407. if item.MedChrgitmType == "03" { //检查费
  20408. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20409. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20410. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20411. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20412. if item.ChrgitmLv == "1" {
  20413. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20414. }
  20415. if item.ChrgitmLv == "2" {
  20416. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20417. }
  20418. if item.ChrgitmLv == "3" {
  20419. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20420. }
  20421. }
  20422. if item.MedChrgitmType == "04" { //化验费
  20423. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20424. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20425. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20426. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20427. if item.ChrgitmLv == "1" {
  20428. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20429. }
  20430. if item.ChrgitmLv == "2" {
  20431. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20432. }
  20433. if item.ChrgitmLv == "3" {
  20434. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20435. }
  20436. }
  20437. if item.MedChrgitmType == "05" { //治疗费
  20438. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20439. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20440. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20441. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20442. if item.ChrgitmLv == "1" {
  20443. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20444. }
  20445. if item.ChrgitmLv == "2" {
  20446. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20447. }
  20448. if item.ChrgitmLv == "3" {
  20449. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20450. }
  20451. }
  20452. if item.MedChrgitmType == "06" { //手术费
  20453. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20454. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20455. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20456. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20457. if item.ChrgitmLv == "1" {
  20458. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20459. }
  20460. if item.ChrgitmLv == "2" {
  20461. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20462. }
  20463. if item.ChrgitmLv == "3" {
  20464. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20465. }
  20466. }
  20467. if item.MedChrgitmType == "08" { //材料费
  20468. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20469. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20470. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20471. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20472. if item.ChrgitmLv == "1" {
  20473. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20474. }
  20475. if item.ChrgitmLv == "2" {
  20476. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20477. }
  20478. if item.ChrgitmLv == "3" {
  20479. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20480. }
  20481. }
  20482. if item.MedChrgitmType == "09" { //西药费
  20483. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20484. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20485. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20486. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20487. if item.ChrgitmLv == "1" {
  20488. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20489. }
  20490. if item.ChrgitmLv == "2" {
  20491. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20492. }
  20493. if item.ChrgitmLv == "3" {
  20494. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20495. }
  20496. }
  20497. if item.MedChrgitmType == "11" { //中成费
  20498. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20499. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20500. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20501. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20502. if item.ChrgitmLv == "1" {
  20503. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20504. }
  20505. if item.ChrgitmLv == "2" {
  20506. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20507. }
  20508. if item.ChrgitmLv == "3" {
  20509. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20510. }
  20511. }
  20512. if item.MedChrgitmType == "14" { //其他费
  20513. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20514. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20515. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20516. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20517. if item.ChrgitmLv == "1" {
  20518. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20519. }
  20520. if item.ChrgitmLv == "2" {
  20521. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20522. }
  20523. if item.ChrgitmLv == "3" {
  20524. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20525. }
  20526. }
  20527. }
  20528. var iteminfoStructs []service.IteminfoStruct
  20529. if bedCostTotal != 0 {
  20530. iteminfo.MedChrgitm = "01"
  20531. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20532. iteminfo.Amt = bedCostTotal
  20533. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20534. iteminfo.ClabAmt = bed_clab_amt
  20535. iteminfo.OthAmt = bed_other_amt
  20536. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20537. }
  20538. if checkCostTotal != 0 {
  20539. iteminfo.MedChrgitm = "03"
  20540. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20541. iteminfo.Amt = checkCostTotal
  20542. iteminfo.ClaaSumfee = check_claa_sunmfee
  20543. iteminfo.ClabAmt = check_clab_amt
  20544. iteminfo.OthAmt = check_other_amt
  20545. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20546. }
  20547. if laboratoryCostTotal != 0 {
  20548. iteminfo.MedChrgitm = "04"
  20549. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20550. iteminfo.Amt = laboratoryCostTotal
  20551. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20552. iteminfo.ClabAmt = laboratory_clab_amt
  20553. iteminfo.OthAmt = laboratory_other_amt
  20554. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20555. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20556. }
  20557. if treatCostTotal != 0 {
  20558. iteminfo.MedChrgitm = "05"
  20559. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20560. iteminfo.Amt = treatCostTotal
  20561. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20562. iteminfo.ClabAmt = treat_clab_amt
  20563. iteminfo.OthAmt = treat_other_amt
  20564. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20565. //(struct4101.IteminfoStruct, iteminfo)
  20566. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20567. }
  20568. if operationCostTotal != 0 {
  20569. iteminfo.MedChrgitm = "06"
  20570. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20571. iteminfo.Amt = operationCostTotal
  20572. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20573. iteminfo.ClabAmt = operation_clab_amt
  20574. iteminfo.OthAmt = operation_other_amt
  20575. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20576. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20577. }
  20578. if materialCostTotal != 0 {
  20579. iteminfo.MedChrgitm = "08"
  20580. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20581. iteminfo.Amt = materialCostTotal
  20582. iteminfo.ClaaSumfee = material_claa_sunmfee
  20583. iteminfo.ClabAmt = material_clab_amt
  20584. iteminfo.OthAmt = material_other_amt
  20585. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20586. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20587. }
  20588. if westernMedicineCostTotal != 0 {
  20589. iteminfo.MedChrgitm = "09"
  20590. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20591. iteminfo.Amt = westernMedicineCostTotal
  20592. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20593. iteminfo.ClabAmt = westernMedicine_clab_amt
  20594. iteminfo.OthAmt = westernMedicine_other_amt
  20595. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20596. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20597. }
  20598. if chineseTraditionalMedicineCostTotal != 0 {
  20599. iteminfo.MedChrgitm = "11"
  20600. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20601. iteminfo.Amt = westernMedicineCostTotal
  20602. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20603. iteminfo.ClabAmt = westernMedicine_clab_amt
  20604. iteminfo.OthAmt = westernMedicine_other_amt
  20605. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20606. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20607. }
  20608. if otherCostTotal != 0 {
  20609. iteminfo.MedChrgitm = "14"
  20610. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20611. iteminfo.Amt = otherCostTotal
  20612. iteminfo.ClaaSumfee = other_claa_sunmfee
  20613. iteminfo.ClabAmt = other_clab_amt
  20614. iteminfo.OthAmt = other_other_amt
  20615. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20616. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20617. }
  20618. struct4101.IteminfoStruct = iteminfoStructs
  20619. struct4101.Ntly = "中国"
  20620. struct4101.AdmCaty = "A03.06"
  20621. struct4101.DoctorName = doctor.UserName
  20622. struct4101.DoctorCode = doctor.DoctorNumber
  20623. var res ResultSeventeen
  20624. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20625. struct4101.BillCode = order.Number
  20626. struct4101.BillNo = order.SetlId
  20627. var resOther ResultSeventeenOther
  20628. var pp models.PublicParams
  20629. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20630. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20631. pp.FixmedinsName = miConfig.OrgName
  20632. pp.FixmedinsCode = miConfig.Code
  20633. pp.RequestUrl = miConfig.Url
  20634. pp.Cainfo = miConfig.Cainfo
  20635. pp.SecretKey = miConfig.SecretKey
  20636. pp.AccessKey = miConfig.AccessKey
  20637. pp.OpterName = curRoles.UserName
  20638. client := &http.Client{}
  20639. var req *http.Request
  20640. data := make(map[string]interface{})
  20641. data["struct4101"] = struct4101
  20642. data["pp"] = pp
  20643. bytesData, _ := json.Marshal(data)
  20644. if miConfig.MdtrtareaAdmvs == "320830" {
  20645. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20646. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20647. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20648. } else {
  20649. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20650. }
  20651. resp, _ := client.Do(req)
  20652. defer resp.Body.Close()
  20653. body, ioErr := ioutil.ReadAll(resp.Body)
  20654. if ioErr != nil {
  20655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20657. return
  20658. }
  20659. var respJSON map[string]interface{}
  20660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20663. return
  20664. }
  20665. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20666. userJSONBytes, _ := json.Marshal(respJSON)
  20667. fmt.Println("log")
  20668. fmt.Println(string(userJSONBytes))
  20669. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20670. utils.ErrorLog("解析失败:%v", err)
  20671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20672. return
  20673. }
  20674. res.InfRefmsgid = resOther.InfRefmsgid
  20675. res.Output = resOther.Output
  20676. res.ErrMsg = resOther.ErrMsg
  20677. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20678. res.Infcode = infocode
  20679. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20680. var pp models.PublicParams
  20681. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20682. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20683. pp.FixmedinsName = miConfig.OrgName
  20684. pp.FixmedinsCode = miConfig.Code
  20685. pp.RequestUrl = miConfig.Url
  20686. pp.Cainfo = miConfig.Cainfo
  20687. pp.SecretKey = miConfig.SecretKey
  20688. pp.AccessKey = miConfig.AccessKey
  20689. pp.OpterName = curRoles.UserName
  20690. result, _ := service.Jxyb4101(struct4101, pp)
  20691. var dat map[string]interface{}
  20692. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20693. fmt.Println(dat)
  20694. } else {
  20695. fmt.Println(err)
  20696. }
  20697. userJSONBytes, _ := json.Marshal(dat)
  20698. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20699. utils.ErrorLog("解析失败:%v", err)
  20700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20701. return
  20702. }
  20703. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20704. var pp models.PublicParams
  20705. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20706. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20707. pp.FixmedinsName = miConfig.OrgName
  20708. pp.FixmedinsCode = miConfig.Code
  20709. pp.RequestUrl = miConfig.Url
  20710. pp.Cainfo = miConfig.Cainfo
  20711. pp.SecretKey = miConfig.SecretKey
  20712. pp.AccessKey = miConfig.AccessKey
  20713. pp.OpterName = curRoles.UserName
  20714. result, _ := service.Jxyb4101(struct4101, pp)
  20715. var dat map[string]interface{}
  20716. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20717. fmt.Println(dat)
  20718. } else {
  20719. fmt.Println(err)
  20720. }
  20721. userJSONBytes, _ := json.Marshal(dat)
  20722. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20723. utils.ErrorLog("解析失败:%v", err)
  20724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20725. return
  20726. }
  20727. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20728. var pp models.PublicParams
  20729. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20730. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20731. pp.FixmedinsName = miConfig.OrgName
  20732. pp.FixmedinsCode = miConfig.Code
  20733. pp.RequestUrl = miConfig.Url
  20734. pp.Cainfo = miConfig.Cainfo
  20735. pp.SecretKey = miConfig.SecretKey
  20736. pp.AccessKey = miConfig.AccessKey
  20737. pp.OpterName = curRoles.UserName
  20738. result, _ := service.Jxyb4101(struct4101, pp)
  20739. var dat map[string]interface{}
  20740. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20741. fmt.Println(dat)
  20742. } else {
  20743. fmt.Println(err)
  20744. }
  20745. userJSONBytes, _ := json.Marshal(dat)
  20746. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20747. utils.ErrorLog("解析失败:%v", err)
  20748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20749. return
  20750. }
  20751. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20752. var pp models.PublicParams
  20753. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20754. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20755. pp.FixmedinsName = miConfig.OrgName
  20756. pp.FixmedinsCode = miConfig.Code
  20757. pp.RequestUrl = miConfig.Url
  20758. pp.Cainfo = miConfig.Cainfo
  20759. pp.SecretKey = miConfig.SecretKey
  20760. pp.AccessKey = miConfig.AccessKey
  20761. pp.OpterName = curRoles.UserName
  20762. result, _ := service.Hnyb4101(struct4101, pp)
  20763. var dat map[string]interface{}
  20764. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20765. fmt.Println(dat)
  20766. } else {
  20767. fmt.Println(err)
  20768. }
  20769. userJSONBytes, _ := json.Marshal(dat)
  20770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20771. utils.ErrorLog("解析失败:%v", err)
  20772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20773. return
  20774. }
  20775. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20776. var resOther ResultSeventeenOther
  20777. var pp models.PublicParams
  20778. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20779. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20780. pp.FixmedinsName = miConfig.OrgName
  20781. pp.FixmedinsCode = miConfig.Code
  20782. pp.RequestUrl = miConfig.Url
  20783. pp.Cainfo = miConfig.Cainfo
  20784. pp.SecretKey = miConfig.SecretKey
  20785. pp.AccessKey = miConfig.AccessKey
  20786. pp.OpterName = curRoles.UserName
  20787. client := &http.Client{}
  20788. var req *http.Request
  20789. data := make(map[string]interface{})
  20790. data["struct4101"] = struct4101
  20791. data["pp"] = pp
  20792. bytesData, _ := json.Marshal(data)
  20793. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20794. resp, _ := client.Do(req)
  20795. defer resp.Body.Close()
  20796. body, ioErr := ioutil.ReadAll(resp.Body)
  20797. if ioErr != nil {
  20798. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20800. return
  20801. }
  20802. var respJSON map[string]interface{}
  20803. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20806. return
  20807. }
  20808. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20809. userJSONBytes, _ := json.Marshal(respJSON)
  20810. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20811. utils.ErrorLog("解析失败:%v", err)
  20812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20813. return
  20814. }
  20815. res.InfRefmsgid = resOther.InfRefmsgid
  20816. res.Output = resOther.Output
  20817. res.ErrMsg = resOther.ErrMsg
  20818. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20819. res.Infcode = infocode
  20820. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20821. var pp models.PublicParams
  20822. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20823. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20824. pp.FixmedinsName = miConfig.OrgName
  20825. pp.FixmedinsCode = miConfig.Code
  20826. pp.RequestUrl = miConfig.Url
  20827. pp.Cainfo = miConfig.Cainfo
  20828. pp.SecretKey = miConfig.SecretKey
  20829. pp.AccessKey = miConfig.AccessKey
  20830. pp.OpterName = curRoles.UserName
  20831. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20832. fmt.Println(requestLog)
  20833. fmt.Println(errMsgLog)
  20834. saveLog(result, requestLog, "4101a", "上传清单")
  20835. var dat map[string]interface{}
  20836. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20837. fmt.Println(dat)
  20838. } else {
  20839. fmt.Println(err)
  20840. }
  20841. userJSONBytes, _ := json.Marshal(dat)
  20842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20843. utils.ErrorLog("解析失败:%v", err)
  20844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20845. return
  20846. }
  20847. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20848. var pp models.PublicParams
  20849. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20850. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20851. pp.FixmedinsName = miConfig.OrgName
  20852. pp.FixmedinsCode = miConfig.Code
  20853. pp.RequestUrl = miConfig.Url
  20854. pp.Cainfo = miConfig.Cainfo
  20855. pp.SecretKey = miConfig.SecretKey
  20856. pp.AccessKey = miConfig.AccessKey
  20857. pp.OpterName = curRoles.UserName
  20858. client := &http.Client{}
  20859. var req *http.Request
  20860. data := make(map[string]interface{})
  20861. data["struct4101"] = struct4101
  20862. data["pp"] = pp
  20863. bytesData, _ := json.Marshal(data)
  20864. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20865. resp, _ := client.Do(req)
  20866. defer resp.Body.Close()
  20867. body, ioErr := ioutil.ReadAll(resp.Body)
  20868. if ioErr != nil {
  20869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20871. return
  20872. }
  20873. var respJSON map[string]interface{}
  20874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20877. return
  20878. }
  20879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20880. userJSONBytes, _ := json.Marshal(respJSON)
  20881. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20882. utils.ErrorLog("解析失败:%v", err)
  20883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20884. return
  20885. }
  20886. } else {
  20887. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20888. var dat map[string]interface{}
  20889. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20890. fmt.Println(dat)
  20891. } else {
  20892. fmt.Println(err)
  20893. }
  20894. userJSONBytes, _ := json.Marshal(dat)
  20895. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20896. utils.ErrorLog("解析失败:%v", err)
  20897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20898. return
  20899. }
  20900. }
  20901. if res.Infcode != 0 {
  20902. c.ServeSuccessJSON(map[string]interface{}{
  20903. "failed_code": -10,
  20904. "msg": res.ErrMsg,
  20905. })
  20906. return
  20907. } else {
  20908. //order.FaPiaoNumber = zero
  20909. //order.FaPiaoCode = last_order.FaPiaoCode
  20910. //service.UpdateOrder(order)
  20911. hisFundSettleListResult := &models.HisFundSettleListResult{
  20912. Number: res.Output.SetlListId,
  20913. Status: 1,
  20914. Ctime: time.Now().Unix(),
  20915. Mtime: time.Now().Unix(),
  20916. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20917. IsUpload: 1,
  20918. OrderId: order_id,
  20919. }
  20920. service.CreateUploadRecord(hisFundSettleListResult)
  20921. c.ServeSuccessJSON(map[string]interface{}{
  20922. "msg": "上传成功",
  20923. "result": hisFundSettleListResult,
  20924. })
  20925. return
  20926. }
  20927. }
  20928. func (c *HisApiController) GetSettleListHospital() {
  20929. order_id, _ := c.GetInt64("order_id")
  20930. admin_user_id, _ := c.GetInt64("admin_user_id")
  20931. order, _ := service.GetHisOrderByIDTwo(order_id)
  20932. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20933. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  20934. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20935. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20936. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20937. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20938. if order.ID == 0 {
  20939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20940. return
  20941. }
  20942. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20943. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20944. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20945. fmt.Println(count)
  20946. var zero string
  20947. number := count + 1
  20948. if number >= 1000 {
  20949. zero = "0000" + strconv.FormatInt(number, 10)
  20950. } else if number >= 10000 {
  20951. zero = "000" + strconv.FormatInt(number, 10)
  20952. } else if number >= 100000 {
  20953. zero = "00" + strconv.FormatInt(number, 10)
  20954. } else if number >= 1000000 {
  20955. zero = "0" + strconv.FormatInt(number, 10)
  20956. } else {
  20957. zero = strconv.FormatInt(number, 10)
  20958. }
  20959. fmt.Println(zero)
  20960. struct4101 := service.Struct4101{
  20961. PsnNo: order.PsnNo,
  20962. MdtrtId: order.MdtrtId,
  20963. SetlId: order.SetlId,
  20964. PsnName: order.PsnName,
  20965. Gend: order.Gend,
  20966. Brdy: his.Brdy,
  20967. Age: int64(order.Age),
  20968. Naty: order.Naty,
  20969. PatnCertType: "01",
  20970. Certno: order.Certno,
  20971. Prfs: "90",
  20972. ConerName: roles[0].UserName,
  20973. PatnRlts: "99",
  20974. ConerAddr: miConfig.OrgName,
  20975. ConerTel: admin.Mobile,
  20976. HiType: order.Insutype,
  20977. Insuplc: miConfig.InsuplcAdmdvs,
  20978. MaindiagFlag: "1",
  20979. BillCode: order.SetlId,
  20980. BillNo: order.SetlId,
  20981. BizSn: order.Number,
  20982. PsnSelfPay: order.PsnPartAmt,
  20983. PsnOwnPay: order.PsnPartAmt,
  20984. AcctPay: order.AcctPay,
  20985. PsnCashpay: order.PsnCashPay,
  20986. HiPaymtd: "1",
  20987. Hsorg: miConfig.InsuplcAdmdvs,
  20988. HsorgOpter: miConfig.InsuplcAdmdvs,
  20989. MedinsFillPsn: curRoles.UserName,
  20990. MedinsFillDept: depart.Name,
  20991. IptMedType: "2",
  20992. AdmTime: his.InHosptialTime,
  20993. AdmEndTime: his.OutHosptialTime,
  20994. }
  20995. struct4101.SetlBegnDate = order.SetlTime
  20996. struct4101.SetlEndDate = order.SetlTime
  20997. //var rf []CustomFundPay
  20998. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20999. //
  21000. //var tempFunPays []service.CustomStruct
  21001. //for _, item := range rf {
  21002. // var tempFunPay service.CustomStruct
  21003. // tempFunPay.FundPayamt = item.FundPayamt
  21004. // tempFunPay.FundPayType = item.FundPayType
  21005. // tempFunPays = append(tempFunPays, tempFunPay)
  21006. //}
  21007. //struct4101.CustomStruct = tempFunPays
  21008. var tempDiaginfos []service.DiaginfoStructTwo
  21009. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21010. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21011. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  21012. //for _, item := range infos {
  21013. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  21014. //}
  21015. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  21016. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  21017. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21018. fmt.Println(diagnosis_ids_arr)
  21019. if order.UserOrgId == 10210 {
  21020. var diagnosis_ids_arr_two []int64
  21021. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  21022. var config []*models.HisXtDiagnoseConfig
  21023. for _, id := range diagnosis_ids_arr_two {
  21024. //id, _ := strconv.ParseInt(item, 10, 64)
  21025. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21026. if diagnosisConfig.ID > 0 {
  21027. config = append(config, &diagnosisConfig)
  21028. }
  21029. }
  21030. for index, item := range config {
  21031. if item.ID > 0 {
  21032. if index == 0 {
  21033. var tempDiaginfo service.DiaginfoStructTwo
  21034. tempDiaginfo.DiagCode = item.CountryCode
  21035. tempDiaginfo.DiagName = item.CountryContentName
  21036. tempDiaginfo.DiagType = "1"
  21037. tempDiaginfo.MaindiagFlag = "1"
  21038. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21039. } else {
  21040. var tempDiaginfo service.DiaginfoStructTwo
  21041. tempDiaginfo.DiagCode = item.CountryCode
  21042. tempDiaginfo.DiagName = item.CountryContentName
  21043. tempDiaginfo.DiagType = "1"
  21044. tempDiaginfo.MaindiagFlag = "0"
  21045. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21046. }
  21047. }
  21048. }
  21049. struct4101.Diseinfo = tempDiaginfos
  21050. } else {
  21051. var config []*models.HisXtDiagnoseConfig
  21052. for _, item := range diagnosis_ids_arr {
  21053. id, _ := strconv.ParseInt(item, 10, 64)
  21054. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21055. if diagnosisConfig.ID > 0 {
  21056. config = append(config, &diagnosisConfig)
  21057. }
  21058. }
  21059. for index, item := range config {
  21060. if item.ID > 0 {
  21061. if index == 0 {
  21062. var tempDiaginfo service.DiaginfoStructTwo
  21063. tempDiaginfo.DiagCode = item.CountryCode
  21064. tempDiaginfo.DiagName = item.CountryContentName
  21065. tempDiaginfo.DiagType = "1"
  21066. tempDiaginfo.MaindiagFlag = "1"
  21067. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21068. } else {
  21069. var tempDiaginfo service.DiaginfoStructTwo
  21070. tempDiaginfo.DiagCode = item.CountryCode
  21071. tempDiaginfo.DiagName = item.CountryContentName
  21072. tempDiaginfo.DiagType = "1"
  21073. tempDiaginfo.MaindiagFlag = "0"
  21074. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21075. }
  21076. }
  21077. }
  21078. struct4101.Diseinfo = tempDiaginfos
  21079. }
  21080. sickConfigTwo, _ := service.FindSickById(his.SickType)
  21081. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21082. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21083. tempOpspdiseinfo2.OprnOprtCode = ""
  21084. tempOpspdiseinfo2.OprnOprtName = ""
  21085. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21086. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21087. var iteminfo service.IteminfoStruct
  21088. var bedCostTotal float64 = 0 //床位总费
  21089. var bedCostSelfTotal float64 = 0 //床位自费
  21090. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21091. var operationCostTotal float64 = 0 //手术费
  21092. var operationCostSelfTotal float64 = 0 //手术费
  21093. var operationCostPartSelfTotal float64 = 0 //手术费
  21094. var otherCostTotal float64 = 0 //其他费用
  21095. var otherCostSelfTotal float64 = 0 //其他费用
  21096. var otherCostPartSelfTotal float64 = 0 //其他费用
  21097. var materialCostTotal float64 = 0 //材料费
  21098. var materialCostSelfTotal float64 = 0 //材料费
  21099. var materialCostPartSelfTotal float64 = 0 //材料费
  21100. var westernMedicineCostTotal float64 = 0 //西药费
  21101. var westernMedicineCostSelfTotal float64 = 0 //西药费
  21102. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21103. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21104. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21105. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21106. var checkCostTotal float64 = 0 //检查费
  21107. var checkCostSelfTotal float64 = 0 //检查费
  21108. var checkCostPartSelfTotal float64 = 0 //检查费
  21109. var laboratoryCostTotal float64 = 0 //化验费
  21110. var laboratoryCostSelfTotal float64 = 0 //化验费
  21111. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21112. var treatCostTotal float64 = 0 //治疗费用
  21113. var treatCostSelfTotal float64 = 0 //治疗费用
  21114. var treatCostPartSelfTotal float64 = 0 //治疗费用
  21115. decimal.DivisionPrecision = 2
  21116. var bed_fulamt_ownpay_amt float64 = 0
  21117. var operation_fulamt_ownpay_amt float64 = 0
  21118. var other_fulamt_ownpay_amt float64 = 0
  21119. var westernMedicine_fulamt_ownpay_amt float64 = 0
  21120. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21121. var check_fulamt_ownpay_amt float64 = 0
  21122. var material_fulamt_ownpay_amt float64 = 0
  21123. var laboratory_fulamt_ownpay_amt float64 = 0
  21124. var treat_fulamt_ownpay_amt float64 = 0
  21125. var bed_claa_sunmfee float64 = 0
  21126. var bed_clab_amt float64 = 0
  21127. var bed_other_amt float64 = 0
  21128. var operation_claa_sunmfee float64 = 0
  21129. var operation_clab_amt float64 = 0
  21130. var operation_other_amt float64 = 0
  21131. var other_claa_sunmfee float64 = 0
  21132. var other_clab_amt float64 = 0
  21133. var other_other_amt float64 = 0
  21134. var westernMedicine_claa_sunmfee float64 = 0
  21135. var westernMedicine_clab_amt float64 = 0
  21136. var westernMedicine_other_amt float64 = 0
  21137. var chineseTraditional_claa_sunmfee float64 = 0
  21138. var chineseTraditional_clab_amt float64 = 0
  21139. var chineseTraditional_other_amt float64 = 0
  21140. var check_claa_sunmfee float64 = 0
  21141. var check_clab_amt float64 = 0
  21142. var check_other_amt float64 = 0
  21143. var material_claa_sunmfee float64 = 0
  21144. var material_clab_amt float64 = 0
  21145. var material_other_amt float64 = 0
  21146. var laboratory_claa_sunmfee float64 = 0
  21147. var laboratory_clab_amt float64 = 0
  21148. var laboratory_other_amt float64 = 0
  21149. var treat_claa_sunmfee float64 = 0
  21150. var treat_clab_amt float64 = 0
  21151. var treat_other_amt float64 = 0
  21152. for _, item := range order.HisOrderInfo {
  21153. if item.MedChrgitmType == "01" { //床位费
  21154. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21155. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21156. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21157. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21158. if item.ChrgitmLv == "1" {
  21159. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21160. }
  21161. if item.ChrgitmLv == "2" {
  21162. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21163. }
  21164. if item.ChrgitmLv == "3" {
  21165. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21166. }
  21167. }
  21168. if item.MedChrgitmType == "03" { //检查费
  21169. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21170. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21171. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21172. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21173. if item.ChrgitmLv == "1" {
  21174. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21175. }
  21176. if item.ChrgitmLv == "2" {
  21177. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21178. }
  21179. if item.ChrgitmLv == "3" {
  21180. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21181. }
  21182. }
  21183. if item.MedChrgitmType == "04" { //化验费
  21184. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21185. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21186. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21187. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21188. if item.ChrgitmLv == "1" {
  21189. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21190. }
  21191. if item.ChrgitmLv == "2" {
  21192. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21193. }
  21194. if item.ChrgitmLv == "3" {
  21195. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21196. }
  21197. }
  21198. if item.MedChrgitmType == "05" { //治疗费
  21199. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21200. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21201. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21202. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21203. if item.ChrgitmLv == "1" {
  21204. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21205. }
  21206. if item.ChrgitmLv == "2" {
  21207. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21208. }
  21209. if item.ChrgitmLv == "3" {
  21210. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21211. }
  21212. }
  21213. if item.MedChrgitmType == "06" { //手术费
  21214. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21215. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21216. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21217. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21218. if item.ChrgitmLv == "1" {
  21219. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21220. }
  21221. if item.ChrgitmLv == "2" {
  21222. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21223. }
  21224. if item.ChrgitmLv == "3" {
  21225. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21226. }
  21227. }
  21228. if item.MedChrgitmType == "08" { //材料费
  21229. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21230. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21231. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21232. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21233. if item.ChrgitmLv == "1" {
  21234. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21235. }
  21236. if item.ChrgitmLv == "2" {
  21237. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21238. }
  21239. if item.ChrgitmLv == "3" {
  21240. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21241. }
  21242. }
  21243. if item.MedChrgitmType == "09" { //西药费
  21244. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21245. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21246. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21247. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21248. if item.ChrgitmLv == "1" {
  21249. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21250. }
  21251. if item.ChrgitmLv == "2" {
  21252. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21253. }
  21254. if item.ChrgitmLv == "3" {
  21255. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21256. }
  21257. }
  21258. if item.MedChrgitmType == "11" { //中成费
  21259. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21260. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21261. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21262. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21263. if item.ChrgitmLv == "1" {
  21264. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21265. }
  21266. if item.ChrgitmLv == "2" {
  21267. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21268. }
  21269. if item.ChrgitmLv == "3" {
  21270. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21271. }
  21272. }
  21273. if item.MedChrgitmType == "14" { //其他费
  21274. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21275. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21276. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21277. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21278. if item.ChrgitmLv == "1" {
  21279. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21280. }
  21281. if item.ChrgitmLv == "2" {
  21282. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21283. }
  21284. if item.ChrgitmLv == "3" {
  21285. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21286. }
  21287. }
  21288. }
  21289. var iteminfoStructs []service.IteminfoStruct
  21290. if bedCostTotal != 0 {
  21291. iteminfo.MedChrgitm = "01"
  21292. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21293. iteminfo.Amt = bedCostTotal
  21294. iteminfo.ClaaSumfee = bed_claa_sunmfee
  21295. iteminfo.ClabAmt = bed_clab_amt
  21296. iteminfo.OthAmt = bed_other_amt
  21297. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21298. }
  21299. if checkCostTotal != 0 {
  21300. iteminfo.MedChrgitm = "03"
  21301. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21302. iteminfo.Amt = checkCostTotal
  21303. iteminfo.ClaaSumfee = check_claa_sunmfee
  21304. iteminfo.ClabAmt = check_clab_amt
  21305. iteminfo.OthAmt = check_other_amt
  21306. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21307. }
  21308. if laboratoryCostTotal != 0 {
  21309. iteminfo.MedChrgitm = "04"
  21310. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21311. iteminfo.Amt = laboratoryCostTotal
  21312. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21313. iteminfo.ClabAmt = laboratory_clab_amt
  21314. iteminfo.OthAmt = laboratory_other_amt
  21315. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21316. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21317. }
  21318. if treatCostTotal != 0 {
  21319. iteminfo.MedChrgitm = "05"
  21320. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21321. iteminfo.Amt = treatCostTotal
  21322. iteminfo.ClaaSumfee = treat_claa_sunmfee
  21323. iteminfo.ClabAmt = treat_clab_amt
  21324. iteminfo.OthAmt = treat_other_amt
  21325. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21326. //(struct4101.IteminfoStruct, iteminfo)
  21327. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21328. }
  21329. if operationCostTotal != 0 {
  21330. iteminfo.MedChrgitm = "06"
  21331. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21332. iteminfo.Amt = operationCostTotal
  21333. iteminfo.ClaaSumfee = operation_claa_sunmfee
  21334. iteminfo.ClabAmt = operation_clab_amt
  21335. iteminfo.OthAmt = operation_other_amt
  21336. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21337. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21338. }
  21339. if materialCostTotal != 0 {
  21340. iteminfo.MedChrgitm = "08"
  21341. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21342. iteminfo.Amt = materialCostTotal
  21343. iteminfo.ClaaSumfee = material_claa_sunmfee
  21344. iteminfo.ClabAmt = material_clab_amt
  21345. iteminfo.OthAmt = material_other_amt
  21346. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21347. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21348. }
  21349. if westernMedicineCostTotal != 0 {
  21350. iteminfo.MedChrgitm = "09"
  21351. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21352. iteminfo.Amt = westernMedicineCostTotal
  21353. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21354. iteminfo.ClabAmt = westernMedicine_clab_amt
  21355. iteminfo.OthAmt = westernMedicine_other_amt
  21356. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21357. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21358. }
  21359. if chineseTraditionalMedicineCostTotal != 0 {
  21360. iteminfo.MedChrgitm = "11"
  21361. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21362. iteminfo.Amt = westernMedicineCostTotal
  21363. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21364. iteminfo.ClabAmt = westernMedicine_clab_amt
  21365. iteminfo.OthAmt = westernMedicine_other_amt
  21366. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21367. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21368. }
  21369. if otherCostTotal != 0 {
  21370. iteminfo.MedChrgitm = "14"
  21371. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21372. iteminfo.Amt = otherCostTotal
  21373. iteminfo.ClaaSumfee = other_claa_sunmfee
  21374. iteminfo.ClabAmt = other_clab_amt
  21375. iteminfo.OthAmt = other_other_amt
  21376. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21377. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21378. }
  21379. struct4101.IteminfoStruct = iteminfoStructs
  21380. struct4101.Ntly = "中国"
  21381. struct4101.AdmCaty = "A03.06"
  21382. var resOther ResultSeventeenOther
  21383. var res ResultSeventeen
  21384. if miConfig.MdtrtareaAdmvs == "150499" {
  21385. var pp models.PublicParams
  21386. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21387. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21388. pp.FixmedinsName = miConfig.OrgName
  21389. pp.FixmedinsCode = miConfig.Code
  21390. pp.RequestUrl = miConfig.Url
  21391. pp.Cainfo = miConfig.Cainfo
  21392. pp.SecretKey = miConfig.SecretKey
  21393. pp.AccessKey = miConfig.AccessKey
  21394. pp.OpterName = curRoles.UserName
  21395. client := &http.Client{}
  21396. var req *http.Request
  21397. data := make(map[string]interface{})
  21398. data["struct4101"] = struct4101
  21399. data["pp"] = pp
  21400. bytesData, _ := json.Marshal(data)
  21401. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  21402. resp, _ := client.Do(req)
  21403. defer resp.Body.Close()
  21404. body, ioErr := ioutil.ReadAll(resp.Body)
  21405. if ioErr != nil {
  21406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21408. return
  21409. }
  21410. var respJSON map[string]interface{}
  21411. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21414. return
  21415. }
  21416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21417. userJSONBytes, _ := json.Marshal(respJSON)
  21418. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  21419. utils.ErrorLog("解析失败:%v", err)
  21420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21421. return
  21422. }
  21423. res.InfRefmsgid = resOther.InfRefmsgid
  21424. res.Output = resOther.Output
  21425. res.ErrMsg = resOther.ErrMsg
  21426. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  21427. res.Infcode = infocode
  21428. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21429. var pp models.PublicParams
  21430. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21431. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21432. pp.FixmedinsName = miConfig.OrgName
  21433. pp.FixmedinsCode = miConfig.Code
  21434. pp.RequestUrl = miConfig.Url
  21435. pp.Cainfo = miConfig.Cainfo
  21436. pp.SecretKey = miConfig.SecretKey
  21437. pp.AccessKey = miConfig.AccessKey
  21438. pp.OpterName = curRoles.UserName
  21439. result, _ := service.Jxyb4101(struct4101, pp)
  21440. var dat map[string]interface{}
  21441. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21442. fmt.Println(dat)
  21443. } else {
  21444. fmt.Println(err)
  21445. }
  21446. userJSONBytes, _ := json.Marshal(dat)
  21447. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21448. utils.ErrorLog("解析失败:%v", err)
  21449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21450. return
  21451. }
  21452. } else if miConfig.MdtrtareaAdmvs == "361025" {
  21453. var pp models.PublicParams
  21454. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21455. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21456. pp.FixmedinsName = miConfig.OrgName
  21457. pp.FixmedinsCode = miConfig.Code
  21458. pp.RequestUrl = miConfig.Url
  21459. pp.Cainfo = miConfig.Cainfo
  21460. pp.SecretKey = miConfig.SecretKey
  21461. pp.AccessKey = miConfig.AccessKey
  21462. pp.OpterName = curRoles.UserName
  21463. result, _ := service.Jxyb4101(struct4101, pp)
  21464. var dat map[string]interface{}
  21465. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21466. fmt.Println(dat)
  21467. } else {
  21468. fmt.Println(err)
  21469. }
  21470. userJSONBytes, _ := json.Marshal(dat)
  21471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21472. utils.ErrorLog("解析失败:%v", err)
  21473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21474. return
  21475. }
  21476. } else if miConfig.MdtrtareaAdmvs == "360100" {
  21477. var pp models.PublicParams
  21478. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21479. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21480. pp.FixmedinsName = miConfig.OrgName
  21481. pp.FixmedinsCode = miConfig.Code
  21482. pp.RequestUrl = miConfig.Url
  21483. pp.Cainfo = miConfig.Cainfo
  21484. pp.SecretKey = miConfig.SecretKey
  21485. pp.AccessKey = miConfig.AccessKey
  21486. pp.OpterName = curRoles.UserName
  21487. result, _ := service.Jxyb4101(struct4101, pp)
  21488. var dat map[string]interface{}
  21489. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21490. fmt.Println(dat)
  21491. } else {
  21492. fmt.Println(err)
  21493. }
  21494. userJSONBytes, _ := json.Marshal(dat)
  21495. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21496. utils.ErrorLog("解析失败:%v", err)
  21497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21498. return
  21499. }
  21500. } else {
  21501. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21502. var dat map[string]interface{}
  21503. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21504. fmt.Println(dat)
  21505. } else {
  21506. fmt.Println(err)
  21507. }
  21508. userJSONBytes, _ := json.Marshal(dat)
  21509. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21510. utils.ErrorLog("解析失败:%v", err)
  21511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21512. return
  21513. }
  21514. }
  21515. if res.Infcode != 0 {
  21516. c.ServeSuccessJSON(map[string]interface{}{
  21517. "failed_code": -10,
  21518. "msg": res.ErrMsg,
  21519. })
  21520. return
  21521. } else {
  21522. if miConfig.MdtrtareaAdmvs != "150499" {
  21523. order.FaPiaoNumber = zero
  21524. order.FaPiaoCode = last_order.FaPiaoCode
  21525. service.UpdateOrder(order)
  21526. }
  21527. hisFundSettleListResult := &models.HisFundSettleListResult{
  21528. Number: res.Output.SetlListId,
  21529. Status: 1,
  21530. Ctime: time.Now().Unix(),
  21531. Mtime: time.Now().Unix(),
  21532. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21533. IsUpload: 1,
  21534. OrderId: order_id,
  21535. }
  21536. service.CreateUploadRecord(hisFundSettleListResult)
  21537. c.ServeSuccessJSON(map[string]interface{}{
  21538. "msg": "上传成功",
  21539. "result": hisFundSettleListResult,
  21540. })
  21541. return
  21542. }
  21543. }
  21544. //func (c *HisApiController) GetBatchSettleList() {
  21545. // orders, _ := service.GetAllHisOrder(10106)
  21546. // for _, item := range orders {
  21547. // order_id := item.ID
  21548. // order, _ := service.GetHisOrderByIDTwo(order_id)
  21549. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21550. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  21551. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21552. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  21553. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21554. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21555. //
  21556. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  21557. //
  21558. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  21559. //
  21560. // if order.ID == 0 {
  21561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21562. // return
  21563. // }
  21564. // if his.BalanceAccountsType == 2 {
  21565. // continue
  21566. // }
  21567. // struct4101 := service.Struct4101{
  21568. // PsnNo: order.PsnNo,
  21569. // MdtrtId: order.MdtrtId,
  21570. // SetlId: order.SetlId,
  21571. // PsnName: order.PsnName,
  21572. // Gend: order.Gend,
  21573. // Brdy: his.Brdy,
  21574. // Age: his.Age,
  21575. // Naty: order.Naty,
  21576. // PatnCertType: "01",
  21577. // Certno: order.Certno,
  21578. // Prfs: "90",
  21579. // ConerName: roles[0].UserName,
  21580. // PatnRlts: "99",
  21581. // ConerAddr: miConfig.OrgName,
  21582. // ConerTel: admin.Mobile,
  21583. // HiType: order.Insutype,
  21584. // Insuplc: his.InsuplcAdmdvs,
  21585. // MaindiagFlag: "1",
  21586. // BillCode: order.SetlId,
  21587. // BillNo: order.SetlId,
  21588. // BizSn: order.Number,
  21589. // PsnSelfPay: order.PsnPartAmt,
  21590. // PsnOwnPay: order.PsnPartAmt,
  21591. // AcctPay: order.AcctPay,
  21592. // PsnCashpay: order.PsnCashPay,
  21593. // HiPaymtd: "1",
  21594. // Hsorg: his.InsuplcAdmdvs,
  21595. // HsorgOpter: his.InsuplcAdmdvs,
  21596. // MedinsFillPsn: curRoles.UserName,
  21597. // MedinsFillDept: depart.Name,
  21598. // IptMedType: "2",
  21599. // }
  21600. // struct4101.SetlBegnDate = order.SetlTime
  21601. // struct4101.SetlEndDate = order.SetlTime
  21602. // //if order.SettleType == 1 {
  21603. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  21604. // // dateStr := t.Format("2006-01-02")
  21605. // // struct4101.SetlBegnDate = dateStr
  21606. // // struct4101.SetlEndDate = dateStr
  21607. // //} else {
  21608. // // t := time.Unix(int64(order.SettleStartTime), 0)
  21609. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  21610. // // dateStartStr := t.Format("2006-01-02")
  21611. // // dateEndStr := t2.Format("2006-01-02")
  21612. // // struct4101.SetlBegnDate = dateStartStr
  21613. // // struct4101.SetlEndDate = dateEndStr
  21614. // //}
  21615. //
  21616. // var rf []CustomFundPay
  21617. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  21618. //
  21619. // var tempFunPays []service.CustomStruct
  21620. // var tempFunPay610100 service.CustomStruct
  21621. //
  21622. // for _, item := range rf {
  21623. // if item.FundPayType == "610100" {
  21624. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  21625. // tempFunPay610100.FundPayType = item.FundPayType
  21626. // } else {
  21627. // var tempFunPay service.CustomStruct
  21628. // tempFunPay.FundPayamt = item.FundPayamt
  21629. // tempFunPay.FundPayType = item.FundPayType
  21630. // tempFunPays = append(tempFunPays, tempFunPay)
  21631. // }
  21632. // }
  21633. // tempFunPays = append(tempFunPays, tempFunPay610100)
  21634. // struct4101.CustomStruct = tempFunPays
  21635. //
  21636. // var tempDiaginfos []service.DiaginfoStructTwo
  21637. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21638. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21639. //
  21640. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21641. // var config []*models.HisXtDiagnoseConfig
  21642. // for _, item := range diagnosis_ids {
  21643. // id, _ := strconv.ParseInt(item, 10, 64)
  21644. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  21645. // config = append(config, &diagnosisConfig)
  21646. // }
  21647. //
  21648. // for index, item := range config {
  21649. // if index == 0 {
  21650. // var tempDiaginfo service.DiaginfoStructTwo
  21651. // tempDiaginfo.DiagCode = item.CountryCode
  21652. // tempDiaginfo.DiagName = item.CountryContentName
  21653. // tempDiaginfo.DiagType = "1"
  21654. // tempDiaginfo.MaindiagFlag = "1"
  21655. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21656. // } else {
  21657. //
  21658. // var tempDiaginfo service.DiaginfoStructTwo
  21659. // tempDiaginfo.DiagCode = item.CountryCode
  21660. // tempDiaginfo.DiagName = item.CountryContentName
  21661. // tempDiaginfo.DiagType = "2"
  21662. // tempDiaginfo.MaindiagFlag = "0"
  21663. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21664. // }
  21665. // }
  21666. // struct4101.Diseinfo = tempDiaginfos
  21667. //
  21668. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  21669. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21670. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21671. // tempOpspdiseinfo2.OprnOprtCode = ""
  21672. // tempOpspdiseinfo2.OprnOprtName = ""
  21673. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21674. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21675. //
  21676. // var iteminfo service.IteminfoStruct
  21677. //
  21678. // var bedCostTotal float64 = 0 //床位总费
  21679. // var bedCostSelfTotal float64 = 0 //床位自费
  21680. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21681. //
  21682. // var examineCostTotal float64 = 0 //诊查总费
  21683. // var examineCostSelfTotal float64 = 0 //诊查自费
  21684. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21685. //
  21686. // var nursingCostTotal float64 = 0 //护理总费
  21687. // var nursingCostSelfTotal float64 = 0 //护理自费
  21688. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21689. //
  21690. // var chineseMedicineCostTotal float64 = 0 //中成药
  21691. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21692. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21693. //
  21694. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21695. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21696. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21697. //
  21698. // var registerCostTotal float64 = 0 //一般诊疗费
  21699. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21700. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21701. //
  21702. // var operationCostTotal float64 = 0 //手术费
  21703. // var operationCostSelfTotal float64 = 0 //手术费
  21704. // var operationCostPartSelfTotal float64 = 0 //手术费
  21705. //
  21706. // var otherCostTotal float64 = 0 //其他费用
  21707. // var otherCostSelfTotal float64 = 0 //其他费用
  21708. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21709. //
  21710. // var materialCostTotal float64 = 0 //材料费
  21711. // var materialCostSelfTotal float64 = 0 //材料费
  21712. // var materialCostPartSelfTotal float64 = 0 //材料费
  21713. //
  21714. // var westernMedicineCostTotal float64 = 0 //西药费
  21715. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21716. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21717. //
  21718. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21719. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21720. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21721. //
  21722. // var checkCostTotal float64 = 0 //检查费
  21723. // var checkCostSelfTotal float64 = 0 //检查费
  21724. // var checkCostPartSelfTotal float64 = 0 //检查费
  21725. //
  21726. // var laboratoryCostTotal float64 = 0 //化验费
  21727. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21728. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21729. //
  21730. // var treatCostTotal float64 = 0 //治疗费用
  21731. // var treatCostSelfTotal float64 = 0 //治疗费用
  21732. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21733. //
  21734. // decimal.DivisionPrecision = 2
  21735. //
  21736. // var bed_fulamt_ownpay_amt float64 = 0
  21737. //
  21738. // var examine_fulamt_ownpay_amt float64 = 0
  21739. //
  21740. // var nursing_fulamt_ownpay_amt float64 = 0
  21741. //
  21742. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21743. //
  21744. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21745. //
  21746. // var register_fulamt_ownpay_amt float64 = 0
  21747. //
  21748. // var operation_fulamt_ownpay_amt float64 = 0
  21749. // var other_fulamt_ownpay_amt float64 = 0
  21750. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21751. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21752. // var check_fulamt_ownpay_amt float64 = 0
  21753. // var material_fulamt_ownpay_amt float64 = 0
  21754. // var laboratory_fulamt_ownpay_amt float64 = 0
  21755. // var treat_fulamt_ownpay_amt float64 = 0
  21756. //
  21757. // var bed_claa_sunmfee float64 = 0
  21758. // var bed_clab_amt float64 = 0
  21759. // var bed_other_amt float64 = 0
  21760. //
  21761. // var examine_claa_sunmfee float64 = 0
  21762. // var examine_clab_amt float64 = 0
  21763. // var examine_other_amt float64 = 0
  21764. //
  21765. // var nursing_claa_sunmfee float64 = 0
  21766. // var nursing_clab_amt float64 = 0
  21767. // var nursing_other_amt float64 = 0
  21768. //
  21769. // var chinese_medicine_claa_sunmfee float64 = 0
  21770. // var chinese_medicine_clab_amt float64 = 0
  21771. // var chinese_medicine_other_amt float64 = 0
  21772. //
  21773. // var commonly_treatment_claa_sunmfee float64 = 0
  21774. // var commonly_treatment_clab_amt float64 = 0
  21775. // var commonly_treatment_other_amt float64 = 0
  21776. //
  21777. // var operation_claa_sunmfee float64 = 0
  21778. // var operation_clab_amt float64 = 0
  21779. // var operation_other_amt float64 = 0
  21780. //
  21781. // var other_claa_sunmfee float64 = 0
  21782. // var other_clab_amt float64 = 0
  21783. // var other_other_amt float64 = 0
  21784. //
  21785. // var westernMedicine_claa_sunmfee float64 = 0
  21786. // var westernMedicine_clab_amt float64 = 0
  21787. // var westernMedicine_other_amt float64 = 0
  21788. //
  21789. // var chineseTraditional_claa_sunmfee float64 = 0
  21790. // var chineseTraditional_clab_amt float64 = 0
  21791. // var chineseTraditional_other_amt float64 = 0
  21792. //
  21793. // var check_claa_sunmfee float64 = 0
  21794. // var check_clab_amt float64 = 0
  21795. // var check_other_amt float64 = 0
  21796. //
  21797. // var material_claa_sunmfee float64 = 0
  21798. // var material_clab_amt float64 = 0
  21799. // var material_other_amt float64 = 0
  21800. //
  21801. // var laboratory_claa_sunmfee float64 = 0
  21802. // var laboratory_clab_amt float64 = 0
  21803. // var laboratory_other_amt float64 = 0
  21804. //
  21805. // var treat_claa_sunmfee float64 = 0
  21806. // var treat_clab_amt float64 = 0
  21807. // var treat_other_amt float64 = 0
  21808. //
  21809. // var register_claa_sunmfee float64 = 0
  21810. // var register_clab_amt float64 = 0
  21811. // var register_other_amt float64 = 0
  21812. //
  21813. // for _, item := range order.HisOrderInfo {
  21814. // if item.MedChrgitmType == "01" { //床位费
  21815. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21816. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21817. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21818. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21819. // if item.ChrgitmLv == "1" {
  21820. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21821. // }
  21822. // if item.ChrgitmLv == "2" {
  21823. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21824. //
  21825. // }
  21826. // if item.ChrgitmLv == "3" {
  21827. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21828. // }
  21829. //
  21830. // }
  21831. //
  21832. // if item.MedChrgitmType == "02" { //诊查
  21833. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21834. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21835. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21836. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21837. // if item.ChrgitmLv == "1" {
  21838. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21839. // }
  21840. // if item.ChrgitmLv == "2" {
  21841. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21842. //
  21843. // }
  21844. // if item.ChrgitmLv == "3" {
  21845. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21846. // }
  21847. //
  21848. // }
  21849. //
  21850. // if item.MedChrgitmType == "03" { //检查费
  21851. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21852. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21853. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21854. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21855. // if item.ChrgitmLv == "1" {
  21856. //
  21857. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21858. //
  21859. // }
  21860. // if item.ChrgitmLv == "2" {
  21861. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21862. //
  21863. // }
  21864. // if item.ChrgitmLv == "3" {
  21865. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21866. // }
  21867. // }
  21868. //
  21869. // if item.MedChrgitmType == "04" { //化验费
  21870. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21871. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21872. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21873. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21874. // if item.ChrgitmLv == "1" {
  21875. //
  21876. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21877. //
  21878. // }
  21879. // if item.ChrgitmLv == "2" {
  21880. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21881. //
  21882. // }
  21883. // if item.ChrgitmLv == "3" {
  21884. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21885. // }
  21886. // }
  21887. //
  21888. // if item.MedChrgitmType == "05" { //治疗费
  21889. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21890. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21891. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21892. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21893. // if item.ChrgitmLv == "1" {
  21894. //
  21895. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21896. //
  21897. // }
  21898. // if item.ChrgitmLv == "2" {
  21899. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21900. //
  21901. // }
  21902. // if item.ChrgitmLv == "3" {
  21903. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21904. // }
  21905. // }
  21906. //
  21907. // if item.MedChrgitmType == "06" { //手术费
  21908. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21909. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21910. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21911. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21912. //
  21913. // if item.ChrgitmLv == "1" {
  21914. //
  21915. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21916. //
  21917. // }
  21918. // if item.ChrgitmLv == "2" {
  21919. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21920. //
  21921. // }
  21922. // if item.ChrgitmLv == "3" {
  21923. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21924. // }
  21925. // }
  21926. //
  21927. // if item.MedChrgitmType == "07" { //手术费
  21928. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21929. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21930. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21931. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21932. //
  21933. // if item.ChrgitmLv == "1" {
  21934. //
  21935. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21936. //
  21937. // }
  21938. // if item.ChrgitmLv == "2" {
  21939. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21940. //
  21941. // }
  21942. // if item.ChrgitmLv == "3" {
  21943. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21944. // }
  21945. // }
  21946. //
  21947. // if item.MedChrgitmType == "08" { //材料费
  21948. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21949. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21950. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21951. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21952. // if item.ChrgitmLv == "1" {
  21953. //
  21954. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21955. //
  21956. // }
  21957. // if item.ChrgitmLv == "2" {
  21958. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21959. //
  21960. // }
  21961. // if item.ChrgitmLv == "3" {
  21962. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21963. // }
  21964. // }
  21965. // if item.MedChrgitmType == "09" { //西药费
  21966. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21967. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21968. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21969. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21970. // if item.ChrgitmLv == "1" {
  21971. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21972. // }
  21973. // if item.ChrgitmLv == "2" {
  21974. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21975. // }
  21976. // if item.ChrgitmLv == "3" {
  21977. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21978. // }
  21979. // }
  21980. // if item.MedChrgitmType == "10" { //中药饮片
  21981. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21982. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21983. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21984. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21985. // if item.ChrgitmLv == "1" {
  21986. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21987. // }
  21988. // if item.ChrgitmLv == "2" {
  21989. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21990. // }
  21991. // if item.ChrgitmLv == "3" {
  21992. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21993. // }
  21994. // }
  21995. //
  21996. // if item.MedChrgitmType == "11" { //中成费
  21997. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21998. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21999. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22000. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22001. // if item.ChrgitmLv == "1" {
  22002. //
  22003. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22004. //
  22005. // }
  22006. // if item.ChrgitmLv == "2" {
  22007. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22008. //
  22009. // }
  22010. // if item.ChrgitmLv == "3" {
  22011. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22012. // }
  22013. // }
  22014. //
  22015. // if item.MedChrgitmType == "12" { //中成费
  22016. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22017. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22018. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22019. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22020. // if item.ChrgitmLv == "1" {
  22021. //
  22022. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22023. //
  22024. // }
  22025. // if item.ChrgitmLv == "2" {
  22026. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22027. //
  22028. // }
  22029. // if item.ChrgitmLv == "3" {
  22030. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22031. // }
  22032. // }
  22033. //
  22034. // if item.MedChrgitmType == "13" { //中成费
  22035. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22036. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22037. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22038. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22039. // if item.ChrgitmLv == "1" {
  22040. //
  22041. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22042. //
  22043. // }
  22044. // if item.ChrgitmLv == "2" {
  22045. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22046. //
  22047. // }
  22048. // if item.ChrgitmLv == "3" {
  22049. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22050. // }
  22051. // }
  22052. //
  22053. // if item.MedChrgitmType == "14" { //其他费
  22054. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22055. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22056. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22057. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22058. // if item.ChrgitmLv == "1" {
  22059. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22060. //
  22061. // }
  22062. // if item.ChrgitmLv == "2" {
  22063. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22064. //
  22065. // }
  22066. // if item.ChrgitmLv == "3" {
  22067. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22068. // }
  22069. // }
  22070. //
  22071. // }
  22072. //
  22073. // var iteminfoStructs []service.IteminfoStruct
  22074. //
  22075. // if bedCostTotal != 0 {
  22076. // iteminfo.MedChrgitm = "01"
  22077. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22078. // iteminfo.Amt = bedCostTotal
  22079. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  22080. // iteminfo.ClabAmt = bed_clab_amt
  22081. // iteminfo.OthAmt = bed_other_amt
  22082. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22083. // }
  22084. //
  22085. // if examineCostTotal != 0 {
  22086. // iteminfo.MedChrgitm = "02"
  22087. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  22088. // iteminfo.Amt = examineCostTotal
  22089. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  22090. // iteminfo.ClabAmt = examine_clab_amt
  22091. // iteminfo.OthAmt = examine_other_amt
  22092. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22093. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22094. // }
  22095. //
  22096. // if checkCostTotal != 0 {
  22097. // iteminfo.MedChrgitm = "03"
  22098. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  22099. // iteminfo.Amt = checkCostTotal
  22100. // iteminfo.ClaaSumfee = check_claa_sunmfee
  22101. // iteminfo.ClabAmt = check_clab_amt
  22102. // iteminfo.OthAmt = check_other_amt
  22103. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22104. //
  22105. // }
  22106. //
  22107. // if laboratoryCostTotal != 0 {
  22108. // iteminfo.MedChrgitm = "04"
  22109. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  22110. // iteminfo.Amt = laboratoryCostTotal
  22111. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  22112. // iteminfo.ClabAmt = laboratory_clab_amt
  22113. // iteminfo.OthAmt = laboratory_other_amt
  22114. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22115. //
  22116. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22117. //
  22118. // }
  22119. //
  22120. // if treatCostTotal != 0 {
  22121. // iteminfo.MedChrgitm = "05"
  22122. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  22123. // iteminfo.Amt = treatCostTotal
  22124. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  22125. // iteminfo.ClabAmt = treat_clab_amt
  22126. // iteminfo.OthAmt = treat_other_amt
  22127. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22128. // //(struct4101.IteminfoStruct, iteminfo)
  22129. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22130. // }
  22131. //
  22132. // if operationCostTotal != 0 {
  22133. // iteminfo.MedChrgitm = "06"
  22134. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22135. // iteminfo.Amt = operationCostTotal
  22136. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  22137. // iteminfo.ClabAmt = operation_clab_amt
  22138. // iteminfo.OthAmt = operation_other_amt
  22139. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22140. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22141. // }
  22142. //
  22143. // if nursingCostTotal != 0 {
  22144. // iteminfo.MedChrgitm = "07"
  22145. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  22146. // iteminfo.Amt = nursingCostTotal
  22147. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  22148. // iteminfo.ClabAmt = nursing_clab_amt
  22149. // iteminfo.OthAmt = nursing_other_amt
  22150. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22151. // }
  22152. //
  22153. // if materialCostTotal != 0 {
  22154. // iteminfo.MedChrgitm = "08"
  22155. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  22156. // iteminfo.Amt = materialCostTotal
  22157. // iteminfo.ClaaSumfee = material_claa_sunmfee
  22158. // iteminfo.ClabAmt = material_clab_amt
  22159. // iteminfo.OthAmt = material_other_amt
  22160. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22161. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22162. // }
  22163. //
  22164. // if westernMedicineCostTotal != 0 {
  22165. // iteminfo.MedChrgitm = "09"
  22166. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22167. // iteminfo.Amt = westernMedicineCostTotal
  22168. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22169. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22170. // iteminfo.OthAmt = westernMedicine_other_amt
  22171. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22172. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22173. //
  22174. // }
  22175. //
  22176. // if chineseMedicineCostTotal != 0 {
  22177. // iteminfo.MedChrgitm = "10"
  22178. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  22179. // iteminfo.Amt = chineseMedicineCostTotal
  22180. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  22181. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  22182. // iteminfo.OthAmt = chinese_medicine_other_amt
  22183. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22184. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22185. //
  22186. // }
  22187. //
  22188. // if chineseTraditionalMedicineCostTotal != 0 {
  22189. // iteminfo.MedChrgitm = "11"
  22190. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22191. // iteminfo.Amt = westernMedicineCostTotal
  22192. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22193. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22194. // iteminfo.OthAmt = westernMedicine_other_amt
  22195. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22196. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22197. //
  22198. // }
  22199. //
  22200. // if commonlyTreatmentCostTotal != 0 {
  22201. // iteminfo.MedChrgitm = "12"
  22202. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  22203. // iteminfo.Amt = commonlyTreatmentCostTotal
  22204. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  22205. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  22206. // iteminfo.OthAmt = commonly_treatment_other_amt
  22207. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22208. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22209. //
  22210. // }
  22211. //
  22212. // if registerCostTotal != 0 {
  22213. // iteminfo.MedChrgitm = "13"
  22214. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  22215. // iteminfo.Amt = registerCostTotal
  22216. // iteminfo.ClaaSumfee = register_claa_sunmfee
  22217. // iteminfo.ClabAmt = register_clab_amt
  22218. // iteminfo.OthAmt = register_other_amt
  22219. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22220. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22221. //
  22222. // }
  22223. //
  22224. // if otherCostTotal != 0 {
  22225. // iteminfo.MedChrgitm = "14"
  22226. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  22227. // iteminfo.Amt = otherCostTotal
  22228. // iteminfo.ClaaSumfee = other_claa_sunmfee
  22229. // iteminfo.ClabAmt = other_clab_amt
  22230. // iteminfo.OthAmt = other_other_amt
  22231. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22232. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22233. //
  22234. // }
  22235. // struct4101.IteminfoStruct = iteminfoStructs
  22236. // time_arr := strings.Split(order.SetlTime, " ")
  22237. // struct4101.AdmTime = time_arr[0]
  22238. // struct4101.AdmEndTime = time_arr[0]
  22239. //
  22240. // struct4101.DoctorName = doctor.UserName
  22241. // struct4101.DoctorCode = doctor.DoctorNumber
  22242. //
  22243. // struct4101.Ntly = "中国"
  22244. // struct4101.AdmCaty = "A03.06"
  22245. // var res ResultSeventeen
  22246. // if miConfig.MdtrtareaAdmvs == "421300" {
  22247. // data := make(map[string]interface{})
  22248. // data["struct4101"] = struct4101
  22249. // data["secret_key"] = miConfig.SecretKey
  22250. // data["org_name"] = miConfig.OrgName
  22251. // data["opera"] = curRoles.UserName
  22252. // data["code"] = miConfig.Code
  22253. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22254. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22255. //
  22256. // client := &http.Client{}
  22257. // bytesData, _ := json.Marshal(data)
  22258. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22259. // resp, _ := client.Do(req)
  22260. // defer resp.Body.Close()
  22261. // body, ioErr := ioutil.ReadAll(resp.Body)
  22262. // if ioErr != nil {
  22263. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22264. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22265. // return
  22266. // }
  22267. // var respJSON map[string]interface{}
  22268. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22269. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22271. // return
  22272. // }
  22273. //
  22274. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22275. // userJSONBytes, _ := json.Marshal(respJSON)
  22276. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22277. // utils.ErrorLog("解析失败:%v", err)
  22278. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22279. // adminUser := c.GetAdminUserInfo()
  22280. // errlog := &models.HisOrderError{
  22281. // UserOrgId: adminUser.CurrentOrgId,
  22282. // Ctime: time.Now().Unix(),
  22283. // Mtime: time.Now().Unix(),
  22284. // ErrMsg: res.ErrMsg + "解析失败",
  22285. // Status: 1,
  22286. // PatientId: order_id,
  22287. // Stage: 10088,
  22288. // }
  22289. // service.CreateErrMsgLog(errlog)
  22290. // continue
  22291. // }
  22292. //
  22293. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  22294. // data := make(map[string]interface{})
  22295. // data["struct4101"] = struct4101
  22296. // data["secret_key"] = miConfig.SecretKey
  22297. // data["org_name"] = miConfig.OrgName
  22298. // data["opera"] = curRoles.UserName
  22299. // data["code"] = miConfig.Code
  22300. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22301. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22302. //
  22303. // client := &http.Client{}
  22304. // bytesData, _ := json.Marshal(data)
  22305. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22306. // resp, _ := client.Do(req)
  22307. // defer resp.Body.Close()
  22308. // body, ioErr := ioutil.ReadAll(resp.Body)
  22309. // if ioErr != nil {
  22310. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22311. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22312. // return
  22313. // }
  22314. // var respJSON map[string]interface{}
  22315. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22316. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22318. // return
  22319. // }
  22320. //
  22321. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22322. // userJSONBytes, _ := json.Marshal(respJSON)
  22323. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22324. // utils.ErrorLog("解析失败:%v", err)
  22325. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22326. // adminUser := c.GetAdminUserInfo()
  22327. // errlog := &models.HisOrderError{
  22328. // UserOrgId: adminUser.CurrentOrgId,
  22329. // Ctime: time.Now().Unix(),
  22330. // Mtime: time.Now().Unix(),
  22331. // ErrMsg: res.ErrMsg + "解析失败",
  22332. // Status: 1,
  22333. // PatientId: order_id,
  22334. // Stage: 10088,
  22335. // }
  22336. // service.CreateErrMsgLog(errlog)
  22337. // continue
  22338. // }
  22339. //
  22340. // } else {
  22341. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  22342. // fmt.Println(result)
  22343. //
  22344. // var dat map[string]interface{}
  22345. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22346. // fmt.Println(dat)
  22347. // } else {
  22348. // fmt.Println(err)
  22349. // }
  22350. // userJSONBytes, _ := json.Marshal(dat)
  22351. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22352. // utils.ErrorLog("解析失败:%v", err)
  22353. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22354. // adminUser := c.GetAdminUserInfo()
  22355. // errlog := &models.HisOrderError{
  22356. // UserOrgId: adminUser.CurrentOrgId,
  22357. // Ctime: time.Now().Unix(),
  22358. // Mtime: time.Now().Unix(),
  22359. // ErrMsg: res.ErrMsg + "解析失败",
  22360. // Status: 1,
  22361. // PatientId: order_id,
  22362. // Stage: 10106,
  22363. // }
  22364. // service.CreateErrMsgLog(errlog)
  22365. // continue
  22366. // }
  22367. // }
  22368. //
  22369. // if res.Infcode != 0 {
  22370. // adminUser := c.GetAdminUserInfo()
  22371. // errlog := &models.HisOrderError{
  22372. // UserOrgId: adminUser.CurrentOrgId,
  22373. // Ctime: time.Now().Unix(),
  22374. // Mtime: time.Now().Unix(),
  22375. // ErrMsg: res.ErrMsg,
  22376. // Status: 1,
  22377. // PatientId: order_id,
  22378. // Stage: 10106,
  22379. // }
  22380. // service.CreateErrMsgLog(errlog)
  22381. // continue
  22382. // } else {
  22383. // hisFundSettleListResult := &models.HisFundSettleListResult{
  22384. // Number: res.Output.SetlListId,
  22385. // Status: 1,
  22386. // Ctime: time.Now().Unix(),
  22387. // Mtime: time.Now().Unix(),
  22388. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  22389. // IsUpload: 1,
  22390. // OrderId: order_id,
  22391. // }
  22392. // service.CreateUploadRecord(hisFundSettleListResult)
  22393. // continue
  22394. // }
  22395. // }
  22396. //}
  22397. func (c *HisApiController) GetOrgInfo() {
  22398. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  22399. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  22400. }
  22401. func (c *HisApiController) GetHisPatientInfo() {
  22402. medical_insurance_card := c.GetString("medical_insurance_card")
  22403. id_card_type, _ := c.GetInt64("id_card_type")
  22404. id_card := c.GetString("id_card")
  22405. adminInfo := c.GetAdminUserInfo()
  22406. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22407. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22408. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  22409. IdCardNo := ""
  22410. if id_card_type == 1 {
  22411. IdCardNo = medical_insurance_card
  22412. } else if id_card_type == 2 {
  22413. IdCardNo = id_card
  22414. }
  22415. if config.IsOpen == 1 {
  22416. 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
  22417. resp, requestErr := http.Get(api)
  22418. if requestErr != nil {
  22419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22420. return
  22421. }
  22422. defer resp.Body.Close()
  22423. body, ioErr := ioutil.ReadAll(resp.Body)
  22424. if ioErr != nil {
  22425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22427. return
  22428. }
  22429. var respJSON map[string]interface{}
  22430. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22433. return
  22434. }
  22435. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22436. userJSONBytes, _ := json.Marshal(userJSON)
  22437. var res ResultTwo
  22438. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22439. utils.ErrorLog("解析失败:%v", err)
  22440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22441. return
  22442. }
  22443. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22444. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22445. infoStr := string(Iinfos)
  22446. idetinfoStr := string(Idetinfos)
  22447. if res.Infcode == 0 {
  22448. his := models.VMHisPatient{
  22449. Status: 1,
  22450. Ctime: time.Now().Unix(),
  22451. Mtime: time.Now().Unix(),
  22452. PsnNo: res.Output.Baseinfo.PsnNo,
  22453. PsnCertType: res.Output.Baseinfo.PsnCertType,
  22454. Certno: res.Output.Baseinfo.Certno,
  22455. PsnName: res.Output.Baseinfo.PsnName,
  22456. Gend: res.Output.Baseinfo.Gend,
  22457. Naty: res.Output.Baseinfo.Naty,
  22458. Iinfo: infoStr,
  22459. Idetinfo: idetinfoStr,
  22460. UserOrgId: adminInfo.CurrentOrgId,
  22461. IsReturn: 1,
  22462. IdCardType: id_card_type,
  22463. }
  22464. c.ServeSuccessJSON(map[string]interface{}{
  22465. "info": his,
  22466. })
  22467. } else {
  22468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  22469. return
  22470. }
  22471. }
  22472. }
  22473. //func GetBasBaseInfo() (jsonStr string, err error) {
  22474. //
  22475. // handle := syscall.NewLazyDLL("SSCard.dll")
  22476. // add := handle.NewProc("ReadCardBas")
  22477. // str := make([]byte, 1024)
  22478. // str1 := make([]byte, 1024)
  22479. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22480. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  22481. //
  22482. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  22483. //
  22484. // fmt.Println("> Add(4,5)的结果为:", ret)
  22485. // handle.Release()
  22486. //
  22487. // return "", nil
  22488. //
  22489. //}
  22490. //func GetQRBaseInfo() (jsonStr string, err error) {
  22491. // handle := syscall.LoadDLL("SSCard.dll")
  22492. // ReadCardBas := handle.FindProc("GetQRBase")
  22493. //
  22494. // str := make([]byte, 256)
  22495. // str1 := make([]byte, 256)
  22496. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22497. //
  22498. // fmt.Println(string(str))
  22499. // fmt.Println(r)
  22500. // return string(str), nil
  22501. //}
  22502. //func CardInit() int {
  22503. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  22504. // add := DllTestDef.MustFindProc("Init")
  22505. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22506. // if err != nil {
  22507. // fmt.Println("SSCard的运算结果为:", ret)
  22508. // }
  22509. // result := int(ret)
  22510. // return result
  22511. //}
  22512. //func CardInit() int {
  22513. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22514. // if err != nil {
  22515. // fmt.Println("SSCard的运算结果为:", ret)
  22516. // }
  22517. // fmt.Println(err)
  22518. // result := int(ret)
  22519. // return result
  22520. //}
  22521. func IntPtr(n int) uintptr {
  22522. return uintptr(n)
  22523. }
  22524. func StrPtr(s string) uintptr {
  22525. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  22526. }
  22527. type Result2001 struct {
  22528. Cainfo interface{} `json:"cainfo"`
  22529. ErrMsg string `json:"err_msg"`
  22530. InfRefmsgid string `json:"inf_refmsgid"`
  22531. Infcode int64 `json:"infcode"`
  22532. Output struct {
  22533. Trtinfo struct {
  22534. PsnNo string `json:"psn_no"`
  22535. TrtChkType string `json:"trt_chk_type"`
  22536. FundPayType string `json:"fund_pay_type"`
  22537. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22538. Begndate string `json:"begndate"`
  22539. Enddate string `json:"enddate"`
  22540. TrtChkRslt string `json:"trt_chk_rslt"`
  22541. } `json:"trtinfo"`
  22542. } `json:"output"`
  22543. RefmsgTime string `json:"refmsg_time"`
  22544. RespondTime string `json:"respond_time"`
  22545. Signtype interface{} `json:"signtype"`
  22546. WarnMsg interface{} `json:"warn_msg"`
  22547. }
  22548. type Result2001Org10265 struct {
  22549. Cainfo interface{} `json:"cainfo"`
  22550. ErrMsg string `json:"err_msg"`
  22551. InfRefmsgid string `json:"inf_refmsgid"`
  22552. Infcode string `json:"infcode"`
  22553. Output struct {
  22554. Trtinfo struct {
  22555. PsnNo string `json:"psn_no"`
  22556. TrtChkType string `json:"trt_chk_type"`
  22557. FundPayType string `json:"fund_pay_type"`
  22558. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22559. Begndate string `json:"begndate"`
  22560. Enddate string `json:"enddate"`
  22561. TrtChkRslt string `json:"trt_chk_rslt"`
  22562. } `json:"trtinfo"`
  22563. } `json:"output"`
  22564. RefmsgTime string `json:"refmsg_time"`
  22565. RespondTime string `json:"respond_time"`
  22566. Signtype interface{} `json:"signtype"`
  22567. WarnMsg interface{} `json:"warn_msg"`
  22568. }
  22569. type ResultTwo struct {
  22570. ErrMsg string `json:"err_msg"`
  22571. InfRefmsgid string `json:"inf_refmsgid"`
  22572. Infcode int64 `json:"infcode"`
  22573. Output struct {
  22574. Baseinfo struct {
  22575. //Brdy string `json:"brdy"`
  22576. Certno string `json:"certno"`
  22577. Gend string `json:"gend"`
  22578. Naty string `json:"naty"`
  22579. PsnCertType string `json:"psn_cert_type"`
  22580. PsnName string `json:"psn_name"`
  22581. PsnNo string `json:"psn_no"`
  22582. } `json:"baseinfo"`
  22583. Idetinfo []interface{} `json:"idetinfo"`
  22584. Iinfo []struct {
  22585. Balc float64 `json:"balc"`
  22586. CvlservFlag string `json:"cvlserv_flag"`
  22587. EmpName string `json:"emp_name"`
  22588. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22589. Insutype string `json:"insutype"`
  22590. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22591. //PausInsuDate string `json:"paus_insu_date"`
  22592. //PsnInsuDate string `json:"psn_insu_date"`
  22593. PsnInsuStas string `json:"psn_insu_stas"`
  22594. PsnType string `json:"psn_type"`
  22595. } `json:"insuinfo"`
  22596. } `json:"output"`
  22597. RefmsgTime string `json:"refmsg_time"`
  22598. RespondTime string `json:"respond_time"`
  22599. Signtype interface{} `json:"signtype"`
  22600. WarnInfo interface{} `json:"warn_info"`
  22601. }
  22602. type ResultTwo10265 struct {
  22603. ErrMsg string `json:"err_msg"`
  22604. InfRefmsgid string `json:"inf_refmsgid"`
  22605. Infcode string `json:"infcode"`
  22606. Output struct {
  22607. Baseinfo struct {
  22608. //Brdy string `json:"brdy"`
  22609. Certno string `json:"certno"`
  22610. Gend string `json:"gend"`
  22611. Naty string `json:"naty"`
  22612. PsnCertType string `json:"psn_cert_type"`
  22613. PsnName string `json:"psn_name"`
  22614. PsnNo string `json:"psn_no"`
  22615. } `json:"baseinfo"`
  22616. Idetinfo []interface{} `json:"idetinfo"`
  22617. Iinfo []struct {
  22618. Balc float64 `json:"balc"`
  22619. CvlservFlag string `json:"cvlserv_flag"`
  22620. EmpName string `json:"emp_name"`
  22621. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22622. Insutype string `json:"insutype"`
  22623. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22624. PsnInsuStas string `json:"psn_insu_stas"`
  22625. PsnType string `json:"psn_type"`
  22626. } `json:"insuinfo"`
  22627. } `json:"output"`
  22628. RefmsgTime string `json:"refmsg_time"`
  22629. RespondTime string `json:"respond_time"`
  22630. Signtype interface{} `json:"signtype"`
  22631. WarnInfo interface{} `json:"warn_info"`
  22632. }
  22633. type ResultThree struct {
  22634. Cainfo interface{} `json:"cainfo"`
  22635. ErrMsg string `json:"err_msg"`
  22636. InfRefmsgid string `json:"inf_refmsgid"`
  22637. Infcode int64 `json:"infcode"`
  22638. Output struct {
  22639. Data struct {
  22640. IptOtpNo string `json:"ipt_otp_no"`
  22641. MdtrtID string `json:"mdtrt_id"`
  22642. PsnNo string `json:"psn_no"`
  22643. } `json:"data"`
  22644. } `json:"output"`
  22645. RefmsgTime string `json:"refmsg_time"`
  22646. RespondTime string `json:"respond_time"`
  22647. Signtype interface{} `json:"signtype"`
  22648. WarnMsg interface{} `json:"warn_msg"`
  22649. }
  22650. type ResultThree10265 struct {
  22651. Cainfo interface{} `json:"cainfo"`
  22652. ErrMsg string `json:"err_msg"`
  22653. InfRefmsgid string `json:"inf_refmsgid"`
  22654. Infcode string `json:"infcode"`
  22655. Output struct {
  22656. Data struct {
  22657. IptOtpNo string `json:"ipt_otp_no"`
  22658. MdtrtID string `json:"mdtrt_id"`
  22659. PsnNo string `json:"psn_no"`
  22660. } `json:"data"`
  22661. } `json:"output"`
  22662. RefmsgTime string `json:"refmsg_time"`
  22663. RespondTime string `json:"respond_time"`
  22664. Signtype interface{} `json:"signtype"`
  22665. WarnMsg interface{} `json:"warn_msg"`
  22666. }
  22667. type ResultFour struct {
  22668. Cainfo string `json:"cainfo"`
  22669. ErrMsg string `json:"err_msg"`
  22670. InfRefmsgid string `json:"inf_refmsgid"`
  22671. Infcode int64 `json:"infcode"`
  22672. Output struct {
  22673. Result []struct {
  22674. BasMednFlag string `json:"bas_medn_flag"`
  22675. ChldMedcFlag string `json:"chld_medc_flag"`
  22676. ChrgitmLv string `json:"chrgitm_lv"`
  22677. Cnt float64 `json:"cnt"`
  22678. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22679. DrtReimFlag string `json:"drt_reim_flag"`
  22680. FeedetlSn string `json:"feedetl_sn"`
  22681. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22682. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22683. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22684. ListSpItemFlag string `json:"list_sp_item_flag"`
  22685. LmtUsedFlag string `json:"lmt_used_flag"`
  22686. MedChrgitmType string `json:"med_chrgitm_type"`
  22687. Memo string `json:"memo"`
  22688. OverlmtAmt float64 `json:"overlmt_amt"`
  22689. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22690. Pric float64 `json:"pric"`
  22691. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22692. SelfpayProp float64 `json:"selfpay_prop"`
  22693. } `json:"result"`
  22694. } `json:"output"`
  22695. RefmsgTime string `json:"refmsg_time"`
  22696. RespondTime string `json:"respond_time"`
  22697. Signtype string `json:"signtype"`
  22698. WarnMsg string `json:"warn_msg"`
  22699. }
  22700. type ResultFour10265 struct {
  22701. Cainfo string `json:"cainfo"`
  22702. ErrMsg string `json:"err_msg"`
  22703. InfRefmsgid string `json:"inf_refmsgid"`
  22704. Infcode string `json:"infcode"`
  22705. Output struct {
  22706. Result []struct {
  22707. BasMednFlag string `json:"bas_medn_flag"`
  22708. ChldMedcFlag string `json:"chld_medc_flag"`
  22709. ChrgitmLv string `json:"chrgitm_lv"`
  22710. Cnt float64 `json:"cnt"`
  22711. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22712. DrtReimFlag string `json:"drt_reim_flag"`
  22713. FeedetlSn string `json:"feedetl_sn"`
  22714. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22715. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22716. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22717. ListSpItemFlag string `json:"list_sp_item_flag"`
  22718. LmtUsedFlag string `json:"lmt_used_flag"`
  22719. MedChrgitmType string `json:"med_chrgitm_type"`
  22720. Memo string `json:"memo"`
  22721. OverlmtAmt float64 `json:"overlmt_amt"`
  22722. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22723. Pric float64 `json:"pric"`
  22724. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22725. SelfpayProp float64 `json:"selfpay_prop"`
  22726. } `json:"result"`
  22727. } `json:"output"`
  22728. RefmsgTime string `json:"refmsg_time"`
  22729. RespondTime string `json:"respond_time"`
  22730. Signtype string `json:"signtype"`
  22731. WarnMsg string `json:"warn_msg"`
  22732. }
  22733. type ResultMemo struct {
  22734. InsuAdmdvs string `json:"insuAdmdvs"`
  22735. }
  22736. // [{"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}]
  22737. type ResultIDInfo struct {
  22738. Begntime string `json:"begntime"`
  22739. Endtime string `json:"endtime"`
  22740. Memo string `json:"memo"`
  22741. }
  22742. type ResultFive struct {
  22743. Balc float64 `json:"balc"`
  22744. CvlservFlag string `json:"cvlserv_flag"`
  22745. EmpName string `json:"emp_name"`
  22746. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22747. Insutype string `json:"insutype"`
  22748. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22749. PausInsuDate string `json:"paus_insu_date"`
  22750. PsnInsuDate string `json:"psn_insu_date"`
  22751. PsnInsuStas string `json:"psn_insu_stas"`
  22752. PsnType string `json:"psn_type"`
  22753. }
  22754. type ResultSix struct {
  22755. Cainfo interface{} `json:"cainfo"`
  22756. ErrMsg string `json:"err_msg"`
  22757. InfRefmsgid string `json:"inf_refmsgid"`
  22758. Infcode int64 `json:"infcode"`
  22759. Output struct {
  22760. } `json:"output"`
  22761. RefmsgTime string `json:"refmsg_time"`
  22762. RespondTime string `json:"respond_time"`
  22763. Signtype interface{} `json:"signtype"`
  22764. WarnMsg interface{} `json:"warn_msg"`
  22765. }
  22766. type ResultSix3103 struct {
  22767. Cainfo interface{} `json:"cainfo"`
  22768. ErrMsg string `json:"err_msg"`
  22769. InfRefmsgid string `json:"inf_refmsgid"`
  22770. Infcode int64 `json:"infcode"`
  22771. RefmsgTime string `json:"refmsg_time"`
  22772. RespondTime string `json:"respond_time"`
  22773. Signtype interface{} `json:"signtype"`
  22774. WarnMsg interface{} `json:"warn_msg"`
  22775. }
  22776. type FJ3507Result struct {
  22777. Cainfo interface{} `json:"cainfo"`
  22778. ErrMsg string `json:"err_msg"`
  22779. InfRefmsgid string `json:"inf_refmsgid"`
  22780. Infcode int64 `json:"infcode"`
  22781. Output struct {
  22782. retRslt string `json:"retRslt"`
  22783. msgRslt string `json:"msgRslt"`
  22784. } `json:"output"`
  22785. RefmsgTime string `json:"refmsg_time"`
  22786. RespondTime string `json:"respond_time"`
  22787. Signtype interface{} `json:"signtype"`
  22788. WarnMsg interface{} `json:"warn_msg"`
  22789. }
  22790. type FJ3507ResultFor10188 struct {
  22791. Cainfo interface{} `json:"cainfo"`
  22792. ErrMsg string `json:"err_msg"`
  22793. InfRefmsgid string `json:"inf_refmsgid"`
  22794. Infcode string `json:"infcode"`
  22795. RefmsgTime string `json:"refmsg_time"`
  22796. RespondTime string `json:"respond_time"`
  22797. Signtype interface{} `json:"signtype"`
  22798. WarnMsg interface{} `json:"warn_msg"`
  22799. }
  22800. type Result2406 struct {
  22801. Cainfo interface{} `json:"cainfo"`
  22802. ErrMsg string `json:"err_msg"`
  22803. InfRefmsgid string `json:"inf_refmsgid"`
  22804. Infcode int64 `json:"infcode"`
  22805. Output struct {
  22806. Result struct {
  22807. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22808. } `json:"result"`
  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 GZResultSix struct {
  22816. Cainfo interface{} `json:"cainfo"`
  22817. ErrMsg string `json:"err_msg"`
  22818. InfRefmsgid string `json:"inf_refmsgid"`
  22819. Infcode int64 `json:"infcode"`
  22820. Output string `json:"output"`
  22821. RefmsgTime string `json:"refmsg_time"`
  22822. RespondTime string `json:"respond_time"`
  22823. Signtype interface{} `json:"signtype"`
  22824. WarnMsg interface{} `json:"warn_msg"`
  22825. }
  22826. type ResultSix10265 struct {
  22827. Cainfo interface{} `json:"cainfo"`
  22828. ErrMsg string `json:"err_msg"`
  22829. InfRefmsgid string `json:"inf_refmsgid"`
  22830. Infcode string `json:"infcode"`
  22831. Output struct {
  22832. } `json:"output"`
  22833. RefmsgTime string `json:"refmsg_time"`
  22834. RespondTime string `json:"respond_time"`
  22835. Signtype interface{} `json:"signtype"`
  22836. WarnMsg interface{} `json:"warn_msg"`
  22837. }
  22838. type ResultSeven struct {
  22839. Cainfo string `json:"cainfo"`
  22840. ErrMsg string `json:"err_msg"`
  22841. InfRefmsgid string `json:"inf_refmsgid"`
  22842. Infcode int64 `json:"infcode"`
  22843. Output struct {
  22844. Setlinfo struct {
  22845. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22846. AcctPay float64 `json:"acct_pay"`
  22847. ActPayDedc float64 `json:"act_pay_dedc"`
  22848. Age float64 `json:"age"`
  22849. Balc float64 `json:"balc"`
  22850. Certno string `json:"certno"`
  22851. ClrOptins string `json:"clr_optins"`
  22852. ClrType string `json:"clr_type"`
  22853. ClrWay string `json:"clr_way"`
  22854. CvlservFlag string `json:"cvlserv_flag"`
  22855. CvlservPay float64 `json:"cvlserv_pay"`
  22856. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22857. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22858. Gend string `json:"gend"`
  22859. HifesPay float64 `json:"hifes_pay"`
  22860. HifmiPay float64 `json:"hifmi_pay"`
  22861. HifpPay float64 `json:"hifp_pay"`
  22862. HospPartAmt float64 `json:"hosp_part_amt"`
  22863. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22864. Insutype string `json:"insutype"`
  22865. MafPay float64 `json:"maf_pay"`
  22866. MdtrtCertType string `json:"mdtrt_cert_type"`
  22867. HifobPay float64 `json:"hifob_pay"`
  22868. MdtrtID string `json:"mdtrt_id"`
  22869. MedType string `json:"med_type"`
  22870. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22871. MedinsSetlID string `json:"medins_setl_id"`
  22872. Naty string `json:"naty"`
  22873. OthPay float64 `json:"oth_pay"`
  22874. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22875. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22876. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22877. PsnCashPay float64 `json:"psn_cash_pay"`
  22878. PsnCertType string `json:"psn_cert_type"`
  22879. PsnName string `json:"psn_name"`
  22880. PsnNo string `json:"psn_no"`
  22881. PsnPartAmt float64 `json:"psn_part_amt"`
  22882. PsnType string `json:"psn_type"`
  22883. SetlID string `json:"setl_id"`
  22884. SetlTime string `json:"setl_time"`
  22885. } `json:"setlinfo"`
  22886. Setldetail interface{} `json:"setldetail"`
  22887. } `json:"output"`
  22888. RefmsgTime string `json:"refmsg_time"`
  22889. RespondTime string `json:"respond_time"`
  22890. Signtype interface{} `json:"signtype"`
  22891. WarnMsg interface{} `json:"warn_msg"`
  22892. }
  22893. type ResultSevenAH struct {
  22894. Cainfo string `json:"cainfo"`
  22895. ErrMsg string `json:"err_msg"`
  22896. InfRefmsgid string `json:"inf_refmsgid"`
  22897. Infcode int64 `json:"infcode"`
  22898. Output struct {
  22899. Setlinfo struct {
  22900. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22901. AcctPay float64 `json:"acct_pay"`
  22902. ActPayDedc float64 `json:"act_pay_dedc"`
  22903. Age float64 `json:"age"`
  22904. Balc float64 `json:"balc"`
  22905. Certno string `json:"certno"`
  22906. ClrOptins string `json:"clr_optins"`
  22907. ClrType string `json:"clr_type"`
  22908. ClrWay string `json:"clr_way"`
  22909. CvlservFlag string `json:"cvlserv_flag"`
  22910. CvlservPay float64 `json:"cvlserv_pay"`
  22911. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22912. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22913. Gend string `json:"gend"`
  22914. HifesPay float64 `json:"hifes_pay"`
  22915. HifmiPay float64 `json:"hifmi_pay"`
  22916. HifpPay float64 `json:"hifp_pay"`
  22917. HospPartAmt float64 `json:"hosp_part_amt"`
  22918. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22919. Insutype string `json:"insutype"`
  22920. MafPay float64 `json:"maf_pay"`
  22921. MdtrtCertType string `json:"mdtrt_cert_type"`
  22922. HifobPay float64 `json:"hifob_pay"`
  22923. MdtrtID string `json:"mdtrt_id"`
  22924. MedType string `json:"med_type"`
  22925. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22926. MedinsSetlID string `json:"medins_setl_id"`
  22927. Naty string `json:"naty"`
  22928. OthPay float64 `json:"oth_pay"`
  22929. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22930. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22931. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22932. PsnCashPay float64 `json:"psn_cash_pay"`
  22933. PsnCertType string `json:"psn_cert_type"`
  22934. PsnName string `json:"psn_name"`
  22935. PsnNo string `json:"psn_no"`
  22936. PsnPartAmt float64 `json:"psn_part_amt"`
  22937. PsnType string `json:"psn_type"`
  22938. SetlID string `json:"setl_id"`
  22939. SetlTime int64 `json:"setl_time"`
  22940. } `json:"setlinfo"`
  22941. Setldetail interface{} `json:"setldetail"`
  22942. } `json:"output"`
  22943. RefmsgTime string `json:"refmsg_time"`
  22944. RespondTime string `json:"respond_time"`
  22945. Signtype interface{} `json:"signtype"`
  22946. WarnMsg interface{} `json:"warn_msg"`
  22947. }
  22948. type ResultSeven10265 struct {
  22949. Cainfo string `json:"cainfo"`
  22950. ErrMsg string `json:"err_msg"`
  22951. InfRefmsgid string `json:"inf_refmsgid"`
  22952. Infcode string `json:"infcode"`
  22953. Output struct {
  22954. Setlinfo struct {
  22955. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22956. AcctPay float64 `json:"acct_pay"`
  22957. ActPayDedc float64 `json:"act_pay_dedc"`
  22958. Age float64 `json:"age"`
  22959. Balc float64 `json:"balc"`
  22960. Certno string `json:"certno"`
  22961. ClrOptins string `json:"clr_optins"`
  22962. ClrType string `json:"clr_type"`
  22963. ClrWay string `json:"clr_way"`
  22964. CvlservFlag string `json:"cvlserv_flag"`
  22965. CvlservPay float64 `json:"cvlserv_pay"`
  22966. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22967. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22968. Gend string `json:"gend"`
  22969. HifesPay float64 `json:"hifes_pay"`
  22970. HifmiPay float64 `json:"hifmi_pay"`
  22971. HifpPay float64 `json:"hifp_pay"`
  22972. HospPartAmt float64 `json:"hosp_part_amt"`
  22973. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22974. Insutype string `json:"insutype"`
  22975. MafPay float64 `json:"maf_pay"`
  22976. MdtrtCertType string `json:"mdtrt_cert_type"`
  22977. HifobPay float64 `json:"hifob_pay"`
  22978. MdtrtID string `json:"mdtrt_id"`
  22979. MedType string `json:"med_type"`
  22980. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22981. MedinsSetlID string `json:"medins_setl_id"`
  22982. Naty string `json:"naty"`
  22983. OthPay float64 `json:"oth_pay"`
  22984. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22985. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22986. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22987. PsnCashPay float64 `json:"psn_cash_pay"`
  22988. PsnCertType string `json:"psn_cert_type"`
  22989. PsnName string `json:"psn_name"`
  22990. PsnNo string `json:"psn_no"`
  22991. PsnPartAmt float64 `json:"psn_part_amt"`
  22992. PsnType string `json:"psn_type"`
  22993. SetlID string `json:"setl_id"`
  22994. SetlTime string `json:"setl_time"`
  22995. } `json:"setlinfo"`
  22996. Setldetail interface{} `json:"setldetail"`
  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 ResultSeven10265Two struct {
  23004. Cainfo string `json:"cainfo"`
  23005. ErrMsg string `json:"err_msg"`
  23006. InfRefmsgid string `json:"inf_refmsgid"`
  23007. Infcode string `json:"infcode"`
  23008. Output struct {
  23009. Setlinfo struct {
  23010. AcctMulaidPay string `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 string `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 string `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 GZResultSeven10265Two 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 string `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 string `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 ResultEight struct {
  23114. Cainfo string `json:"cainfo"`
  23115. ErrMsg string `json:"err_msg"`
  23116. InfRefmsgid string `json:"inf_refmsgid"`
  23117. Infcode int64 `json:"infcode"`
  23118. Output struct {
  23119. Stmtinfo struct {
  23120. SetlOptins string `json:"setl_optins"`
  23121. StmtRslt string `json:"stmt_rslt"`
  23122. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23123. } `json:"stmtinfo"`
  23124. } `json:"output"`
  23125. RefmsgTime string `json:"refmsg_time"`
  23126. RespondTime string `json:"respond_time"`
  23127. Signtype interface{} `json:"signtype"`
  23128. WarnMsg interface{} `json:"warn_msg"`
  23129. }
  23130. type ResultEightFor10188 struct {
  23131. Cainfo string `json:"cainfo"`
  23132. ErrMsg string `json:"err_msg"`
  23133. InfRefmsgid string `json:"inf_refmsgid"`
  23134. Infcode string `json:"infcode"`
  23135. Output struct {
  23136. Stmtinfo struct {
  23137. SetlOptins string `json:"setl_optins"`
  23138. StmtRslt string `json:"stmt_rslt"`
  23139. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23140. } `json:"stmtinfo"`
  23141. } `json:"output"`
  23142. RefmsgTime string `json:"refmsg_time"`
  23143. RespondTime string `json:"respond_time"`
  23144. Signtype interface{} `json:"signtype"`
  23145. WarnMsg interface{} `json:"warn_msg"`
  23146. }
  23147. type ResultNine struct {
  23148. Cainfo string `json:"cainfo"`
  23149. ErrMsg string `json:"err_msg"`
  23150. InfRefmsgid string `json:"inf_refmsgid"`
  23151. Infcode int64 `json:"infcode"`
  23152. Output struct {
  23153. FileQuryNo string `json:"file_qury_no"`
  23154. } `json:"output"`
  23155. RefmsgTime string `json:"refmsg_time"`
  23156. RespondTime string `json:"respond_time"`
  23157. Signtype interface{} `json:"signtype"`
  23158. WarnMsg interface{} `json:"warn_msg"`
  23159. }
  23160. type ResultTen struct {
  23161. Cainfo string `json:"cainfo"`
  23162. ErrMsg string `json:"err_msg"`
  23163. InfRefmsgid string `json:"inf_refmsgid"`
  23164. Infcode int64 `json:"infcode"`
  23165. Output struct {
  23166. Fileinfo struct {
  23167. DldEndtime string `json:"dld_endtime"`
  23168. FileQuryNo string `json:"file_qury_no"`
  23169. Filename string `json:"filename"`
  23170. } `json:"fileinfo"`
  23171. } `json:"output"`
  23172. RefmsgTime string `json:"refmsg_time"`
  23173. RespondTime string `json:"respond_time"`
  23174. Signtype interface{} `json:"signtype"`
  23175. WarnMsg interface{} `json:"warn_msg"`
  23176. }
  23177. type Result5262 struct {
  23178. ErrMsg string `json:"err_msg"`
  23179. InfRefmsgid string `json:"inf_refmsgid"`
  23180. Infcode int64 `json:"infcode"`
  23181. Output struct {
  23182. PageInfo struct {
  23183. Size int `json:"size"`
  23184. RecordCounts int `json:"record_counts"`
  23185. } `json:"page_info"`
  23186. Idetinfo []interface{} `json:"idetinfo"`
  23187. Result []struct {
  23188. SetlID string `json:"setl_id"`
  23189. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23190. MdtrtID string `json:"mdtrt_id"`
  23191. InitSetlID string `json:"init_setl_id,omitempty"`
  23192. PsnNo string `json:"psn_no"`
  23193. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23194. PsnName string `json:"psn_name"`
  23195. PsnCertType string `json:"psn_cert_type"`
  23196. Certno string `json:"certno"`
  23197. Gend string `json:"gend,omitempty"`
  23198. Naty string `json:"naty,omitempty"`
  23199. Brdy string `json:"brdy,omitempty"`
  23200. Age float64 `json:"age,omitempty"`
  23201. Insutype string `json:"insutype,omitempty"`
  23202. PsnType string `json:"psn_type"`
  23203. CvlservFlag string `json:"cvlserv_flag"`
  23204. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23205. SpPsnType string `json:"sp_psn_type,omitempty"`
  23206. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23207. ClctGrde string `json:"clct_grde,omitempty"`
  23208. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23209. NwbFlag string `json:"nwb_flag,omitempty"`
  23210. InsuAdmdvs string `json:"insu_admdvs"`
  23211. EmpNo string `json:"emp_no,omitempty"`
  23212. EmpName string `json:"emp_name,omitempty"`
  23213. EmpType string `json:"emp_type,omitempty"`
  23214. EconType string `json:"econ_type,omitempty"`
  23215. AfilIndu string `json:"afil_indu,omitempty"`
  23216. AfilRlts string `json:"afil_rlts,omitempty"`
  23217. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23218. PayLoc string `json:"pay_loc,omitempty"`
  23219. FixmedinsCode string `json:"fixmedins_code"`
  23220. FixmedinsName string `json:"fixmedins_name"`
  23221. HospLv string `json:"hosp_lv,omitempty"`
  23222. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23223. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23224. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23225. Begndate string `json:"begndate"`
  23226. Enddate string `json:"enddate"`
  23227. SetlTime string `json:"setl_time"`
  23228. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23229. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23230. MedType string `json:"med_type"`
  23231. SetlType string `json:"setl_type,omitempty"`
  23232. ClrType string `json:"clr_type,omitempty"`
  23233. ClrWay string `json:"clr_way,omitempty"`
  23234. PsnSetlway string `json:"psn_setlway,omitempty"`
  23235. ClrOptins string `json:"clr_optins,omitempty"`
  23236. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23237. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23238. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23239. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23240. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23241. DedcStd float64 `json:"dedc_std,omitempty"`
  23242. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23243. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23244. HifpPay float64 `json:"hifp_pay,omitempty"`
  23245. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23246. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23247. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23248. HifesPay float64 `json:"hifes_pay,omitempty"`
  23249. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23250. HifobPay float64 `json:"hifob_pay,omitempty"`
  23251. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23252. MafPay float64 `json:"maf_pay,omitempty"`
  23253. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23254. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23255. PsnPay float64 `json:"psn_pay,omitempty"`
  23256. AcctPay float64 `json:"acct_pay,omitempty"`
  23257. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23258. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23259. Balc float64 `json:"balc,omitempty"`
  23260. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23261. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23262. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23263. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23264. Year string `json:"year,omitempty"`
  23265. DiseNo string `json:"dise_no,omitempty"`
  23266. DiseName string `json:"dise_name,omitempty"`
  23267. Invono string `json:"invono,omitempty"`
  23268. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23269. ValiFlag string `json:"vali_flag,omitempty"`
  23270. Memo string `json:"memo,omitempty"`
  23271. Rid string `json:"rid"`
  23272. UpdtTime string `json:"updt_time,omitempty"`
  23273. CrterID string `json:"crter_id,omitempty"`
  23274. CrterName string `json:"crter_name,omitempty"`
  23275. CrteTime string `json:"crte_time,omitempty"`
  23276. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  23277. OpterID string `json:"opter_id,omitempty"`
  23278. OpterName string `json:"opter_name,omitempty"`
  23279. OptTime string `json:"opt_time,omitempty"`
  23280. OptinsNo string `json:"optins_no,omitempty"`
  23281. PoolareaNo string `json:"poolarea_no,omitempty"`
  23282. } `json:"result"`
  23283. } `json:"output"`
  23284. RefmsgTime string `json:"refmsg_time"`
  23285. RespondTime string `json:"respond_time"`
  23286. Signtype interface{} `json:"signtype"`
  23287. WarnInfo interface{} `json:"warn_info"`
  23288. }
  23289. type Result5267 struct {
  23290. ErrMsg string `json:"err_msg"`
  23291. InfRefmsgid string `json:"inf_refmsgid"`
  23292. Infcode int64 `json:"infcode"`
  23293. Output struct {
  23294. PageInfo struct {
  23295. Size int `json:"size"`
  23296. RecordCounts int `json:"record_counts"`
  23297. } `json:"pageinfo"`
  23298. Result []struct {
  23299. SetlID string `json:"setl_id"`
  23300. ClrOptins string `json:"clr_optins"`
  23301. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23302. MdtrtID string `json:"mdtrt_id"`
  23303. InitSetlID string `json:"init_setl_id,omitempty"`
  23304. PsnNo string `json:"psn_no"`
  23305. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23306. PsnName string `json:"psn_name"`
  23307. PsnCertType string `json:"psn_cert_type"`
  23308. Certno string `json:"certno"`
  23309. Gend string `json:"gend,omitempty"`
  23310. Naty string `json:"naty,omitempty"`
  23311. Brdy string `json:"brdy,omitempty"`
  23312. Age float64 `json:"age,omitempty"`
  23313. Insutype string `json:"insutype,omitempty"`
  23314. PsnType string `json:"psn_type"`
  23315. CvlservFlag string `json:"cvlserv_flag"`
  23316. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23317. SpPsnType string `json:"sp_psn_type,omitempty"`
  23318. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23319. ClctGrde string `json:"clct_grde,omitempty"`
  23320. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23321. NwbFlag string `json:"nwb_flag,omitempty"`
  23322. InsuAdmdvs string `json:"insu_admdvs"`
  23323. EmpNo string `json:"emp_no,omitempty"`
  23324. EmpName string `json:"emp_name,omitempty"`
  23325. EmpType string `json:"emp_type,omitempty"`
  23326. EconType string `json:"econ_type,omitempty"`
  23327. AfilIndu string `json:"afil_indu,omitempty"`
  23328. AfilRlts string `json:"afil_rlts,omitempty"`
  23329. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23330. PayLoc string `json:"pay_loc,omitempty"`
  23331. FixmedinsCode string `json:"fixmedins_code"`
  23332. FixmedinsName string `json:"fixmedins_name"`
  23333. HospLv string `json:"hosp_lv,omitempty"`
  23334. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23335. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23336. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23337. Begndate string `json:"begndate,omitempty"`
  23338. Enddate string `json:"enddate,omitempty"`
  23339. SetlTime string `json:"setl_time,omitempty"`
  23340. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23341. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23342. MedType string `json:"med_type"`
  23343. SetlType string `json:"setl_type,omitempty"`
  23344. ClrType string `json:"clr_type,omitempty"`
  23345. ClrWay string `json:"clr_way,omitempty"`
  23346. PsnSetlway string `json:"psn_setlway,omitempty"`
  23347. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23348. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23349. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23350. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23351. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23352. DedcStd float64 `json:"dedc_std,omitempty"`
  23353. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23354. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23355. HifpPay float64 `json:"hifp_pay,omitempty"`
  23356. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23357. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23358. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23359. HifesPay float64 `json:"hifes_pay,omitempty"`
  23360. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23361. HifobPay float64 `json:"hifob_pay,omitempty"`
  23362. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23363. MafPay float64 `json:"maf_pay,omitempty"`
  23364. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23365. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23366. PsnPay float64 `json:"psn_pay,omitempty"`
  23367. AcctPay float64 `json:"acct_pay,omitempty"`
  23368. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23369. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23370. Balc float64 `json:"balc,omitempty"`
  23371. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23372. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23373. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23374. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23375. Year string `json:"year,omitempty"`
  23376. DiseNo string `json:"dise_no,omitempty"`
  23377. DiseName string `json:"dise_name,omitempty"`
  23378. Invono string `json:"invono,omitempty"`
  23379. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23380. Memo string `json:"memo,omitempty"`
  23381. UpdtTime string `json:"updt_time,omitempty"`
  23382. OpterID string `json:"opter_id,omitempty"`
  23383. OpterName string `json:"opter_name,omitempty"`
  23384. OptTime string `json:"opt_time,omitempty"`
  23385. OptinsNo string `json:"optins_no,omitempty"`
  23386. PoolareaNo string `json:"poolarea_no,omitempty"`
  23387. } `json:"result"`
  23388. } `json:"output"`
  23389. RefmsgTime string `json:"refmsg_time"`
  23390. RespondTime string `json:"respond_time"`
  23391. Signtype interface{} `json:"signtype"`
  23392. WarnInfo interface{} `json:"warn_info"`
  23393. }
  23394. // type Autogenerated struct {
  23395. // Output struct {
  23396. // Setlinfo struct {
  23397. // SetlTime string `json:"setl_time"`
  23398. // CvlservPay float64 `json:"cvlserv_pay"`
  23399. // Year string `json:"year"`
  23400. // MedType string `json:"med_type"`
  23401. // PsnPay float64 `json:"psn_pay"`
  23402. // OpterID string `json:"opter_id"`
  23403. // Begndate string `json:"begndate"`
  23404. // FlxempeFlag string `json:"flxempe_flag"`
  23405. // HifmiPay float64 `json:"hifmi_pay"`
  23406. // PsnNo string `json:"psn_no"`
  23407. // ActPayDedc float64 `json:"act_pay_dedc"`
  23408. // MedinsSetlID interface{} `json:"medins_setl_id"`
  23409. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23410. // ClrWay string `json:"clr_way"`
  23411. // OthPay float64 `json:"oth_pay"`
  23412. // Gend string `json:"gend"`
  23413. // MdtrtID string `json:"mdtrt_id"`
  23414. // AcctPay float64 `json:"acct_pay"`
  23415. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  23416. // Insutype string `json:"insutype"`
  23417. // Invono interface{} `json:"invono"`
  23418. // Enddate string `json:"enddate"`
  23419. // CashPayamt float64 `json:"cash_payamt"`
  23420. // PsnType string `json:"psn_type"`
  23421. // FixmedinsName string `json:"fixmedins_name"`
  23422. // HifpPay float64 `json:"hifp_pay"`
  23423. // NewFlag interface{} `json:"new_flag"`
  23424. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23425. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  23426. // PayLoc string `json:"pay_loc"`
  23427. // ClrType string `json:"clr_type"`
  23428. // RefdSetlFlag string `json:"refd_setl_flag"`
  23429. // CvlservFlag string `json:"cvlserv_flag"`
  23430. // EmpName string `json:"emp_name"`
  23431. // Brdy string `json:"brdy"`
  23432. // Naty string `json:"naty"`
  23433. // Certno string `json:"certno"`
  23434. // DiseCode string `json:"dise_code"`
  23435. // FixmedinsCode string `json:"fixmedins_code"`
  23436. // DedcHospLv string `json:"dedc_hosp_lv"`
  23437. // OpterName string `json:"opter_name"`
  23438. // Balc float64 `json:"balc"`
  23439. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23440. // PsnCertType string `json:"psn_cert_type"`
  23441. // HifobPay float64 `json:"hifob_pay"`
  23442. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  23443. // HifesPay float64 `json:"hifes_pay"`
  23444. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23445. // OptTime string `json:"opt_time"`
  23446. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23447. // SetlID string `json:"setl_id"`
  23448. // MafPay float64 `json:"maf_pay"`
  23449. // PsnName string `json:"psn_name"`
  23450. // InsuOptins interface{} `json:"insu_optins"`
  23451. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23452. // ClrOptins string `json:"clr_optins"`
  23453. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23454. // DiseName string `json:"dise_name"`
  23455. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23456. // Age float64 `json:"age"`
  23457. // DtrtCertType string `json:"dtrt_cert_type"`
  23458. // HospLv string `json:"hosp_lv"`
  23459. // } `json:"setlinfo"`
  23460. // Setldetail []struct {
  23461. // FundPayType string `json:"fund_pay_type"`
  23462. // FundPayamt float64 `json:"fund_payamt"`
  23463. // SetlProcInfo interface{} `json:"setl_proc_info"`
  23464. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  23465. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  23466. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  23467. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23468. // } `json:"setldetail"`
  23469. // } `json:"output"`
  23470. // Infcode int `json:"infcode"`
  23471. // WarnMsg interface{} `json:"warn_msg"`
  23472. // Cainfo interface{} `json:"cainfo"`
  23473. // ErrMsg interface{} `json:"err_msg"`
  23474. // RefmsgTime string `json:"refmsg_time"`
  23475. // Signtype interface{} `json:"signtype"`
  23476. // RespondTime string `json:"respond_time"`
  23477. // InfRefmsgid string `json:"inf_refmsgid"`
  23478. // }
  23479. type Result002 struct {
  23480. Cainfo interface{} `json:"cainfo"`
  23481. ErrMsg string `json:"err_msg"`
  23482. InfRefmsgid string `json:"inf_refmsgid"`
  23483. Infcode int64 `json:"infcode"`
  23484. Output struct {
  23485. RxFile string `json:"rx_file"`
  23486. SignDigest string `json:"sign_digest"`
  23487. SignCertSn string `json:"sign_cert_sn"`
  23488. SignCertDn string `json:"sign_cert_dn"`
  23489. } `json:"output"`
  23490. RefmsgTime string `json:"refmsg_time"`
  23491. RespondTime string `json:"respond_time"`
  23492. Signtype interface{} `json:"signtype"`
  23493. WarnMsg interface{} `json:"warn_msg"`
  23494. }
  23495. type AhResult002 struct {
  23496. RxFile string `json:"rxFile"`
  23497. SignDigest string `json:"signDigest"`
  23498. SignCertSn string `json:"signCertSn"`
  23499. SignCertDn string `json:"signCertDn"`
  23500. }
  23501. type Result003 struct {
  23502. Cainfo interface{} `json:"cainfo"`
  23503. ErrMsg string `json:"err_msg"`
  23504. InfRefmsgid string `json:"inf_refmsgid"`
  23505. Infcode int64 `json:"infcode"`
  23506. Output struct {
  23507. HiRxno string `json:"hi_rxno"`
  23508. RxStasCodg string `json:"rx_stas_codg"`
  23509. RxStasName string `json:"rx_stas_name"`
  23510. } `json:"output"`
  23511. RefmsgTime string `json:"refmsg_time"`
  23512. RespondTime string `json:"respond_time"`
  23513. Signtype interface{} `json:"signtype"`
  23514. WarnMsg interface{} `json:"warn_msg"`
  23515. }
  23516. type AHResult003 struct {
  23517. HiRxno string `json:"hiRxno"`
  23518. RxStasCodg string `json:"rxStasCodg"`
  23519. RxStasName string `json:"rxStasName"`
  23520. }
  23521. type ResultEleven struct {
  23522. Cainfo string `json:"cainfo"`
  23523. ErrMsg string `json:"err_msg"`
  23524. InfRefmsgid string `json:"inf_refmsgid"`
  23525. Infcode int64 `json:"infcode"`
  23526. Output struct {
  23527. Setlinfo struct {
  23528. SetlTime string `json:"setl_time"`
  23529. CvlservPay float64 `json:"cvlserv_pay"`
  23530. Year string `json:"year"`
  23531. MedType string `json:"med_type"`
  23532. PsnPay float64 `json:"psn_pay"`
  23533. OpterID string `json:"opter_id"`
  23534. Begndate string `json:"begndate"`
  23535. FlxempeFlag string `json:"flxempe_flag"`
  23536. HifmiPay float64 `json:"hifmi_pay"`
  23537. PsnNo string `json:"psn_no"`
  23538. ActPayDedc float64 `json:"act_pay_dedc"`
  23539. MedinsSetlID interface{} `json:"medins_setl_id"`
  23540. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23541. ClrWay string `json:"clr_way"`
  23542. OthPay float64 `json:"oth_pay"`
  23543. Gend string `json:"gend"`
  23544. MdtrtID string `json:"mdtrt_id"`
  23545. AcctPay float64 `json:"acct_pay"`
  23546. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23547. Insutype string `json:"insutype"`
  23548. Invono interface{} `json:"invono"`
  23549. Enddate string `json:"enddate"`
  23550. CashPayamt float64 `json:"cash_payamt"`
  23551. PsnType string `json:"psn_type"`
  23552. FixmedinsName string `json:"fixmedins_name"`
  23553. HifpPay float64 `json:"hifp_pay"`
  23554. NewFlag interface{} `json:"new_flag"`
  23555. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23556. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23557. PayLoc string `json:"pay_loc"`
  23558. ClrType string `json:"clr_type"`
  23559. RefdSetlFlag string `json:"refd_setl_flag"`
  23560. CvlservFlag string `json:"cvlserv_flag"`
  23561. EmpName string `json:"emp_name"`
  23562. Brdy string `json:"brdy"`
  23563. Naty string `json:"naty"`
  23564. Certno string `json:"certno"`
  23565. DiseCode string `json:"dise_code"`
  23566. FixmedinsCode string `json:"fixmedins_code"`
  23567. DedcHospLv string `json:"dedc_hosp_lv"`
  23568. OpterName string `json:"opter_name"`
  23569. Balc float64 `json:"balc"`
  23570. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23571. PsnCertType string `json:"psn_cert_type"`
  23572. HifobPay float64 `json:"hifob_pay"`
  23573. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23574. HifesPay float64 `json:"hifes_pay"`
  23575. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23576. OptTime string `json:"opt_time"`
  23577. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23578. SetlID string `json:"setl_id"`
  23579. MafPay float64 `json:"maf_pay"`
  23580. PsnName string `json:"psn_name"`
  23581. InsuOptins interface{} `json:"insu_optins"`
  23582. PrefFundPay interface{} `json:"pref_fund_pay"`
  23583. ClrOptins string `json:"clr_optins"`
  23584. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23585. DiseName string `json:"dise_name"`
  23586. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23587. Age float64 `json:"age"`
  23588. DtrtCertType string `json:"dtrt_cert_type"`
  23589. HospLv string `json:"hosp_lv"`
  23590. PsnCashPay float64 `json:"psn_cash_pay"`
  23591. } `json:"setlinfo"`
  23592. } `json:"output"`
  23593. RefmsgTime string `json:"refmsg_time"`
  23594. RespondTime string `json:"respond_time"`
  23595. Signtype interface{} `json:"signtype"`
  23596. WarnMsg interface{} `json:"warn_msg"`
  23597. }
  23598. type ResultElevenah struct {
  23599. Cainfo string `json:"cainfo"`
  23600. ErrMsg string `json:"err_msg"`
  23601. InfRefmsgid string `json:"inf_refmsgid"`
  23602. Infcode int64 `json:"infcode"`
  23603. Output struct {
  23604. Setlinfo struct {
  23605. SetlTime int64 `json:"setl_time"`
  23606. CvlservPay float64 `json:"cvlserv_pay"`
  23607. Year string `json:"year"`
  23608. MedType string `json:"med_type"`
  23609. PsnPay float64 `json:"psn_pay"`
  23610. OpterID string `json:"opter_id"`
  23611. Begndate int64 `json:"begndate"`
  23612. FlxempeFlag string `json:"flxempe_flag"`
  23613. HifmiPay float64 `json:"hifmi_pay"`
  23614. PsnNo string `json:"psn_no"`
  23615. ActPayDedc float64 `json:"act_pay_dedc"`
  23616. MedinsSetlID interface{} `json:"medins_setl_id"`
  23617. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23618. ClrWay string `json:"clr_way"`
  23619. OthPay float64 `json:"oth_pay"`
  23620. Gend string `json:"gend"`
  23621. MdtrtID string `json:"mdtrt_id"`
  23622. AcctPay float64 `json:"acct_pay"`
  23623. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23624. Insutype string `json:"insutype"`
  23625. Invono interface{} `json:"invono"`
  23626. Enddate int64 `json:"enddate"`
  23627. CashPayamt float64 `json:"cash_payamt"`
  23628. PsnType string `json:"psn_type"`
  23629. FixmedinsName string `json:"fixmedins_name"`
  23630. HifpPay float64 `json:"hifp_pay"`
  23631. NewFlag interface{} `json:"new_flag"`
  23632. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23633. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23634. PayLoc string `json:"pay_loc"`
  23635. ClrType string `json:"clr_type"`
  23636. RefdSetlFlag string `json:"refd_setl_flag"`
  23637. CvlservFlag string `json:"cvlserv_flag"`
  23638. EmpName string `json:"emp_name"`
  23639. Brdy int64 `json:"brdy"`
  23640. Naty string `json:"naty"`
  23641. Certno string `json:"certno"`
  23642. DiseCode string `json:"dise_code"`
  23643. FixmedinsCode string `json:"fixmedins_code"`
  23644. DedcHospLv string `json:"dedc_hosp_lv"`
  23645. OpterName string `json:"opter_name"`
  23646. Balc float64 `json:"balc"`
  23647. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23648. PsnCertType string `json:"psn_cert_type"`
  23649. HifobPay float64 `json:"hifob_pay"`
  23650. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23651. HifesPay float64 `json:"hifes_pay"`
  23652. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23653. OptTime int64 `json:"opt_time"`
  23654. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23655. SetlID string `json:"setl_id"`
  23656. MafPay float64 `json:"maf_pay"`
  23657. PsnName string `json:"psn_name"`
  23658. InsuOptins interface{} `json:"insu_optins"`
  23659. PrefFundPay interface{} `json:"pref_fund_pay"`
  23660. ClrOptins string `json:"clr_optins"`
  23661. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23662. DiseName string `json:"dise_name"`
  23663. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23664. Age float64 `json:"age"`
  23665. DtrtCertType string `json:"dtrt_cert_type"`
  23666. HospLv string `json:"hosp_lv"`
  23667. PsnCashPay float64 `json:"psn_cash_pay"`
  23668. } `json:"setlinfo"`
  23669. } `json:"output"`
  23670. RefmsgTime string `json:"refmsg_time"`
  23671. RespondTime string `json:"respond_time"`
  23672. Signtype interface{} `json:"signtype"`
  23673. WarnMsg interface{} `json:"warn_msg"`
  23674. }
  23675. type ResultEleven10265 struct {
  23676. Cainfo string `json:"cainfo"`
  23677. ErrMsg string `json:"err_msg"`
  23678. InfRefmsgid string `json:"inf_refmsgid"`
  23679. Infcode string `json:"infcode"`
  23680. Output struct {
  23681. Setlinfo struct {
  23682. SetlTime string `json:"setl_time"`
  23683. CvlservPay float64 `json:"cvlserv_pay"`
  23684. Year string `json:"year"`
  23685. MedType string `json:"med_type"`
  23686. PsnPay float64 `json:"psn_pay"`
  23687. OpterID string `json:"opter_id"`
  23688. Begndate string `json:"begndate"`
  23689. FlxempeFlag string `json:"flxempe_flag"`
  23690. HifmiPay float64 `json:"hifmi_pay"`
  23691. PsnNo string `json:"psn_no"`
  23692. ActPayDedc float64 `json:"act_pay_dedc"`
  23693. MedinsSetlID interface{} `json:"medins_setl_id"`
  23694. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23695. ClrWay string `json:"clr_way"`
  23696. OthPay float64 `json:"oth_pay"`
  23697. Gend string `json:"gend"`
  23698. MdtrtID string `json:"mdtrt_id"`
  23699. AcctPay float64 `json:"acct_pay"`
  23700. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23701. Insutype string `json:"insutype"`
  23702. Invono interface{} `json:"invono"`
  23703. Enddate string `json:"enddate"`
  23704. CashPayamt float64 `json:"cash_payamt"`
  23705. PsnType string `json:"psn_type"`
  23706. FixmedinsName string `json:"fixmedins_name"`
  23707. HifpPay float64 `json:"hifp_pay"`
  23708. NewFlag interface{} `json:"new_flag"`
  23709. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23710. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23711. PayLoc string `json:"pay_loc"`
  23712. ClrType string `json:"clr_type"`
  23713. RefdSetlFlag string `json:"refd_setl_flag"`
  23714. CvlservFlag string `json:"cvlserv_flag"`
  23715. EmpName string `json:"emp_name"`
  23716. Brdy string `json:"brdy"`
  23717. Naty string `json:"naty"`
  23718. Certno string `json:"certno"`
  23719. DiseCode string `json:"dise_code"`
  23720. FixmedinsCode string `json:"fixmedins_code"`
  23721. DedcHospLv string `json:"dedc_hosp_lv"`
  23722. OpterName string `json:"opter_name"`
  23723. Balc float64 `json:"balc"`
  23724. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23725. PsnCertType string `json:"psn_cert_type"`
  23726. HifobPay float64 `json:"hifob_pay"`
  23727. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23728. HifesPay float64 `json:"hifes_pay"`
  23729. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23730. OptTime string `json:"opt_time"`
  23731. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23732. SetlID string `json:"setl_id"`
  23733. MafPay float64 `json:"maf_pay"`
  23734. PsnName string `json:"psn_name"`
  23735. InsuOptins interface{} `json:"insu_optins"`
  23736. PrefFundPay interface{} `json:"pref_fund_pay"`
  23737. ClrOptins string `json:"clr_optins"`
  23738. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23739. DiseName string `json:"dise_name"`
  23740. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23741. Age float64 `json:"age"`
  23742. DtrtCertType string `json:"dtrt_cert_type"`
  23743. HospLv string `json:"hosp_lv"`
  23744. PsnCashPay float64 `json:"psn_cash_pay"`
  23745. } `json:"setlinfo"`
  23746. } `json:"output"`
  23747. RefmsgTime string `json:"refmsg_time"`
  23748. RespondTime string `json:"respond_time"`
  23749. Signtype interface{} `json:"signtype"`
  23750. WarnMsg interface{} `json:"warn_msg"`
  23751. }
  23752. type ResultTwelve struct {
  23753. Cainfo string `json:"cainfo"`
  23754. ErrMsg string `json:"err_msg"`
  23755. InfRefmsgid string `json:"inf_refmsgid"`
  23756. Infcode int64 `json:"infcode"`
  23757. Output struct {
  23758. MdtrtId string `json:"mdtrt_id"`
  23759. ChrgBchno string `json:"chrg_bchno"`
  23760. PsnNo string `json:"psn_no"`
  23761. } `json:"output"`
  23762. RefmsgTime string `json:"refmsg_time"`
  23763. RespondTime string `json:"respond_time"`
  23764. Signtype interface{} `json:"signtype"`
  23765. WarnMsg interface{} `json:"warn_msg"`
  23766. }
  23767. type ResultThirteen struct {
  23768. ErrMsg string `json:"err_msg"`
  23769. InfRefmsgid string `json:"inf_refmsgid"`
  23770. Infcode int64 `json:"infcode"`
  23771. Output struct {
  23772. Result struct {
  23773. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23774. } `json:"result"`
  23775. } `json:"output"`
  23776. RefmsgTime string `json:"refmsg_time"`
  23777. RespondTime string `json:"respond_time"`
  23778. Signtype interface{} `json:"signtype"`
  23779. WarnInfo interface{} `json:"warn_info"`
  23780. }
  23781. type ResultThirteen10265 struct {
  23782. ErrMsg string `json:"err_msg"`
  23783. InfRefmsgid string `json:"inf_refmsgid"`
  23784. Infcode string `json:"infcode"`
  23785. Output struct {
  23786. Result struct {
  23787. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23788. } `json:"result"`
  23789. } `json:"output"`
  23790. RefmsgTime string `json:"refmsg_time"`
  23791. RespondTime string `json:"respond_time"`
  23792. Signtype interface{} `json:"signtype"`
  23793. WarnInfo interface{} `json:"warn_info"`
  23794. }
  23795. type ResultFourteen struct {
  23796. ErrMsg string `json:"err_msg"`
  23797. InfRefmsgid string `json:"inf_refmsgid"`
  23798. Infcode int64 `json:"infcode"`
  23799. Output struct {
  23800. } `json:"output"`
  23801. RefmsgTime string `json:"refmsg_time"`
  23802. RespondTime string `json:"respond_time"`
  23803. Signtype interface{} `json:"signtype"`
  23804. WarnInfo interface{} `json:"warn_info"`
  23805. }
  23806. type ResultCFYLJG001 struct {
  23807. ErrMsg string `json:"err_msg"`
  23808. InfRefmsgid string `json:"inf_refmsgid"`
  23809. Infcode int64 `json:"infcode"`
  23810. Output struct {
  23811. RxTraceCode string `json:"rx_trace_code"`
  23812. HiRxno string `json:"hi_rxno"`
  23813. } `json:"output"`
  23814. RefmsgTime string `json:"refmsg_time"`
  23815. RespondTime string `json:"respond_time"`
  23816. Signtype interface{} `json:"signtype"`
  23817. WarnInfo interface{} `json:"warn_info"`
  23818. }
  23819. type ResultCFYLJG001AH struct {
  23820. RxTraceCode string `json:"rxTraceCode"`
  23821. HiRxno string `json:"hiRxno"`
  23822. }
  23823. type ResultCFYLJG007 struct {
  23824. ErrMsg string `json:"err_msg"`
  23825. InfRefmsgid string `json:"inf_refmsgid"`
  23826. Infcode int64 `json:"infcode"`
  23827. Output struct {
  23828. HiRxno string `json:"hi_rxno"`
  23829. RxStasName string `json:"rx_stas_name"`
  23830. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  23831. Seltdelts []interface{} `json:"seltdelts"`
  23832. RxUsedStasName string `json:"rx_used_stas_name"`
  23833. RxStasCodg string `json:"rx_stas_codg"`
  23834. } `json:"output"`
  23835. RefmsgTime string `json:"refmsg_time"`
  23836. RespondTime string `json:"respond_time"`
  23837. Signtype interface{} `json:"signtype"`
  23838. WarnInfo interface{} `json:"warn_info"`
  23839. }
  23840. type ResultCFYLJG002 struct {
  23841. ErrMsg string `json:"err_msg"`
  23842. InfRefmsgid string `json:"inf_refmsgid"`
  23843. Infcode int64 `json:"infcode"`
  23844. Output struct {
  23845. RxFile string `json:"rx_file"`
  23846. SignDigest string `json:"sign_digest"`
  23847. SignCertSn string `json:"sign_cert_sn"`
  23848. SignCertDn string `json:"sign_cert_dn"`
  23849. } `json:"output"`
  23850. RefmsgTime string `json:"refmsg_time"`
  23851. RespondTime string `json:"respond_time"`
  23852. Signtype interface{} `json:"signtype"`
  23853. WarnInfo interface{} `json:"warn_info"`
  23854. }
  23855. type ResultCFYLJG003 struct {
  23856. ErrMsg string `json:"err_msg"`
  23857. InfRefmsgid string `json:"inf_refmsgid"`
  23858. Infcode int64 `json:"infcode"`
  23859. Output struct {
  23860. HiRxno string `json:"hi_rxno"`
  23861. RxStasCodg string `json:"rx_stas_codg"`
  23862. RxStasName string `json:"rx_stas_name"`
  23863. } `json:"output"`
  23864. RefmsgTime string `json:"refmsg_time"`
  23865. RespondTime string `json:"respond_time"`
  23866. Signtype interface{} `json:"signtype"`
  23867. WarnInfo interface{} `json:"warn_info"`
  23868. }
  23869. type ResultCFYLJG004 struct {
  23870. ErrMsg string `json:"err_msg"`
  23871. InfRefmsgid string `json:"inf_refmsgid"`
  23872. Infcode int64 `json:"infcode"`
  23873. Output struct {
  23874. HiRxno string `json:"hi_rxno"`
  23875. RxStasCodg string `json:"rx_stas_codg"`
  23876. RxStasName string `json:"rx_stas_name"`
  23877. } `json:"output"`
  23878. RefmsgTime string `json:"refmsg_time"`
  23879. RespondTime string `json:"respond_time"`
  23880. Signtype interface{} `json:"signtype"`
  23881. WarnInfo interface{} `json:"warn_info"`
  23882. }
  23883. type ResultCFYLJG008 struct {
  23884. ErrMsg string `json:"err_msg"`
  23885. InfRefmsgid string `json:"inf_refmsgid"`
  23886. Infcode int64 `json:"infcode"`
  23887. Output struct {
  23888. PoolareaNo string `json:"poolareaNo"`
  23889. AdmdvsName string `json:"admdvsName"`
  23890. Count string `json:"count"`
  23891. } `json:"output"`
  23892. RefmsgTime string `json:"refmsg_time"`
  23893. RespondTime string `json:"respond_time"`
  23894. Signtype interface{} `json:"signtype"`
  23895. WarnInfo interface{} `json:"warn_info"`
  23896. }
  23897. type ResultCFYLJG005 struct {
  23898. ErrMsg string `json:"err_msg"`
  23899. InfRefmsgid string `json:"inf_refmsgid"`
  23900. Infcode int64 `json:"infcode"`
  23901. Output struct {
  23902. HiRxNo string `json:"hi_rxno"`
  23903. FixMedinsCode string `json:"fixmedins_code"`
  23904. FixMedinsName string `json:"fixmedins_name"`
  23905. RxStasCodg string `json:"rx_stas_codg"`
  23906. RxStasName string `json:"rx_stas_name"`
  23907. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  23908. RxUserdStasName string `json:"rx_userd_stas_name"`
  23909. PrscTime string `json:"prsc_time"`
  23910. RxDrugCnt float64 `json:"rx_drug_cnt"`
  23911. RxUsedWayCodg string `json:"rx_used_way_codg"`
  23912. RxUsedWayName string `json:"rx_used_way_name"`
  23913. RxFrquCodg string `json:"rx_frqu_codg"`
  23914. RxFrquName string `json:"rx_frqu_name"`
  23915. RxDosunt string `json:"rx_dosunt"`
  23916. RxDoscnt float64 `json:"rx_doscnt"`
  23917. RxDrordDscr string `json:"rx_drord_dscr"`
  23918. ValiDays int64 `json:"vali_days"`
  23919. ValiEndTime string `json:"vali_end_time"`
  23920. ReptFlag string `json:"rept_flag"`
  23921. MaxReptCnt int64 `json:"max_rept_cnt"`
  23922. ReptdCnt int64 `json:"reptd_cnt"`
  23923. MinInrvDays int64 `json:"min_inrv_days"`
  23924. RxTypeCode string `json:"rx_type_code"`
  23925. RxTypeName string `json:"rx_type_name"`
  23926. LongRxFlag string `json:"long_rx_flag"`
  23927. RxDetlList []struct {
  23928. MedListCodg string `json:"med_list_codg"`
  23929. MedinsListCodg string `json:"medins_list_codg"`
  23930. HospPrepFlag string `json:"hosp_prep_flag"`
  23931. RxItemTypeCode string `json:"rx_item_type_code"`
  23932. RxItemTypeName string `json:"rx_item_type_name"`
  23933. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  23934. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  23935. TcmHerbFoote string `json:"tcmherb_foote"`
  23936. MednTypeCode string `json:"medn_type_code"`
  23937. MednTypeName string `json:"medn_type_name"`
  23938. MainMedcFlag string `json:"main_medc_flag"`
  23939. UrgtFlag string `json:"urgt_flag"`
  23940. BasMednFlag string `json:"bas_medn_flag"`
  23941. ImpDrugFlag string `json:"imp_drug_flag"`
  23942. ProdBarc string `json:"prod_barc"`
  23943. DrugProdname string `json:"drug_prodname"`
  23944. GennameCodg string `json:"genname_codg"`
  23945. DrugGenname string `json:"drug_genname"`
  23946. DrugDosform string `json:"drug_dosform"`
  23947. DrugSpec string `json:"drug_spec"`
  23948. PrdrName string `json:"prdr_name"`
  23949. MedcWayCodg string `json:"medc_way_codg"`
  23950. MedcWayDscr string `json:"medc_way_dscr"`
  23951. MedcBegntime string `json:"medc_begntime"`
  23952. MedcEndtime string `json:"medc_endtime"`
  23953. MedcDays float64 `json:"medc_days"`
  23954. DrugPric float64 `json:"drug_pric"`
  23955. DrugSumamt float64 `json:"drug_sumamt"`
  23956. DrugCnt float64 `json:"drug_cnt"`
  23957. DrugDosunt string `json:"drug_dosunt"`
  23958. SinDoscnt float64 `json:"sin_doscnt"`
  23959. SinDosunt string `json:"sin_dosunt"`
  23960. UsedFrquCodg string `json:"used_frqu_codg"`
  23961. UsedFrquName string `json:"used_frqu_name"`
  23962. DrugTotlcnt string `json:"drug_totlcnt"`
  23963. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  23964. DiseCodg string `json:"dise_codg"`
  23965. HospApprFlag string `json:"hosp_appr_flag"`
  23966. } `json:"rx_detl_list"`
  23967. RxOtpinfo struct {
  23968. MedType string `json:"med_type"`
  23969. IptOtpNo string `json:"ipt_otp_no"`
  23970. OtpIptFlag string `json:"otp_ipt_flag"`
  23971. PatnName string `json:"patn_name"`
  23972. PatnAge float64 `json:"patn_age"`
  23973. PatnHgt float64 `json:"patn_hgt"`
  23974. PatnWt float64 `json:"patn_wt"`
  23975. Gend string `json:"gend"`
  23976. GesoVal float64 `json:"geso_val"`
  23977. NwbFlag string `json:"nwb_flag"`
  23978. NwbAge string `json:"nwb_age"`
  23979. SuckPrdFlag string `json:"suck_prd_flag"`
  23980. AlgsHis string `json:"algs_his"`
  23981. Insutype string `json:"insutype"`
  23982. PrscDeptName string `json:"prsc_dept_name"`
  23983. PrscDrName string `json:"prsc_dr_name"`
  23984. PharName string `json:"phar_name"`
  23985. PharChkTime string `json:"phar_chk_time"`
  23986. MdtrtTime string `json:"mdtrt_time"`
  23987. DiseCodg string `json:"dise_codg"`
  23988. DiseName string `json:"dise_name"`
  23989. SpDiseFlag string `json:"sp_dise_flag"`
  23990. MaindiagCode string `json:"maindiag_code"`
  23991. MaindiagName string `json:"maindiag_name"`
  23992. DiseCondDscr string `json:"dise_cond_dscr"`
  23993. FstdiagFlag string `json:"fstdiag_flag"`
  23994. } `json:"rx_otpinfo"`
  23995. RxDiseList []struct {
  23996. DiagType string `json:"diag_type"`
  23997. MaindiagFlag string `json:"maindiag_flag"`
  23998. DiagSrtNo string `json:"diag_srt_no"`
  23999. DiagCode string `json:"diag_code"`
  24000. DiagName string `json:"diag_name"`
  24001. DiagDept string `json:"diag_dept"`
  24002. DiagDrNo string `json:"diag_dr_no"`
  24003. DiagDrName string `json:"diag_dr_name"`
  24004. DiagTime string `json:"diag_time"`
  24005. TcmDiseCode string `json:"tcm_dise_code"`
  24006. TcmDiseName string `json:"tcm_dise_name"`
  24007. TcmSympCode string `json:"tcmsymp_code"`
  24008. TcmSymp string `json:"tcmsymp"`
  24009. } `json:"rx_dise_list"`
  24010. } `json:"output"`
  24011. RefmsgTime string `json:"refmsg_time"`
  24012. RespondTime string `json:"respond_time"`
  24013. Signtype interface{} `json:"signtype"`
  24014. WarnInfo interface{} `json:"warn_info"`
  24015. }
  24016. type ResultCFYLJG006 struct {
  24017. ErrMsg string `json:"err_msg"`
  24018. InfRefmsgid string `json:"inf_refmsgid"`
  24019. Infcode int64 `json:"infcode"`
  24020. Output struct {
  24021. HiRxNo string `json:"hi_rxno"`
  24022. PharCode string `json:"phar_code"`
  24023. PharName string `json:"phar_name"`
  24024. RxChkOpnn string `json:"rx_chk_opnn"`
  24025. RxChkTime string `json:"rx_chk_time"`
  24026. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  24027. RxChkStasName string `json:"rx_chk_stas_name"`
  24028. RxStasCodg string `json:"rx_stas_codg"`
  24029. RxStasName string `json:"rx_stas_name"`
  24030. } `json:"output"`
  24031. RefmsgTime string `json:"refmsg_time"`
  24032. RespondTime string `json:"respond_time"`
  24033. Signtype interface{} `json:"signtype"`
  24034. WarnInfo interface{} `json:"warn_info"`
  24035. }
  24036. type ResultFourteen10265 struct {
  24037. ErrMsg string `json:"err_msg"`
  24038. InfRefmsgid string `json:"inf_refmsgid"`
  24039. Infcode string `json:"infcode"`
  24040. Output struct {
  24041. } `json:"output"`
  24042. RefmsgTime string `json:"refmsg_time"`
  24043. RespondTime string `json:"respond_time"`
  24044. Signtype interface{} `json:"signtype"`
  24045. WarnInfo interface{} `json:"warn_info"`
  24046. }
  24047. type ResultSixteen struct {
  24048. Cainfo string `json:"cainfo"`
  24049. ErrMsg string `json:"err_msg"`
  24050. InfRefmsgid string `json:"inf_refmsgid"`
  24051. Infcode int64 `json:"infcode"`
  24052. Output struct {
  24053. Setlinfo struct {
  24054. MdtrtID string `json:"mdtrt_id"`
  24055. SetlID string `json:"setl_id"`
  24056. ClrOptins string `json:"clr_optins"`
  24057. SetlTime string `json:"setl_time"`
  24058. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24059. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24060. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24061. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24062. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24063. ActPayDedc float64 `json:"act_pay_dedc"`
  24064. HifpPay float64 `json:"hifp_pay"`
  24065. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24066. Lfpay float64 `json:"selfpay"`
  24067. CvlservPay float64 `json:"cvlserv_pay"`
  24068. HifesPay float64 `json:"hifes_pay"`
  24069. HifmiPay float64 `json:"hifmi_pay"`
  24070. HifobPay float64 `json:"hifob_pay"`
  24071. MafPay float64 `json:"maf_pay"`
  24072. OthPay float64 `json:"oth_pay"`
  24073. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24074. PsnPartAmt float64 `json:"psn_part_amt"`
  24075. AcctPay float64 `json:"acct_pay"`
  24076. Balc float64 `json:"balc"`
  24077. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24078. HospPartAmt float64 `json:"hosp_part_amt"`
  24079. MedinsSetlID string `json:"medins_setl_id"`
  24080. PdnCashPay string `json:"pdn_cash_pay"`
  24081. } `json:"setlinfo"`
  24082. } `json:"output"`
  24083. RefmsgTime string `json:"refmsg_time"`
  24084. RespondTime string `json:"respond_time"`
  24085. Signtype interface{} `json:"signtype"`
  24086. WarnMsg interface{} `json:"warn_msg"`
  24087. }
  24088. type ResultSixteen10265 struct {
  24089. Cainfo string `json:"cainfo"`
  24090. ErrMsg string `json:"err_msg"`
  24091. InfRefmsgid string `json:"inf_refmsgid"`
  24092. Infcode string `json:"infcode"`
  24093. Output struct {
  24094. Setlinfo struct {
  24095. MdtrtID string `json:"mdtrt_id"`
  24096. SetlID string `json:"setl_id"`
  24097. ClrOptins string `json:"clr_optins"`
  24098. SetlTime string `json:"setl_time"`
  24099. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24100. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24101. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24102. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24103. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24104. ActPayDedc float64 `json:"act_pay_dedc"`
  24105. HifpPay float64 `json:"hifp_pay"`
  24106. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24107. Lfpay float64 `json:"selfpay"`
  24108. CvlservPay float64 `json:"cvlserv_pay"`
  24109. HifesPay float64 `json:"hifes_pay"`
  24110. HifmiPay float64 `json:"hifmi_pay"`
  24111. HifobPay float64 `json:"hifob_pay"`
  24112. MafPay float64 `json:"maf_pay"`
  24113. OthPay float64 `json:"oth_pay"`
  24114. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24115. PsnPartAmt float64 `json:"psn_part_amt"`
  24116. AcctPay float64 `json:"acct_pay"`
  24117. Balc float64 `json:"balc"`
  24118. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24119. HospPartAmt float64 `json:"hosp_part_amt"`
  24120. MedinsSetlID string `json:"medins_setl_id"`
  24121. PdnCashPay string `json:"pdn_cash_pay"`
  24122. } `json:"setlinfo"`
  24123. } `json:"output"`
  24124. RefmsgTime string `json:"refmsg_time"`
  24125. RespondTime string `json:"respond_time"`
  24126. Signtype interface{} `json:"signtype"`
  24127. WarnMsg interface{} `json:"warn_msg"`
  24128. }
  24129. type ResultSixteen10265Two struct {
  24130. Cainfo string `json:"cainfo"`
  24131. ErrMsg string `json:"err_msg"`
  24132. InfRefmsgid string `json:"inf_refmsgid"`
  24133. Infcode string `json:"infcode"`
  24134. Output struct {
  24135. Setlinfo interface{} `json:"setlinfo"`
  24136. } `json:"output"`
  24137. RefmsgTime string `json:"refmsg_time"`
  24138. RespondTime string `json:"respond_time"`
  24139. Signtype interface{} `json:"signtype"`
  24140. WarnMsg interface{} `json:"warn_msg"`
  24141. }
  24142. type ResultgzSixteen10265Two struct {
  24143. Cainfo string `json:"cainfo"`
  24144. ErrMsg string `json:"err_msg"`
  24145. InfRefmsgid string `json:"inf_refmsgid"`
  24146. Infcode int64 `json:"infcode"`
  24147. Output struct {
  24148. Setlinfo interface{} `json:"setlinfo"`
  24149. } `json:"output"`
  24150. RefmsgTime string `json:"refmsg_time"`
  24151. RespondTime string `json:"respond_time"`
  24152. Signtype interface{} `json:"signtype"`
  24153. WarnMsg interface{} `json:"warn_msg"`
  24154. }
  24155. type ResultSeventeen struct {
  24156. ErrMsg string `json:"err_msg"`
  24157. InfRefmsgid string `json:"inf_refmsgid"`
  24158. Infcode int64 `json:"infcode"`
  24159. Output struct {
  24160. SetlListId string `json:"setl_list_id"`
  24161. } `json:"output"`
  24162. RefmsgTime string `json:"refmsg_time"`
  24163. RespondTime string `json:"respond_time"`
  24164. Signtype string `json:"signtype"`
  24165. WarnInfo string `json:"warn_info"`
  24166. }
  24167. type ResultSeventeenOther struct {
  24168. ErrMsg string `json:"err_msg"`
  24169. InfRefmsgid string `json:"inf_refmsgid"`
  24170. Infcode string `json:"infcode"`
  24171. Output struct {
  24172. SetlListId string `json:"setl_list_id"`
  24173. } `json:"output"`
  24174. RefmsgTime string `json:"refmsg_time"`
  24175. RespondTime string `json:"respond_time"`
  24176. Signtype string `json:"signtype"`
  24177. WarnInfo string `json:"warn_info"`
  24178. }
  24179. type Result90991 struct {
  24180. ErrMsg string `json:"err_msg"`
  24181. InfRefmsgid string `json:"inf_refmsgid"`
  24182. Infcode int64 `json:"infcode"`
  24183. Output struct {
  24184. Result struct {
  24185. PsnNo string `json:"psn_no"`
  24186. CardStat string `json:"card_stat"`
  24187. Certno string `json:"certno"`
  24188. PsnName string `json:"psn_name"`
  24189. CheckStat string `json:"check_stat"`
  24190. SscnoCheckStat string `json:"sscno_check_stat"`
  24191. } `json:"result"`
  24192. } `json:"output"`
  24193. RefmsgTime string `json:"refmsg_time"`
  24194. RespondTime string `json:"respond_time"`
  24195. Signtype interface{} `json:"signtype"`
  24196. WarnInfo interface{} `json:"warn_info"`
  24197. }
  24198. type Result90100 struct {
  24199. ErrMsg string `json:"err_msg"`
  24200. InfRefmsgid string `json:"inf_refmsgid"`
  24201. Infcode int64 `json:"infcode"`
  24202. Output struct {
  24203. PoolareaNo string `json:"poolarea_no"`
  24204. PoolareaNoName string `json:"poolarea_no_name"`
  24205. Insutype string `json:"insutype"`
  24206. InsutypeName string `json:"insutype_name"`
  24207. ClctType string `json:"clct_type"`
  24208. ClctTypeName string `json:"clct_type_name"`
  24209. ClctFlag string `json:"clct_flag"`
  24210. ClctFlagName string `json:"clct_flag_name"`
  24211. AccrymBegn string `json:"accrym_begn"`
  24212. AccrymEnd string `json:"accrym_end"`
  24213. ClctTime string `json:"clct_time"`
  24214. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  24215. } `json:"output"`
  24216. RefmsgTime string `json:"refmsg_time"`
  24217. RespondTime string `json:"respond_time"`
  24218. Signtype interface{} `json:"signtype"`
  24219. WarnInfo interface{} `json:"warn_info"`
  24220. }
  24221. type Custom struct {
  24222. DetItemFeeSumamt string
  24223. Cut string
  24224. FeedetlSn string
  24225. Price string
  24226. MedListCodg string
  24227. Type int64
  24228. AdviceId int64
  24229. ProjectId int64
  24230. ItemId int64
  24231. }
  24232. type Result5301 struct {
  24233. ErrMsg string `json:"err_msg"`
  24234. InfRefmsgid string `json:"inf_refmsgid"`
  24235. Infcode int64 `json:"infcode"`
  24236. Output struct {
  24237. Result []struct {
  24238. OpspDiseCode string `json:"opsp_dise_code"`
  24239. OpspDiseName string `json:"opsp_dise_name"`
  24240. Begndate string `json:"begndate"`
  24241. Enddate string `json:"enddate"`
  24242. } `json:"feedetail"`
  24243. } `json:"output"`
  24244. RefmsgTime string `json:"refmsg_time"`
  24245. RespondTime string `json:"respond_time"`
  24246. Signtype interface{} `json:"signtype"`
  24247. WarnInfo interface{} `json:"warn_info"`
  24248. }
  24249. type Result5301For10265 struct {
  24250. ErrMsg string `json:"err_msg"`
  24251. InfRefmsgid string `json:"inf_refmsgid"`
  24252. Infcode string `json:"infcode"`
  24253. Output struct {
  24254. Result []struct {
  24255. OpspDiseCode string `json:"opsp_dise_code"`
  24256. OpspDiseName string `json:"opsp_dise_name"`
  24257. Begndate string `json:"begndate"`
  24258. Enddate string `json:"enddate"`
  24259. } `json:"feedetail"`
  24260. } `json:"output"`
  24261. RefmsgTime string `json:"refmsg_time"`
  24262. RespondTime string `json:"respond_time"`
  24263. Signtype interface{} `json:"signtype"`
  24264. WarnInfo interface{} `json:"warn_info"`
  24265. }
  24266. //获取个人信息----挂号-----上传就诊信息
  24267. func (c *HisApiController) GetRegisterInfo() {
  24268. id, _ := c.GetInt64("id")
  24269. record_time := c.GetString("record_time")
  24270. settlementValue, _ := c.GetInt64("settlement_value")
  24271. medical_insurance_card := c.GetString("medical_insurance_card")
  24272. name := c.GetString("name")
  24273. id_card_type, _ := c.GetInt64("id_card_type")
  24274. certificates, _ := c.GetInt64("certificates")
  24275. medical_care, _ := c.GetInt64("medical_care")
  24276. birthday := c.GetString("birthday")
  24277. id_card := c.GetString("id_card")
  24278. register_type, _ := c.GetInt64("register")
  24279. doctor, _ := c.GetInt64("doctor")
  24280. department, _ := c.GetInt64("department")
  24281. gender, _ := c.GetInt64("sex")
  24282. registration_fee, _ := c.GetFloat("registration_fee")
  24283. medical_expenses, _ := c.GetFloat("medical_expenses")
  24284. social_type, _ := c.GetInt64("social_type")
  24285. admin_user_id, _ := c.GetInt64("admin_user_id")
  24286. insuplc_admdvs := c.GetString("insuplc_admdvs")
  24287. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  24288. mdtrt_type := c.GetString("mdtrt_type")
  24289. if id_card_type == 5 {
  24290. id_card_type = 4
  24291. }
  24292. timeLayout := "2006-01-02"
  24293. loc, _ := time.LoadLocation("Local")
  24294. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  24295. birthUnix := birthdays.Unix()
  24296. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24297. if err != nil {
  24298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24299. return
  24300. }
  24301. recordDateTime := theTime.Unix()
  24302. adminInfo := c.GetAdminUserInfo()
  24303. var patient service.Patients
  24304. if id == 0 {
  24305. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  24306. } else {
  24307. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  24308. }
  24309. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24310. if patientPrescription.ID == 0 {
  24311. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24312. }
  24313. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  24314. if patient.ID == 0 {
  24315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  24316. return
  24317. }
  24318. if len(patient.IdCardNo) == 0 {
  24319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  24320. return
  24321. }
  24322. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  24323. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  24324. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  24325. //就诊结算未完成,不能进行二次挂号
  24326. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  24327. if len(his) >= 1 {
  24328. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  24329. if len(his) >= 1 && order.ID == 0 {
  24330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  24331. return
  24332. }
  24333. }
  24334. var aaaa string
  24335. //var register_log string
  24336. if config.IsOpen == 1 {
  24337. var res ResultTwo
  24338. var res10265 ResultTwo10265
  24339. var PsnNo string
  24340. var PsnCertType string
  24341. var Certno string
  24342. var PsnName string
  24343. var Gend string
  24344. var Naty string
  24345. var Brdy string
  24346. var Age float64
  24347. var infoStr string
  24348. var idetinfoStr string
  24349. var infocode int64
  24350. var verify_number string
  24351. fmt.Println(verify_number)
  24352. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  24353. psn_info, _ := service.GetPsnByPatientId(id)
  24354. PsnNo = psn_info.PsnNo
  24355. PsnCertType = psn_info.PsnCertType
  24356. Certno = psn_info.Certno
  24357. PsnName = psn_info.PsnName
  24358. Gend = psn_info.Gend
  24359. Naty = psn_info.Naty
  24360. Brdy = psn_info.Brdy
  24361. Age = psn_info.Age
  24362. infoStr = psn_info.Insuinfo
  24363. idetinfoStr = psn_info.Idetinfo
  24364. infocode = 0
  24365. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  24366. psn_info, _ := service.GetPsnByPatientId(id)
  24367. PsnNo = psn_info.PsnNo
  24368. PsnCertType = psn_info.PsnCertType
  24369. Certno = psn_info.Certno
  24370. PsnName = psn_info.PsnName
  24371. Gend = psn_info.Gend
  24372. Naty = psn_info.Naty
  24373. Brdy = psn_info.Brdy
  24374. Age = psn_info.Age
  24375. infoStr = psn_info.Insuinfo
  24376. idetinfoStr = psn_info.Idetinfo
  24377. infocode = 0
  24378. verify_number = psn_info.VerifyNumber
  24379. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24380. if id_card_type == 2 {
  24381. //请求内网数据
  24382. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  24383. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24384. "&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
  24385. resp, requestErr := http.Get(api)
  24386. if requestErr != nil {
  24387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24388. return
  24389. }
  24390. body, ioErr := ioutil.ReadAll(resp.Body)
  24391. if ioErr != nil {
  24392. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24394. return
  24395. }
  24396. var respJSON map[string]interface{}
  24397. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24400. return
  24401. }
  24402. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24403. result_byte, _ := json.Marshal(respJSON)
  24404. result := string(result_byte)
  24405. var dat map[string]interface{}
  24406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24407. fmt.Println(dat)
  24408. } else {
  24409. fmt.Println(err)
  24410. }
  24411. userJSONBytes, _ := json.Marshal(dat)
  24412. var res ResultTwo
  24413. var resTwo10265 ResultTwo10265
  24414. if miConfig.Code == "H15049901371" {
  24415. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  24416. utils.ErrorLog("解析失败:%v", err)
  24417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24418. return
  24419. }
  24420. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  24421. res.Infcode = Infcode
  24422. res.ErrMsg = resTwo10265.ErrMsg
  24423. res.Output = resTwo10265.Output
  24424. res.InfRefmsgid = resTwo10265.InfRefmsgid
  24425. res.RespondTime = resTwo10265.RespondTime
  24426. res.WarnInfo = resTwo10265.WarnInfo
  24427. } else {
  24428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24429. utils.ErrorLog("解析失败:%v", err)
  24430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24431. return
  24432. }
  24433. }
  24434. //var insutypes []string
  24435. //var insutype string
  24436. //var is390 int = 0
  24437. //var is310 int = 0
  24438. //for _, item := range res.Output.Iinfo {
  24439. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24440. // insutypes = append(insutypes, item.Insutype)
  24441. // }
  24442. //}
  24443. //if len(insutypes) == 1 {
  24444. // insutype = insutypes[0]
  24445. //} else {
  24446. // for _, i := range insutypes {
  24447. // if i == "390" {
  24448. // is390 = 1
  24449. // }
  24450. //
  24451. // if i == "310" {
  24452. // is310 = 1
  24453. // }
  24454. // }
  24455. //}
  24456. //if is390 == 1 {
  24457. // insutype = "390"
  24458. //}
  24459. //if is310 == 1 {
  24460. // insutype = "310"
  24461. //}
  24462. //if len(insutypes) == 0 {
  24463. // insutype = "310"
  24464. //}
  24465. PsnNo = res.Output.Baseinfo.PsnNo
  24466. PsnCertType = res.Output.Baseinfo.PsnCertType
  24467. Certno = res.Output.Baseinfo.Certno
  24468. PsnName = res.Output.Baseinfo.PsnName
  24469. Gend = res.Output.Baseinfo.Gend
  24470. Naty = res.Output.Baseinfo.Naty
  24471. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24472. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24473. infoStr = string(Iinfos)
  24474. idetinfoStr = string(Idetinfos)
  24475. infocode = res.Infcode
  24476. //infocode = 0
  24477. //verify_number = psn_info.VerifyNumber
  24478. } else {
  24479. psn_info, _ := service.GetPsnByPatientId(id)
  24480. PsnNo = psn_info.PsnNo
  24481. PsnCertType = psn_info.PsnCertType
  24482. Certno = psn_info.Certno
  24483. PsnName = psn_info.PsnName
  24484. Gend = psn_info.Gend
  24485. Naty = psn_info.Naty
  24486. Brdy = psn_info.Brdy
  24487. Age = psn_info.Age
  24488. infoStr = psn_info.Insuinfo
  24489. idetinfoStr = psn_info.Idetinfo
  24490. infocode = 0
  24491. verify_number = psn_info.VerifyNumber
  24492. }
  24493. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24494. if id_card_type == 1 {
  24495. psn_info, _ := service.GetPsnByPatientId(id)
  24496. PsnNo = psn_info.PsnNo
  24497. PsnCertType = psn_info.PsnCertType
  24498. Certno = psn_info.Certno
  24499. PsnName = psn_info.PsnName
  24500. Gend = psn_info.Gend
  24501. Naty = psn_info.Naty
  24502. Brdy = psn_info.Brdy
  24503. Age = psn_info.Age
  24504. infoStr = psn_info.Insuinfo
  24505. idetinfoStr = psn_info.Idetinfo
  24506. infocode = 0
  24507. verify_number = psn_info.VerifyNumber
  24508. } else if id_card_type == 2 {
  24509. 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)
  24510. fmt.Println(errMsgLog)
  24511. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24512. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24513. utils.ErrorLog("解析失败:%v", err)
  24514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24515. return
  24516. }
  24517. PsnNo = res.Output.Baseinfo.PsnNo
  24518. PsnCertType = res.Output.Baseinfo.PsnCertType
  24519. Certno = res.Output.Baseinfo.Certno
  24520. PsnName = res.Output.Baseinfo.PsnName
  24521. Gend = res.Output.Baseinfo.Gend
  24522. Naty = res.Output.Baseinfo.Naty
  24523. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24524. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24525. infoStr = string(Iinfos)
  24526. idetinfoStr = string(Idetinfos)
  24527. infocode = res.Infcode
  24528. }
  24529. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24530. if id_card_type == 1 {
  24531. psn_info, _ := service.GetPsnByPatientId(id)
  24532. PsnNo = psn_info.PsnNo
  24533. PsnCertType = psn_info.PsnCertType
  24534. Certno = psn_info.Certno
  24535. PsnName = psn_info.PsnName
  24536. Gend = psn_info.Gend
  24537. Naty = psn_info.Naty
  24538. Brdy = psn_info.Brdy
  24539. Age = psn_info.Age
  24540. infoStr = psn_info.Insuinfo
  24541. idetinfoStr = psn_info.Idetinfo
  24542. infocode = 0
  24543. verify_number = psn_info.VerifyNumber
  24544. } else if id_card_type == 2 {
  24545. 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, "")
  24546. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24547. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24548. utils.ErrorLog("解析失败:%v", err)
  24549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24550. return
  24551. }
  24552. PsnNo = res.Output.Baseinfo.PsnNo
  24553. PsnCertType = res.Output.Baseinfo.PsnCertType
  24554. Certno = res.Output.Baseinfo.Certno
  24555. PsnName = res.Output.Baseinfo.PsnName
  24556. Gend = res.Output.Baseinfo.Gend
  24557. Naty = res.Output.Baseinfo.Naty
  24558. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24559. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24560. infoStr = string(Iinfos)
  24561. idetinfoStr = string(Idetinfos)
  24562. infocode = res.Infcode
  24563. } else {
  24564. psn_info, _ := service.GetPsnByPatientId(id)
  24565. PsnNo = psn_info.PsnNo
  24566. PsnCertType = psn_info.PsnCertType
  24567. Certno = psn_info.Certno
  24568. PsnName = psn_info.PsnName
  24569. Gend = psn_info.Gend
  24570. Naty = psn_info.Naty
  24571. Brdy = psn_info.Brdy
  24572. Age = psn_info.Age
  24573. infoStr = psn_info.Insuinfo
  24574. idetinfoStr = psn_info.Idetinfo
  24575. infocode = 0
  24576. verify_number = psn_info.VerifyNumber
  24577. }
  24578. } else if miConfig.MdtrtareaAdmvs == "361025" {
  24579. if id_card_type == 1 {
  24580. psn_info, _ := service.GetPsnByPatientId(id)
  24581. PsnNo = psn_info.PsnNo
  24582. PsnCertType = psn_info.PsnCertType
  24583. Certno = psn_info.Certno
  24584. PsnName = psn_info.PsnName
  24585. Gend = psn_info.Gend
  24586. Naty = psn_info.Naty
  24587. Brdy = psn_info.Brdy
  24588. Age = psn_info.Age
  24589. infoStr = psn_info.Insuinfo
  24590. idetinfoStr = psn_info.Idetinfo
  24591. infocode = 0
  24592. verify_number = psn_info.VerifyNumber
  24593. } else if id_card_type == 2 {
  24594. psn_info, _ := service.GetPsnByPatientId(id)
  24595. PsnNo = psn_info.PsnNo
  24596. PsnCertType = psn_info.PsnCertType
  24597. Certno = psn_info.Certno
  24598. PsnName = psn_info.PsnName
  24599. Gend = psn_info.Gend
  24600. Naty = psn_info.Naty
  24601. Brdy = psn_info.Brdy
  24602. Age = psn_info.Age
  24603. infoStr = psn_info.Insuinfo
  24604. idetinfoStr = psn_info.Idetinfo
  24605. infocode = 0
  24606. verify_number = psn_info.VerifyNumber
  24607. } else {
  24608. psn_info, _ := service.GetPsnByPatientId(id)
  24609. PsnNo = psn_info.PsnNo
  24610. PsnCertType = psn_info.PsnCertType
  24611. Certno = psn_info.Certno
  24612. PsnName = psn_info.PsnName
  24613. Gend = psn_info.Gend
  24614. Naty = psn_info.Naty
  24615. Brdy = psn_info.Brdy
  24616. Age = psn_info.Age
  24617. infoStr = psn_info.Insuinfo
  24618. idetinfoStr = psn_info.Idetinfo
  24619. infocode = 0
  24620. verify_number = psn_info.VerifyNumber
  24621. }
  24622. } else if miConfig.MdtrtareaAdmvs == "360100" {
  24623. if id_card_type == 1 {
  24624. psn_info, _ := service.GetPsnByPatientId(id)
  24625. PsnNo = psn_info.PsnNo
  24626. PsnCertType = psn_info.PsnCertType
  24627. Certno = psn_info.Certno
  24628. PsnName = psn_info.PsnName
  24629. Gend = psn_info.Gend
  24630. Naty = psn_info.Naty
  24631. Brdy = psn_info.Brdy
  24632. Age = psn_info.Age
  24633. infoStr = psn_info.Insuinfo
  24634. idetinfoStr = psn_info.Idetinfo
  24635. infocode = 0
  24636. verify_number = psn_info.VerifyNumber
  24637. } else if id_card_type == 2 {
  24638. psn_info, _ := service.GetPsnByPatientId(id)
  24639. PsnNo = psn_info.PsnNo
  24640. PsnCertType = psn_info.PsnCertType
  24641. Certno = psn_info.Certno
  24642. PsnName = psn_info.PsnName
  24643. Gend = psn_info.Gend
  24644. Naty = psn_info.Naty
  24645. Brdy = psn_info.Brdy
  24646. Age = psn_info.Age
  24647. infoStr = psn_info.Insuinfo
  24648. idetinfoStr = psn_info.Idetinfo
  24649. infocode = 0
  24650. verify_number = psn_info.VerifyNumber
  24651. } else {
  24652. psn_info, _ := service.GetPsnByPatientId(id)
  24653. PsnNo = psn_info.PsnNo
  24654. PsnCertType = psn_info.PsnCertType
  24655. Certno = psn_info.Certno
  24656. PsnName = psn_info.PsnName
  24657. Gend = psn_info.Gend
  24658. Naty = psn_info.Naty
  24659. Brdy = psn_info.Brdy
  24660. Age = psn_info.Age
  24661. infoStr = psn_info.Insuinfo
  24662. idetinfoStr = psn_info.Idetinfo
  24663. infocode = 0
  24664. verify_number = psn_info.VerifyNumber
  24665. }
  24666. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  24667. psn_info, _ := service.GetPsnByPatientId(id)
  24668. PsnNo = psn_info.PsnNo
  24669. PsnCertType = psn_info.PsnCertType
  24670. Certno = psn_info.Certno
  24671. PsnName = psn_info.PsnName
  24672. Gend = psn_info.Gend
  24673. Naty = psn_info.Naty
  24674. Brdy = psn_info.Brdy
  24675. Age = psn_info.Age
  24676. infoStr = psn_info.Insuinfo
  24677. idetinfoStr = psn_info.Idetinfo
  24678. infocode = 0
  24679. verify_number = psn_info.VerifyNumber
  24680. idetinfoStr = psn_info.Idetinfo
  24681. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24682. if id_card_type == 1 {
  24683. psn_info, _ := service.GetPsnByPatientId(id)
  24684. PsnNo = psn_info.PsnNo
  24685. PsnCertType = psn_info.PsnCertType
  24686. Certno = psn_info.Certno
  24687. PsnName = psn_info.PsnName
  24688. Gend = psn_info.Gend
  24689. Naty = psn_info.Naty
  24690. Brdy = psn_info.Brdy
  24691. Age = psn_info.Age
  24692. infoStr = psn_info.Insuinfo
  24693. idetinfoStr = psn_info.Idetinfo
  24694. infocode = 0
  24695. verify_number = psn_info.VerifyNumber
  24696. } else if id_card_type == 2 {
  24697. 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)
  24698. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24699. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24700. utils.ErrorLog("解析失败:%v", err)
  24701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24702. return
  24703. }
  24704. PsnNo = res.Output.Baseinfo.PsnNo
  24705. PsnCertType = res.Output.Baseinfo.PsnCertType
  24706. Certno = res.Output.Baseinfo.Certno
  24707. PsnName = res.Output.Baseinfo.PsnName
  24708. Gend = res.Output.Baseinfo.Gend
  24709. Naty = res.Output.Baseinfo.Naty
  24710. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24711. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24712. infoStr = string(Iinfos)
  24713. idetinfoStr = string(Idetinfos)
  24714. infocode = res.Infcode
  24715. } else if id_card_type == 4 {
  24716. psn_info, _ := service.GetPsnByPatientId(id)
  24717. PsnNo = psn_info.PsnNo
  24718. PsnCertType = psn_info.PsnCertType
  24719. Certno = psn_info.Certno
  24720. PsnName = psn_info.PsnName
  24721. Gend = psn_info.Gend
  24722. Naty = psn_info.Naty
  24723. Brdy = psn_info.Brdy
  24724. Age = psn_info.Age
  24725. infoStr = psn_info.Insuinfo
  24726. idetinfoStr = psn_info.Idetinfo
  24727. infocode = 0
  24728. verify_number = psn_info.VerifyNumber
  24729. }
  24730. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24731. var result string
  24732. var requestLog string
  24733. 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), "")
  24734. if id_card_type == 4 {
  24735. psn_info, _ := service.GetPsnByPatientId(id)
  24736. PsnNo = psn_info.PsnNo
  24737. PsnCertType = psn_info.PsnCertType
  24738. Certno = psn_info.Certno
  24739. PsnName = psn_info.PsnName
  24740. Gend = psn_info.Gend
  24741. Naty = psn_info.Naty
  24742. Brdy = psn_info.Brdy
  24743. Age = psn_info.Age
  24744. infoStr = psn_info.Insuinfo
  24745. idetinfoStr = psn_info.Idetinfo
  24746. infocode = 0
  24747. verify_number = psn_info.VerifyNumber
  24748. } else {
  24749. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24750. if miConfig.Code == "H15049901371" {
  24751. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24752. utils.ErrorLog("解析失败:%v", err)
  24753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24754. return
  24755. }
  24756. res.ErrMsg = res10265.ErrMsg
  24757. res.Output = res10265.Output
  24758. res.InfRefmsgid = res10265.InfRefmsgid
  24759. } else {
  24760. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24761. utils.ErrorLog("解析失败:%v", err)
  24762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24763. return
  24764. }
  24765. }
  24766. PsnNo = res.Output.Baseinfo.PsnNo
  24767. PsnCertType = res.Output.Baseinfo.PsnCertType
  24768. Certno = res.Output.Baseinfo.Certno
  24769. PsnName = res.Output.Baseinfo.PsnName
  24770. Gend = res.Output.Baseinfo.Gend
  24771. Naty = res.Output.Baseinfo.Naty
  24772. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24773. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24774. infoStr = string(Iinfos)
  24775. idetinfoStr = string(Idetinfos)
  24776. if miConfig.Code == "H15049901371" {
  24777. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24778. } else {
  24779. infocode = res.Infcode
  24780. }
  24781. }
  24782. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24783. psn_info, _ := service.GetPsnByPatientId(id)
  24784. PsnNo = psn_info.PsnNo
  24785. PsnCertType = psn_info.PsnCertType
  24786. Certno = psn_info.Certno
  24787. PsnName = psn_info.PsnName
  24788. Gend = psn_info.Gend
  24789. Naty = psn_info.Naty
  24790. Brdy = psn_info.Brdy
  24791. Age = psn_info.Age
  24792. infoStr = psn_info.Insuinfo
  24793. idetinfoStr = psn_info.Idetinfo
  24794. infocode = 0
  24795. verify_number = psn_info.VerifyNumber
  24796. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24797. psn_info, _ := service.GetPsnByPatientId(id)
  24798. PsnNo = psn_info.PsnNo
  24799. PsnCertType = psn_info.PsnCertType
  24800. Certno = psn_info.Certno
  24801. PsnName = psn_info.PsnName
  24802. Gend = psn_info.Gend
  24803. Naty = psn_info.Naty
  24804. Brdy = psn_info.Brdy
  24805. Age = psn_info.Age
  24806. infoStr = psn_info.Insuinfo
  24807. idetinfoStr = psn_info.Idetinfo
  24808. infocode = 0
  24809. verify_number = psn_info.VerifyNumber
  24810. } else {
  24811. var result string
  24812. var requestLog string
  24813. //if miConfig.UserOrgId == 10138 {
  24814. if id_card_type != 4 || id_card_type != 1 {
  24815. var insa string
  24816. if len(patient.InsuplcAdmdvs) > 0 {
  24817. insa = patient.InsuplcAdmdvs
  24818. } else {
  24819. insa = miConfig.InsuplcAdmdvs
  24820. }
  24821. //psn_info, _ := service.GetPsnByPatientId(id)
  24822. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  24823. 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)
  24824. }
  24825. //}
  24826. //else {
  24827. // var insa string
  24828. // if len(patient.InsuplcAdmdvs) > 0 {
  24829. // insa = patient.InsuplcAdmdvs
  24830. // } else {
  24831. // insa = miConfig.InsuplcAdmdvs
  24832. // }
  24833. // 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)
  24834. //}
  24835. if id_card_type == 4 || id_card_type == 1 {
  24836. psn_info, _ := service.GetPsnByPatientId(id)
  24837. PsnNo = psn_info.PsnNo
  24838. PsnCertType = psn_info.PsnCertType
  24839. Certno = psn_info.Certno
  24840. PsnName = psn_info.PsnName
  24841. Gend = psn_info.Gend
  24842. Naty = psn_info.Naty
  24843. Brdy = psn_info.Brdy
  24844. Age = psn_info.Age
  24845. infoStr = psn_info.Insuinfo
  24846. idetinfoStr = psn_info.Idetinfo
  24847. infocode = 0
  24848. verify_number = psn_info.VerifyNumber
  24849. } else {
  24850. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24851. if miConfig.Code == "H15049901371" {
  24852. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24853. utils.ErrorLog("解析失败:%v", err)
  24854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24855. return
  24856. }
  24857. res.ErrMsg = res10265.ErrMsg
  24858. res.Output = res10265.Output
  24859. res.InfRefmsgid = res10265.InfRefmsgid
  24860. } else {
  24861. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24862. utils.ErrorLog("解析失败:%v", err)
  24863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24864. return
  24865. }
  24866. }
  24867. PsnNo = res.Output.Baseinfo.PsnNo
  24868. PsnCertType = res.Output.Baseinfo.PsnCertType
  24869. Certno = res.Output.Baseinfo.Certno
  24870. PsnName = res.Output.Baseinfo.PsnName
  24871. Gend = res.Output.Baseinfo.Gend
  24872. Naty = res.Output.Baseinfo.Naty
  24873. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24874. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24875. infoStr = string(Iinfos)
  24876. idetinfoStr = string(Idetinfos)
  24877. if miConfig.Code == "H15049901371" {
  24878. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24879. } else {
  24880. infocode = res.Infcode
  24881. }
  24882. }
  24883. }
  24884. if infocode == 0 {
  24885. his := models.VMHisPatient{
  24886. Name: name,
  24887. Gender: gender,
  24888. Birthday: birthUnix,
  24889. MedicalTreatmentType: medical_care,
  24890. IdType: certificates,
  24891. IdCardNo: id_card,
  24892. BalanceAccountsType: settlementValue,
  24893. SocialType: social_type,
  24894. MedicalInsuranceNumber: medical_insurance_card,
  24895. RegisterType: register_type,
  24896. RegisterCost: registration_fee,
  24897. TreatmentCost: medical_expenses,
  24898. Status: 1,
  24899. Ctime: time.Now().Unix(),
  24900. Mtime: time.Now().Unix(),
  24901. PsnNo: PsnNo,
  24902. PsnCertType: PsnCertType,
  24903. Certno: Certno,
  24904. PsnName: PsnName,
  24905. Gend: Gend,
  24906. Naty: Naty,
  24907. Brdy: Brdy,
  24908. Age: Age,
  24909. Iinfo: infoStr,
  24910. Idetinfo: idetinfoStr,
  24911. PatientId: patient.ID,
  24912. RecordDate: theTime.Unix(),
  24913. UserOrgId: adminInfo.CurrentOrgId,
  24914. AdminUserId: admin_user_id,
  24915. IsReturn: 1,
  24916. IdCardType: id_card_type,
  24917. Doctor: doctor,
  24918. Departments: department,
  24919. MdtrtGrpType: mdtrt_type,
  24920. }
  24921. timestamp := time.Now().Unix()
  24922. tempTime := time.Unix(timestamp, 0)
  24923. timeFormat := tempTime.Format("20060102150405")
  24924. chrgBchno := rand.Intn(100000) + 10000
  24925. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  24926. his.Number = ipt_otp_no
  24927. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  24928. department, _ := service.GetDepartMentDetail(department)
  24929. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  24930. IdCardNo := ""
  24931. if id_card_type == 1 {
  24932. // IdCardNo = medical_insurance_card
  24933. IdCardNo = patient.IdCardNo
  24934. } else {
  24935. IdCardNo = patient.IdCardNo
  24936. }
  24937. var rf []*ResultFive
  24938. json.Unmarshal([]byte(his.Iinfo), &rf)
  24939. var insutypes []*ResultFive
  24940. var insutype string
  24941. var insuplc_admdvs_temp string
  24942. var is390 int = 0
  24943. var is310 int = 0
  24944. for _, item := range rf {
  24945. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24946. insutypes = append(insutypes, item)
  24947. }
  24948. }
  24949. if len(insutypes) == 1 {
  24950. insutype = insutypes[0].Insutype
  24951. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24952. if insutype == "390" {
  24953. is390 = 1
  24954. }
  24955. if insutype == "310" {
  24956. is310 = 1
  24957. }
  24958. } else {
  24959. for _, i := range insutypes {
  24960. if i.Insutype == "390" {
  24961. is390 = 1
  24962. }
  24963. if i.Insutype == "310" {
  24964. is310 = 1
  24965. }
  24966. }
  24967. }
  24968. if is390 == 1 {
  24969. insutype = "390"
  24970. }
  24971. if is310 == 1 {
  24972. insutype = "310"
  24973. }
  24974. fmt.Println(social_type)
  24975. if social_type > 0 {
  24976. insutype = strconv.FormatInt(social_type, 10)
  24977. }
  24978. var infocode int64
  24979. var resThree ResultThree
  24980. var resThree10265 ResultThree10265
  24981. if len(insuplc_admdvs) == 0 {
  24982. psn_info, _ := service.GetPsnByPatientId(id)
  24983. //if len(psn_info.InsuplcAdmdvs) > 0 {
  24984. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24985. //}
  24986. } else {
  24987. insuplc_admdvs_temp = insuplc_admdvs
  24988. }
  24989. if miConfig.MdtrtareaAdmvs == "421300" {
  24990. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24991. psn_info, _ := service.GetPsnByPatientId(id)
  24992. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24993. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24994. "&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
  24995. resp, requestErr := http.Get(api)
  24996. if requestErr != nil {
  24997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24998. return
  24999. }
  25000. body, ioErr := ioutil.ReadAll(resp.Body)
  25001. if ioErr != nil {
  25002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25004. return
  25005. }
  25006. var respJSON map[string]interface{}
  25007. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25010. return
  25011. }
  25012. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25013. result, _ := json.Marshal(respJSON)
  25014. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25015. utils.ErrorLog("解析失败:%v", err)
  25016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25017. return
  25018. }
  25019. infocode = resThree.Infcode
  25020. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25021. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25022. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25023. // insuplc_admdvs_temp =
  25024. //}
  25025. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25026. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25027. //}
  25028. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25029. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25030. "&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
  25031. resp, requestErr := http.Get(api)
  25032. if requestErr != nil {
  25033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25034. return
  25035. }
  25036. body, ioErr := ioutil.ReadAll(resp.Body)
  25037. if ioErr != nil {
  25038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25040. return
  25041. }
  25042. var respJSON map[string]interface{}
  25043. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25046. return
  25047. }
  25048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25049. result, _ := json.Marshal(respJSON)
  25050. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25051. utils.ErrorLog("解析失败:%v", err)
  25052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25053. return
  25054. }
  25055. infocode = resThree.Infcode
  25056. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25057. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25058. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25059. // insuplc_admdvs_temp =
  25060. //}
  25061. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25062. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25063. //}
  25064. utils.ErrorLog("解析失败:%v", insutype)
  25065. utils.ErrorLog("解析失败:%v", PsnNo)
  25066. utils.ErrorLog("解析失败:%v", Certno)
  25067. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  25068. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  25069. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  25070. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  25071. utils.ErrorLog("解析失败:%v", PsnNo)
  25072. utils.ErrorLog("解析失败:%v", department.Number)
  25073. utils.ErrorLog("解析失败:%v", department.Name)
  25074. utils.ErrorLog("解析失败:%v", roles.UserName)
  25075. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25076. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25077. "&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
  25078. resp, requestErr := http.Get(api)
  25079. if requestErr != nil {
  25080. utils.ErrorLog("解析失败:%v", requestErr)
  25081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25082. return
  25083. }
  25084. body, ioErr := ioutil.ReadAll(resp.Body)
  25085. if ioErr != nil {
  25086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25088. return
  25089. }
  25090. var respJSON map[string]interface{}
  25091. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25094. return
  25095. }
  25096. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25097. result, _ := json.Marshal(respJSON)
  25098. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25099. utils.ErrorLog("解析失败:%v", err)
  25100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25101. return
  25102. }
  25103. infocode = resThree.Infcode
  25104. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25105. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25106. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25107. // insuplc_admdvs_temp =
  25108. //}
  25109. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25110. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25111. //}
  25112. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25113. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25114. "&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
  25115. resp, requestErr := http.Get(api)
  25116. if requestErr != nil {
  25117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25118. return
  25119. }
  25120. body, ioErr := ioutil.ReadAll(resp.Body)
  25121. if ioErr != nil {
  25122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25124. return
  25125. }
  25126. var respJSON map[string]interface{}
  25127. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25130. return
  25131. }
  25132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25133. result, _ := json.Marshal(respJSON)
  25134. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25135. utils.ErrorLog("解析失败:%v", err)
  25136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25137. return
  25138. }
  25139. infocode = resThree.Infcode
  25140. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25141. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25142. psn_info, _ := service.GetPsnByPatientId(id)
  25143. var verify_number string
  25144. if id_card_type == 4 {
  25145. verify_number = psn_info.VerifyNumber
  25146. } else if id_card_type == 1 {
  25147. bas := strings.Split(psn_info.CardInfo, "|")
  25148. cardNumber := bas[2]
  25149. verify_number = cardNumber
  25150. }
  25151. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25152. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25153. "&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
  25154. resp, requestErr := http.Get(api)
  25155. if requestErr != nil {
  25156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25157. return
  25158. }
  25159. body, ioErr := ioutil.ReadAll(resp.Body)
  25160. if ioErr != nil {
  25161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25163. return
  25164. }
  25165. var respJSON map[string]interface{}
  25166. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25169. return
  25170. }
  25171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25172. result, _ := json.Marshal(respJSON)
  25173. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25174. // utils.ErrorLog("解析失败:%v", err)
  25175. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25176. // return
  25177. //}
  25178. //infocode = resThree.Infcode
  25179. //result, _ := json.Marshal(respJSON)
  25180. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25181. utils.ErrorLog("解析失败:%v", err)
  25182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25183. return
  25184. }
  25185. resThree.ErrMsg = resThree10265.ErrMsg
  25186. resThree.Output = resThree10265.Output
  25187. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25188. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25189. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  25190. psn_info, _ := service.GetPsnByPatientId(id)
  25191. his.PsnNo = psn_info.PsnNo
  25192. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25193. var cert_no string
  25194. if id_card_type == 3 {
  25195. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  25196. cert_no = IdCardNo
  25197. } else if id_card_type == 4 {
  25198. cert_no = IdCardNo
  25199. psn_info.VerifyNumber = psn_info.VerifyNumber
  25200. } else {
  25201. bas := strings.Split(psn_info.CardInfo, "|")
  25202. cert_no = bas[2]
  25203. }
  25204. var hisPrescription []*models.HisPrescription
  25205. fmt.Println(hisPrescription)
  25206. for _, item := range rf {
  25207. if item.Insutype == insutype {
  25208. //insuplc_admdvs = item.InsuplcAdmdvs
  25209. his.InsuplcAdmdvs = insuplc_admdvs
  25210. }
  25211. }
  25212. his.Insutype = insutype
  25213. var res3101 Result3101
  25214. res3101.Infcode = "0"
  25215. //res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25216. if res3101.Infcode == "0" {
  25217. fmt.Println("33333333")
  25218. if len(res3101.Output.Result) > 0 {
  25219. fmt.Println("222222")
  25220. for _, item := range res3101.Output.Result {
  25221. if len(res3101.ErrMsg) == 0 {
  25222. res3101.ErrMsg = item.VolaCont
  25223. } else {
  25224. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25225. }
  25226. }
  25227. c.ServeSuccessJSON(map[string]interface{}{
  25228. "failed_code": -10,
  25229. "msg": res3101.ErrMsg,
  25230. })
  25231. return
  25232. } else {
  25233. fmt.Println("11111")
  25234. var api string
  25235. if miConfig.MdtrtareaAdmvs == "320830" {
  25236. ipt_otp_no = timeFormat
  25237. api = miConfig.AppSecret + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25238. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25239. "&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
  25240. } else if miConfig.MdtrtareaAdmvs == "320921" {
  25241. ipt_otp_no = timeFormat
  25242. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25243. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25244. "&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
  25245. } else {
  25246. ipt_otp_no = timeFormat
  25247. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25248. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25249. "&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
  25250. }
  25251. resp, requestErr := http.Get(api)
  25252. if requestErr != nil {
  25253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25254. return
  25255. }
  25256. body, ioErr := ioutil.ReadAll(resp.Body)
  25257. if ioErr != nil {
  25258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25260. return
  25261. }
  25262. var respJSON map[string]interface{}
  25263. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25266. return
  25267. }
  25268. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25269. result, _ := json.Marshal(respJSON)
  25270. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25271. utils.ErrorLog("解析失败:%v", err)
  25272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25273. return
  25274. }
  25275. resThree.ErrMsg = resThree10265.ErrMsg
  25276. resThree.Output = resThree10265.Output
  25277. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25278. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25279. }
  25280. } else if res3101.Infcode != "0" {
  25281. c.ServeSuccessJSON(map[string]interface{}{
  25282. "failed_code": -10,
  25283. "msg": res3101.ErrMsg,
  25284. })
  25285. return
  25286. }
  25287. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25288. psn_info, _ := service.GetPsnByPatientId(id)
  25289. var cert_no string
  25290. if id_card_type == 1 {
  25291. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25292. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25293. } else if id_card_type == 4 {
  25294. cert_no = psn_info.VerifyNumber
  25295. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25296. } else {
  25297. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25298. cert_no = psn_info.VerifyNumber
  25299. }
  25300. 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)
  25301. saveLog(result, requestLog, "2201", "挂号")
  25302. if miConfig.Code == "H15049901371" {
  25303. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25304. utils.ErrorLog("解析失败:%v", err)
  25305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25306. return
  25307. }
  25308. resThree.ErrMsg = resThree10265.ErrMsg
  25309. resThree.Output = resThree10265.Output
  25310. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25311. } else {
  25312. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25313. utils.ErrorLog("解析失败:%v", err)
  25314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25315. return
  25316. }
  25317. }
  25318. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25319. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  25320. psn_info, _ := service.GetPsnByPatientId(id)
  25321. var result string
  25322. var requestLog string
  25323. if id_card_type == 1 {
  25324. bas := strings.Split(psn_info.CardInfo, "|")
  25325. basNumber := bas[2]
  25326. card_sn := bas[3]
  25327. 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)
  25328. saveLog(result, requestLog, "2201A", "挂号")
  25329. } else if id_card_type == 2 {
  25330. 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, "", "", "", "", "", "")
  25331. saveLog(result, requestLog, "2201A", "挂号")
  25332. } else {
  25333. 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)
  25334. saveLog(result, requestLog, "2201A", "挂号")
  25335. }
  25336. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25337. utils.ErrorLog("解析失败:%v", err)
  25338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25339. return
  25340. }
  25341. infocode = resThree.Infcode
  25342. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  25343. psn_info, _ := service.GetPsnByPatientId(id)
  25344. var result string
  25345. var requestLog string
  25346. if id_card_type == 1 {
  25347. bas := strings.Split(psn_info.CardInfo, "|")
  25348. basNumber := bas[2]
  25349. card_sn := ""
  25350. 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)
  25351. saveLog(result, requestLog, "2201A", "挂号")
  25352. } else if id_card_type == 2 {
  25353. 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, "", "", "", "", "", "")
  25354. saveLog(result, requestLog, "2201A", "挂号")
  25355. } else {
  25356. 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)
  25357. saveLog(result, requestLog, "2201A", "挂号")
  25358. }
  25359. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25360. utils.ErrorLog("解析失败:%v", err)
  25361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25362. return
  25363. }
  25364. infocode = resThree.Infcode
  25365. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  25366. psn_info, _ := service.GetPsnByPatientId(id)
  25367. var result string
  25368. var requestLog string
  25369. if id_card_type == 1 {
  25370. bas := strings.Split(psn_info.CardInfo, "|")
  25371. basNumber := bas[2]
  25372. card_sn := ""
  25373. 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)
  25374. saveLog(result, requestLog, "2201A", "挂号")
  25375. } else if id_card_type == 2 {
  25376. 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, "", "", "", "", "", "")
  25377. saveLog(result, requestLog, "2201A", "挂号")
  25378. } else {
  25379. 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)
  25380. saveLog(result, requestLog, "2201A", "挂号")
  25381. }
  25382. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25383. utils.ErrorLog("解析失败:%v", err)
  25384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25385. return
  25386. }
  25387. infocode = resThree.Infcode
  25388. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25389. psn_info, _ := service.GetPsnByPatientId(id)
  25390. his.PsnNo = psn_info.PsnNo
  25391. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25392. var cert_no string
  25393. if id_card_type == 1 {
  25394. bas := strings.Split(psn_info.CardInfo, "|")
  25395. cert_no = bas[2]
  25396. } else if id_card_type == 4 {
  25397. cert_no = psn_info.VerifyNumber
  25398. psn_info.VerifyNumber = psn_info.VerifyNumber
  25399. IdCardNo = psn_info.VerifyNumber
  25400. } else {
  25401. cert_no = IdCardNo
  25402. psn_info.VerifyNumber = cert_no
  25403. }
  25404. for _, item := range rf {
  25405. if item.Insutype == insutype {
  25406. his.InsuplcAdmdvs = insuplc_admdvs
  25407. }
  25408. }
  25409. his.Insutype = insutype
  25410. var api string
  25411. ipt_otp_no = timeFormat
  25412. 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 +
  25413. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25414. "&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
  25415. resp, requestErr := http.Get(api)
  25416. if requestErr != nil {
  25417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25418. return
  25419. }
  25420. body, ioErr := ioutil.ReadAll(resp.Body)
  25421. if ioErr != nil {
  25422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25424. return
  25425. }
  25426. var respJSON map[string]interface{}
  25427. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25430. return
  25431. }
  25432. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25433. if status == "0" {
  25434. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25435. c.ServeSuccessJSON(map[string]interface{}{
  25436. "failed_code": -10,
  25437. "msg": err_msg,
  25438. })
  25439. return
  25440. }
  25441. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25442. result, _ := json.Marshal(respJSON)
  25443. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25444. utils.ErrorLog("解析失败:%v", err)
  25445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25446. return
  25447. }
  25448. infocode = resThree.Infcode
  25449. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25450. psn_info, _ := service.GetPsnByPatientId(id)
  25451. his.PsnNo = psn_info.PsnNo
  25452. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25453. var cert_no string
  25454. if id_card_type == 1 {
  25455. bas := strings.Split(psn_info.CardInfo, "|")
  25456. cert_no = bas[2]
  25457. } else if id_card_type == 4 {
  25458. cert_no = psn_info.VerifyNumber
  25459. psn_info.VerifyNumber = psn_info.VerifyNumber
  25460. IdCardNo = psn_info.VerifyNumber
  25461. } else {
  25462. cert_no = IdCardNo
  25463. psn_info.VerifyNumber = cert_no
  25464. }
  25465. for _, item := range rf {
  25466. if item.Insutype == insutype {
  25467. his.InsuplcAdmdvs = insuplc_admdvs
  25468. patient.InsuplcAdmdvs = insuplc_admdvs
  25469. }
  25470. }
  25471. his.Insutype = insutype
  25472. var api string
  25473. ipt_otp_no = timeFormat
  25474. 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 +
  25475. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25476. "&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
  25477. resp, requestErr := http.Get(api)
  25478. if requestErr != nil {
  25479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25480. return
  25481. }
  25482. body, ioErr := ioutil.ReadAll(resp.Body)
  25483. if ioErr != nil {
  25484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25486. return
  25487. }
  25488. var respJSON map[string]interface{}
  25489. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25492. return
  25493. }
  25494. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25495. if status == "0" {
  25496. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25497. c.ServeSuccessJSON(map[string]interface{}{
  25498. "failed_code": -10,
  25499. "msg": err_msg,
  25500. })
  25501. return
  25502. }
  25503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25504. result, _ := json.Marshal(respJSON)
  25505. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25506. utils.ErrorLog("解析失败:%v", err)
  25507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25508. return
  25509. }
  25510. infocode = resThree.Infcode
  25511. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25512. hour := time.Now().Format("15")
  25513. min := time.Now().Format("04")
  25514. sec := time.Now().Format("05")
  25515. begin := record_time + " " + hour + ":" + min + ":" + sec
  25516. psn_info, _ := service.GetPsnByPatientId(id)
  25517. var result string
  25518. var requestLog string
  25519. if id_card_type == 1 {
  25520. bas := strings.Split(psn_info.CardInfo, "|")
  25521. basNumber := bas[2]
  25522. card_sn := bas[3]
  25523. 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)
  25524. saveLog(result, requestLog, "2201A", "挂号")
  25525. } else if id_card_type == 2 {
  25526. 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)
  25527. saveLog(result, requestLog, "2201A", "挂号")
  25528. } else {
  25529. 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)
  25530. saveLog(result, requestLog, "2201A", "挂号")
  25531. }
  25532. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25533. utils.ErrorLog("解析失败:%v", err)
  25534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25535. return
  25536. }
  25537. infocode = resThree.Infcode
  25538. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25539. psn_info, _ := service.GetPsnByPatientId(id)
  25540. 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)
  25541. saveLog(result, requestLog, "2201A", "挂号")
  25542. if miConfig.Code == "H15049901371" {
  25543. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25544. utils.ErrorLog("解析失败:%v", err)
  25545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25546. return
  25547. }
  25548. resThree.ErrMsg = resThree10265.ErrMsg
  25549. resThree.Output = resThree10265.Output
  25550. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25551. } else {
  25552. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25553. utils.ErrorLog("解析失败:%v", err)
  25554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25555. return
  25556. }
  25557. }
  25558. if miConfig.Code == "H15049901371" {
  25559. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25560. } else {
  25561. infocode = resThree.Infcode
  25562. }
  25563. } else {
  25564. psn_info, _ := service.GetPsnByPatientId(id)
  25565. if id_card_type == 4 || id_card_type == 1 {
  25566. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25567. }
  25568. var rf []*ResultFive
  25569. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25570. var insutypes []*ResultFive
  25571. var insutype string
  25572. var is390 int = 0
  25573. var is310 int = 0
  25574. for _, item := range rf {
  25575. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25576. insutypes = append(insutypes, item)
  25577. }
  25578. }
  25579. if len(insutypes) == 1 {
  25580. insutype = insutypes[0].Insutype
  25581. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25582. } else {
  25583. for _, i := range insutypes {
  25584. if i.Insutype == "390" {
  25585. is390 = 1
  25586. }
  25587. if i.Insutype == "310" {
  25588. is310 = 1
  25589. }
  25590. }
  25591. }
  25592. if is390 == 1 {
  25593. insutype = "390"
  25594. }
  25595. if is310 == 1 {
  25596. insutype = "310"
  25597. }
  25598. fmt.Println(len(insutypes))
  25599. if len(insutypes) == 0 {
  25600. for index, item := range rf {
  25601. if index == 0 {
  25602. insutype = item.Insutype
  25603. insuplc_admdvs = item.InsuplcAdmdvs
  25604. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25605. }
  25606. }
  25607. fmt.Println(insutype)
  25608. fmt.Println(insuplc_admdvs)
  25609. }
  25610. if social_type > 0 {
  25611. insutype = strconv.FormatInt(social_type, 10)
  25612. }
  25613. fmt.Println("--------")
  25614. fmt.Println(psn_info)
  25615. fmt.Println(psn_info.PsnNo)
  25616. for _, item := range rf {
  25617. if item.Insutype == insutype {
  25618. insutype = item.Insutype
  25619. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25620. }
  25621. }
  25622. if miConfig.MdtrtareaAdmvs == "441202" {
  25623. var hisPrescription []*models.HisPrescription
  25624. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25625. if res3101.Infcode == 0 {
  25626. fmt.Println("33333333")
  25627. if len(res3101.Output.Result) > 0 {
  25628. fmt.Println("222222")
  25629. for _, item := range res3101.Output.Result {
  25630. if len(res3101.ErrMsg) == 0 {
  25631. res3101.ErrMsg = item.VolaCont
  25632. } else {
  25633. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25634. }
  25635. }
  25636. c.ServeSuccessJSON(map[string]interface{}{
  25637. "failed_code": -10,
  25638. "msg": res3101.ErrMsg,
  25639. })
  25640. return
  25641. } else {
  25642. hour := time.Now().Format("15")
  25643. min := time.Now().Format("04")
  25644. sec := time.Now().Format("05")
  25645. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25646. fmt.Println(record_time_two)
  25647. 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)
  25648. saveLog(result, requestLog, "2201A", "挂号")
  25649. if miConfig.Code == "H15049901371" {
  25650. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25651. utils.ErrorLog("解析失败:%v", err)
  25652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25653. return
  25654. }
  25655. resThree.ErrMsg = resThree10265.ErrMsg
  25656. resThree.Output = resThree10265.Output
  25657. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25658. } else {
  25659. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25660. utils.ErrorLog("解析失败:%v", err)
  25661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25662. return
  25663. }
  25664. }
  25665. if miConfig.Code == "H15049901371" {
  25666. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25667. } else {
  25668. infocode = resThree.Infcode
  25669. }
  25670. }
  25671. } else if res3101.Infcode != 0 {
  25672. c.ServeSuccessJSON(map[string]interface{}{
  25673. "failed_code": -10,
  25674. "msg": res3101.ErrMsg,
  25675. })
  25676. return
  25677. }
  25678. } else if miConfig.MdtrtareaAdmvs == "440205" {
  25679. var hisPrescription []*models.HisPrescription
  25680. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25681. if res3101.Infcode == 0 {
  25682. fmt.Println("33333333")
  25683. if len(res3101.Output.Result) > 0 {
  25684. fmt.Println("222222")
  25685. for _, item := range res3101.Output.Result {
  25686. if len(res3101.ErrMsg) == 0 {
  25687. res3101.ErrMsg = item.VolaCont
  25688. } else {
  25689. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25690. }
  25691. }
  25692. c.ServeSuccessJSON(map[string]interface{}{
  25693. "failed_code": -10,
  25694. "msg": res3101.ErrMsg,
  25695. })
  25696. return
  25697. } else {
  25698. hour := time.Now().Format("15")
  25699. min := time.Now().Format("04")
  25700. sec := time.Now().Format("05")
  25701. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25702. fmt.Println(record_time_two)
  25703. 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)
  25704. saveLog(result, requestLog, "2201A", "挂号")
  25705. if miConfig.Code == "H15049901371" {
  25706. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25707. utils.ErrorLog("解析失败:%v", err)
  25708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25709. return
  25710. }
  25711. resThree.ErrMsg = resThree10265.ErrMsg
  25712. resThree.Output = resThree10265.Output
  25713. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25714. } else {
  25715. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25716. utils.ErrorLog("解析失败:%v", err)
  25717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25718. return
  25719. }
  25720. }
  25721. if miConfig.Code == "H15049901371" {
  25722. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25723. } else {
  25724. infocode = resThree.Infcode
  25725. }
  25726. }
  25727. } else if res3101.Infcode != 0 {
  25728. c.ServeSuccessJSON(map[string]interface{}{
  25729. "failed_code": -10,
  25730. "msg": res3101.ErrMsg,
  25731. })
  25732. return
  25733. }
  25734. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25735. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25736. psn_info, _ := service.GetPsnByPatientId(id)
  25737. var verify_number string
  25738. if id_card_type == 4 {
  25739. verify_number = psn_info.VerifyNumber
  25740. } else if id_card_type == 1 {
  25741. bas := strings.Split(psn_info.CardInfo, "|")
  25742. cardNumber := bas[2]
  25743. verify_number = cardNumber
  25744. } else {
  25745. verify_number = psn_info.Certno
  25746. }
  25747. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25748. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25749. "&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
  25750. resp, requestErr := http.Get(api)
  25751. if requestErr != nil {
  25752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25753. return
  25754. }
  25755. body, ioErr := ioutil.ReadAll(resp.Body)
  25756. if ioErr != nil {
  25757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25759. return
  25760. }
  25761. var respJSON map[string]interface{}
  25762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25765. return
  25766. }
  25767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25768. result, _ := json.Marshal(respJSON)
  25769. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25770. utils.ErrorLog("解析失败:%v", err)
  25771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25772. return
  25773. }
  25774. infocode = resThree.Infcode
  25775. } else {
  25776. hour := time.Now().Format("15")
  25777. min := time.Now().Format("04")
  25778. sec := time.Now().Format("05")
  25779. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25780. if id_card_type == 1 {
  25781. for _, item := range rf {
  25782. if item.Insutype == strconv.FormatInt(social_type, 10) {
  25783. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  25784. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25785. } else if strconv.FormatInt(social_type, 10) == "390" {
  25786. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25787. } else {
  25788. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25789. }
  25790. }
  25791. }
  25792. }
  25793. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  25794. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25795. }
  25796. if id_card_type == 1 {
  25797. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  25798. bas := strings.Split(psn_info.CardInfo, "|")
  25799. basNumber := bas[1]
  25800. IdCardNo = basNumber
  25801. }
  25802. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  25803. IdCardNo = psn_info.VerifyNumber
  25804. }
  25805. if len(insuplc_admdvs_temp) == 0 {
  25806. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25807. }
  25808. var result string
  25809. var requestLog string
  25810. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  25811. var hisPrescription []*models.HisPrescription
  25812. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25813. if res3101.Infcode == 0 {
  25814. if len(res3101.Output.Result) > 0 {
  25815. if len(res3101.Output.Result) > 0 {
  25816. c.ServeSuccessJSON(map[string]interface{}{
  25817. "failed_code": -10,
  25818. "failed_type": 100,
  25819. "warm_type": 1,
  25820. "msg": res3101,
  25821. })
  25822. return
  25823. } else {
  25824. c.ServeSuccessJSON(map[string]interface{}{
  25825. "failed_code": -10,
  25826. "msg": res3101.ErrMsg,
  25827. })
  25828. return
  25829. }
  25830. } else {
  25831. hour := time.Now().Format("15")
  25832. min := time.Now().Format("04")
  25833. sec := time.Now().Format("05")
  25834. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25835. fmt.Println(record_time_two)
  25836. if his.IdCardType == 2 {
  25837. IdCardNo = psn_info.Certno
  25838. psn_info.VerifyNumber = psn_info.Certno
  25839. } else if his.IdCardType == 4 {
  25840. IdCardNo = psn_info.Certno
  25841. } else {
  25842. bas := strings.Split(psn_info.CardInfo, "|")
  25843. IdCardNo = bas[2]
  25844. }
  25845. aaaa = insutype
  25846. 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)
  25847. saveLog(result, requestLog, "2201A", "挂号")
  25848. if miConfig.Code == "H15049901371" {
  25849. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25850. utils.ErrorLog("解析失败:%v", err)
  25851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25852. return
  25853. }
  25854. resThree.ErrMsg = resThree10265.ErrMsg
  25855. resThree.Output = resThree10265.Output
  25856. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25857. } else {
  25858. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25859. utils.ErrorLog("解析失败:%v", err)
  25860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25861. return
  25862. }
  25863. }
  25864. if miConfig.Code == "H15049901371" {
  25865. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25866. } else {
  25867. infocode = resThree.Infcode
  25868. }
  25869. }
  25870. } else if res3101.Infcode != 0 {
  25871. c.ServeSuccessJSON(map[string]interface{}{
  25872. "failed_code": -10,
  25873. "msg": res3101.ErrMsg,
  25874. })
  25875. return
  25876. }
  25877. } else {
  25878. psn_info, _ := service.GetPsnByPatientId(id)
  25879. var rf []*ResultFive
  25880. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25881. //var insutypes []*ResultFive
  25882. var insutype string
  25883. var insutypes []*ResultFive
  25884. var is390 int = 0
  25885. var is310 int = 0
  25886. for _, item := range rf {
  25887. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25888. insutypes = append(insutypes, item)
  25889. }
  25890. }
  25891. if len(insutypes) == 1 {
  25892. insutype = insutypes[0].Insutype
  25893. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25894. } else {
  25895. for _, i := range insutypes {
  25896. if i.Insutype == "390" {
  25897. is390 = 1
  25898. }
  25899. if i.Insutype == "310" {
  25900. is310 = 1
  25901. }
  25902. }
  25903. }
  25904. if is390 == 1 {
  25905. insutype = "390"
  25906. }
  25907. if is310 == 1 {
  25908. insutype = "310"
  25909. }
  25910. if len(insutypes) == 0 {
  25911. insutype = "310"
  25912. }
  25913. if social_type > 0 {
  25914. insutype = strconv.FormatInt(social_type, 10)
  25915. }
  25916. for _, item := range rf {
  25917. if item.Insutype == insutype {
  25918. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25919. }
  25920. }
  25921. if len(insuplc_admdvs_tt) > 0 {
  25922. insuplc_admdvs_temp = insuplc_admdvs_tt
  25923. }
  25924. 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)
  25925. saveLog(result, requestLog, "2201A", "挂号")
  25926. }
  25927. if miConfig.Code == "H15049901371" {
  25928. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25929. utils.ErrorLog("解析失败:%v", err)
  25930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25931. return
  25932. }
  25933. resThree.ErrMsg = resThree10265.ErrMsg
  25934. resThree.Output = resThree10265.Output
  25935. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25936. } else {
  25937. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25938. utils.ErrorLog("解析失败:%v", err)
  25939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25940. return
  25941. }
  25942. }
  25943. if miConfig.Code == "H15049901371" {
  25944. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25945. } else {
  25946. infocode = resThree.Infcode
  25947. }
  25948. }
  25949. }
  25950. if infocode == -1 {
  25951. adminUser := c.GetAdminUserInfo()
  25952. errlog := &models.HisOrderError{
  25953. UserOrgId: adminUser.CurrentOrgId,
  25954. Ctime: time.Now().Unix(),
  25955. Mtime: time.Now().Unix(),
  25956. ErrMsg: resThree.ErrMsg,
  25957. Status: 1,
  25958. PatientId: id,
  25959. RecordTime: recordDateTime,
  25960. Stage: 2,
  25961. }
  25962. service.CreateErrMsgLog(errlog)
  25963. c.ServeSuccessJSON(map[string]interface{}{
  25964. "failed_code": -10,
  25965. "msg": resThree.ErrMsg,
  25966. })
  25967. return
  25968. }
  25969. utils.ErrorLog("解析失败:%v", insutype)
  25970. his.Number = resThree.Output.Data.MdtrtID
  25971. his.PsnNo = resThree.Output.Data.PsnNo
  25972. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  25973. his.IdCardNo = patient.IdCardNo
  25974. his.PhoneNumber = patient.Phone
  25975. his.UserOrgId = adminInfo.CurrentOrgId
  25976. his.Insutype = insutype
  25977. if miConfig.Code == "H44030500255" {
  25978. his.Insutype = aaaa
  25979. }
  25980. his.Ctime = time.Now().Unix()
  25981. his.Mtime = time.Now().Unix()
  25982. his.InsuplcAdmdvs = insuplc_admdvs_temp
  25983. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  25984. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25985. }
  25986. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  25987. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25988. }
  25989. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  25990. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25991. }
  25992. his.Status = 1
  25993. his.MdtrtGrpType = mdtrt_type
  25994. service.UpdateHisPatientStatus(&his)
  25995. service.UpdateHisPatient123(&patient)
  25996. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  25997. c.ServeSuccessJSON(map[string]interface{}{
  25998. "his_info": his,
  25999. })
  26000. } else {
  26001. adminUser := c.GetAdminUserInfo()
  26002. errlog := &models.HisOrderError{
  26003. UserOrgId: adminUser.CurrentOrgId,
  26004. Ctime: time.Now().Unix(),
  26005. Mtime: time.Now().Unix(),
  26006. ErrMsg: res.ErrMsg,
  26007. Status: 1,
  26008. PatientId: id,
  26009. RecordTime: recordDateTime,
  26010. Stage: 1,
  26011. }
  26012. service.CreateErrMsgLog(errlog)
  26013. c.ServeSuccessJSON(map[string]interface{}{
  26014. "failed_code": -10,
  26015. "msg": res.ErrMsg,
  26016. })
  26017. return
  26018. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26019. }
  26020. }
  26021. }
  26022. func (c *HisApiController) GetUploadInfo() {
  26023. id, _ := c.GetInt64("id")
  26024. record_time := c.GetString("record_time")
  26025. his_patient_id, _ := c.GetInt64("his_patient_id")
  26026. order_id, _ := c.GetInt64("order_id")
  26027. pay_way, _ := c.GetInt64("pay_way")
  26028. pay_ways := c.GetString("pay_ways")
  26029. oth_desc := c.GetString("oth_desc")
  26030. pay_price, _ := c.GetFloat("pay_price")
  26031. pay_card_no := c.GetString("pay_card_no")
  26032. discount_price, _ := c.GetFloat("discount_price")
  26033. preferential_price, _ := c.GetFloat("preferential_price")
  26034. reality_price, _ := c.GetFloat("reality_price")
  26035. found_price, _ := c.GetFloat("found_price")
  26036. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  26037. private_price, _ := c.GetFloat("private_price")
  26038. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  26039. admin_user_id, _ := c.GetInt64("admin_user_id")
  26040. fapiao_code := c.GetString("fapiao_code")
  26041. fapiao_number := c.GetString("fapiao_number")
  26042. diagnosis_id := c.GetString("diagnosis")
  26043. sick_type, _ := c.GetInt64("sick_type")
  26044. reg_type, _ := c.GetInt64("p_type")
  26045. begin_time := c.GetString("begin_time")
  26046. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  26047. cash_pay := c.GetString("cash_pay")
  26048. band_card_pay := c.GetString("band_card_pay")
  26049. wechat_pay := c.GetString("wechat_pay")
  26050. ali_pay := c.GetString("ali_pay")
  26051. jifen_pay := c.GetString("jifen_pay")
  26052. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  26053. fmt.Println(acct_used_flag)
  26054. id_str := c.GetString("ids")
  26055. ids_arr := strings.Split(id_str, ",")
  26056. timeLayout := "2006-01-02"
  26057. loc, _ := time.LoadLocation("Local")
  26058. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26059. if err != nil {
  26060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26061. return
  26062. }
  26063. recordDateTime := theTime.Unix()
  26064. adminUser := c.GetAdminUserInfo()
  26065. var tempOrder models.HisOrder
  26066. tempOrder, _ = service.GetHisOrderByID(order_id)
  26067. var prescriptions []*models.HisPrescription
  26068. var start_time int64
  26069. var end_time int64
  26070. //押金模块
  26071. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  26072. tmp_decimal := c.GetString("tmp_decimal")
  26073. var decimal float64 //本次使用的押金
  26074. var errmsg error
  26075. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  26076. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  26077. return
  26078. }
  26079. if len(tmp_decimal) > 0 {
  26080. if tmp_decimal[0] == 45 {
  26081. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  26082. return
  26083. }
  26084. }
  26085. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  26086. fmt.Println(errs)
  26087. decimal = tt
  26088. //if adminUser.CurrentOrgId == 10106{
  26089. // if len(fapiao_code) == 0{
  26090. // fapiao_code = "144072080589"
  26091. // }
  26092. // if len(fapiao_number) == 0{
  26093. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  26094. // if order.ID == 0{
  26095. // fapiao_number = "00001520"
  26096. // }else{
  26097. // //fapiao_code = "00001520"
  26098. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  26099. // var zero string
  26100. // if fpNumber >= 1000{
  26101. // zero = "0000" + strconv.Itoa(fpNumber)
  26102. // }else if fpNumber >= 10000{
  26103. // zero = "000" + strconv.Itoa(fpNumber)
  26104. // } else if fpNumber >= 100000{
  26105. // zero = "00" + strconv.Itoa(fpNumber)
  26106. // } else if fpNumber >= 1000000{
  26107. // zero = "0" + strconv.Itoa(fpNumber)
  26108. // }else {
  26109. // zero = strconv.Itoa(fpNumber)
  26110. // }
  26111. // fapiao_number = zero
  26112. // }
  26113. // }
  26114. //}
  26115. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26116. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26117. var patientPrescription models.HisPrescriptionInfo
  26118. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26119. if patientPrescription.ID == 0 {
  26120. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26121. }
  26122. //if patientPrescription.Do
  26123. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26124. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26125. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26126. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26127. var config []*models.HisXtDiagnoseConfig
  26128. for _, item := range diagnosis_ids {
  26129. id, _ := strconv.ParseInt(item, 10, 64)
  26130. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26131. config = append(config, &diagnosisConfig)
  26132. }
  26133. sickConfig, _ := service.FindSickById(sick_type)
  26134. //if tempOrder.ID == 0 {
  26135. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  26136. //}
  26137. if tempOrder.ID == 0 {
  26138. var result string
  26139. var requestLog string
  26140. var res2 ResultSix
  26141. var res3 GZResultSix
  26142. var ressix10265 ResultSix10265
  26143. if miConfig.MdtrtareaAdmvs == "421300" {
  26144. data := make(map[string]interface{})
  26145. client := &http.Client{}
  26146. data["psn_no"] = his.PsnNo
  26147. data["mdtrt_id"] = his.Number
  26148. data["opter"] = roles.UserName
  26149. data["org_name"] = miConfig.OrgName
  26150. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26151. data["doctor_id"] = doctor_info.DoctorNumber
  26152. data["doctor_name"] = doctor_info.UserName
  26153. data["department"] = department.Name
  26154. data["fixmedins_code"] = miConfig.Code
  26155. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26156. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26157. data["secret_key"] = miConfig.SecretKey
  26158. data["sick_code"] = sickConfig.CountryCode
  26159. data["sick_name"] = sickConfig.ClassName
  26160. data["dept"] = strconv.FormatInt(department.ID, 10)
  26161. data["config"] = config
  26162. data["begin_time"] = begin_time
  26163. bytesData, _ := json.Marshal(data)
  26164. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26165. resp, _ := client.Do(req)
  26166. defer resp.Body.Close()
  26167. body, ioErr := ioutil.ReadAll(resp.Body)
  26168. if ioErr != nil {
  26169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26171. return
  26172. }
  26173. var respJSON map[string]interface{}
  26174. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26177. return
  26178. }
  26179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26180. userJSONBytes, _ := json.Marshal(respJSON)
  26181. fmt.Println("log")
  26182. fmt.Println(string(userJSONBytes))
  26183. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26184. utils.ErrorLog("解析失败:%v", err)
  26185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26186. return
  26187. }
  26188. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26189. data := make(map[string]interface{})
  26190. client := &http.Client{}
  26191. data["psn_no"] = his.PsnNo
  26192. data["mdtrt_id"] = his.Number
  26193. data["opter"] = roles.UserName
  26194. data["org_name"] = miConfig.OrgName
  26195. if reg_type == 11 && his.Insutype == "390" {
  26196. data["med_type"] = "110104"
  26197. } else {
  26198. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26199. }
  26200. data["doctor_id"] = doctor_info.DoctorNumber
  26201. data["doctor_name"] = doctor_info.UserName
  26202. data["department"] = department.Name
  26203. data["fixmedins_code"] = miConfig.Code
  26204. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26205. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26206. data["secret_key"] = miConfig.SecretKey
  26207. data["sick_code"] = sickConfig.CountryCode
  26208. data["sick_name"] = sickConfig.ClassName
  26209. data["dept"] = strconv.FormatInt(department.ID, 10)
  26210. data["config"] = config
  26211. data["begin_time"] = begin_time
  26212. bytesData, _ := json.Marshal(data)
  26213. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26214. resp, _ := client.Do(req)
  26215. defer resp.Body.Close()
  26216. body, ioErr := ioutil.ReadAll(resp.Body)
  26217. if ioErr != nil {
  26218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26220. return
  26221. }
  26222. var respJSON map[string]interface{}
  26223. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26226. return
  26227. }
  26228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26229. userJSONBytes, _ := json.Marshal(respJSON)
  26230. fmt.Println("log")
  26231. fmt.Println(string(userJSONBytes))
  26232. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26233. utils.ErrorLog("解析失败:%v", err)
  26234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26235. return
  26236. }
  26237. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26238. data := make(map[string]interface{})
  26239. client := &http.Client{}
  26240. data["psn_no"] = his.PsnNo
  26241. data["mdtrt_id"] = his.Number
  26242. data["opter"] = roles.UserName
  26243. data["org_name"] = miConfig.OrgName
  26244. if reg_type == 11 && his.Insutype == "390" {
  26245. data["med_type"] = "110104"
  26246. } else {
  26247. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26248. }
  26249. data["doctor_id"] = doctor_info.DoctorNumber
  26250. data["doctor_name"] = doctor_info.UserName
  26251. data["department"] = department.Name
  26252. data["fixmedins_code"] = miConfig.Code
  26253. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26254. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26255. data["secret_key"] = miConfig.SecretKey
  26256. data["sick_code"] = sickConfig.CountryCode
  26257. data["sick_name"] = sickConfig.ClassName
  26258. data["dept"] = strconv.FormatInt(department.ID, 10)
  26259. data["config"] = config
  26260. data["begin_time"] = begin_time
  26261. bytesData, _ := json.Marshal(data)
  26262. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26263. resp, _ := client.Do(req)
  26264. defer resp.Body.Close()
  26265. body, ioErr := ioutil.ReadAll(resp.Body)
  26266. if ioErr != nil {
  26267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26269. return
  26270. }
  26271. var respJSON map[string]interface{}
  26272. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26275. return
  26276. }
  26277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26278. userJSONBytes, _ := json.Marshal(respJSON)
  26279. fmt.Println("log")
  26280. fmt.Println(string(userJSONBytes))
  26281. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26282. utils.ErrorLog("解析失败:%v", err)
  26283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26284. return
  26285. }
  26286. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26287. data := make(map[string]interface{})
  26288. client := &http.Client{}
  26289. data["psn_no"] = his.PsnNo
  26290. data["mdtrt_id"] = his.Number
  26291. data["opter"] = roles.UserName
  26292. data["org_name"] = miConfig.OrgName
  26293. if reg_type == 11 && his.Insutype == "390" {
  26294. data["med_type"] = "110104"
  26295. } else {
  26296. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26297. }
  26298. data["doctor_id"] = doctor_info.DoctorNumber
  26299. data["doctor_name"] = doctor_info.UserName
  26300. data["department"] = department.Name
  26301. data["fixmedins_code"] = miConfig.Code
  26302. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26303. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26304. data["secret_key"] = miConfig.SecretKey
  26305. data["sick_code"] = sickConfig.CountryCode
  26306. data["sick_name"] = sickConfig.ClassName
  26307. data["dept"] = strconv.FormatInt(department.ID, 10)
  26308. data["config"] = config
  26309. data["begin_time"] = begin_time
  26310. bytesData, _ := json.Marshal(data)
  26311. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26312. resp, _ := client.Do(req)
  26313. defer resp.Body.Close()
  26314. body, ioErr := ioutil.ReadAll(resp.Body)
  26315. if ioErr != nil {
  26316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26318. return
  26319. }
  26320. var respJSON map[string]interface{}
  26321. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26324. return
  26325. }
  26326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26327. userJSONBytes, _ := json.Marshal(respJSON)
  26328. fmt.Println("log")
  26329. fmt.Println(string(userJSONBytes))
  26330. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26331. utils.ErrorLog("解析失败:%v", err)
  26332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26333. return
  26334. }
  26335. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26336. data := make(map[string]interface{})
  26337. client := &http.Client{}
  26338. data["psn_no"] = his.PsnNo
  26339. data["mdtrt_id"] = his.Number
  26340. data["doctor"] = roles.UserName
  26341. data["department"] = department.Name
  26342. data["org_name"] = miConfig.OrgName
  26343. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26344. data["doctor_id"] = doctor_info.DoctorNumber
  26345. data["new_doctor_name"] = doctor_info.UserName
  26346. data["fixmedins_code"] = miConfig.Code
  26347. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26348. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26349. data["secret_key"] = miConfig.SecretKey
  26350. data["sick_code"] = sickConfig.CountryCode
  26351. data["sick_name"] = sickConfig.ClassName
  26352. data["url"] = miConfig.Url
  26353. data["ak"] = miConfig.AccessKey
  26354. data["begin_time"] = begin_time
  26355. data["cainfo"] = miConfig.Cainfo
  26356. data["dept"] = strconv.FormatInt(department.ID, 10)
  26357. data["config"] = config
  26358. bytesData, _ := json.Marshal(data)
  26359. var req *http.Request
  26360. if miConfig.MdtrtareaAdmvs == "320830" {
  26361. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  26362. //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 +
  26363. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26364. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26365. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26366. //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 +
  26367. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26368. } else {
  26369. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26370. }
  26371. resp, _ := client.Do(req)
  26372. defer resp.Body.Close()
  26373. body, ioErr := ioutil.ReadAll(resp.Body)
  26374. if ioErr != nil {
  26375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26377. return
  26378. }
  26379. var respJSON map[string]interface{}
  26380. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26383. return
  26384. }
  26385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26386. userJSONBytes, _ := json.Marshal(respJSON)
  26387. fmt.Println("log")
  26388. fmt.Println(string(userJSONBytes))
  26389. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26390. utils.ErrorLog("解析失败:%v", err)
  26391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26392. return
  26393. }
  26394. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26395. res2.Output = ressix10265.Output
  26396. res2.ErrMsg = ressix10265.ErrMsg
  26397. res2.Cainfo = ressix10265.Cainfo
  26398. res2.WarnMsg = ressix10265.WarnMsg
  26399. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26400. res2.Infcode = infocode
  26401. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26402. data := make(map[string]interface{})
  26403. client := &http.Client{}
  26404. data["psn_no"] = his.PsnNo
  26405. data["mdtrt_id"] = his.Number
  26406. data["doctor"] = roles.UserName
  26407. data["department"] = department.Name
  26408. data["org_name"] = miConfig.OrgName
  26409. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26410. data["doctor_id"] = doctor_info.DoctorNumber
  26411. data["new_doctor_name"] = doctor_info.UserName
  26412. data["fixmedins_code"] = miConfig.Code
  26413. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26414. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26415. data["secret_key"] = miConfig.SecretKey
  26416. data["sick_code"] = sickConfig.CountryCode
  26417. data["sick_name"] = sickConfig.ClassName
  26418. data["url"] = miConfig.Url
  26419. data["ak"] = miConfig.AccessKey
  26420. data["begin_time"] = begin_time
  26421. data["cainfo"] = miConfig.Cainfo
  26422. data["dept"] = strconv.FormatInt(department.ID, 10)
  26423. data["config"] = config
  26424. bytesData, _ := json.Marshal(data)
  26425. var req *http.Request
  26426. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26427. resp, _ := client.Do(req)
  26428. defer resp.Body.Close()
  26429. body, ioErr := ioutil.ReadAll(resp.Body)
  26430. if ioErr != nil {
  26431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26433. return
  26434. }
  26435. var respJSON map[string]interface{}
  26436. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26439. return
  26440. }
  26441. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26442. userJSONBytes, _ := json.Marshal(respJSON)
  26443. fmt.Println("log")
  26444. fmt.Println(string(userJSONBytes))
  26445. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26446. utils.ErrorLog("解析失败:%v", err)
  26447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26448. return
  26449. }
  26450. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26451. res2.Output = ressix10265.Output
  26452. res2.ErrMsg = ressix10265.ErrMsg
  26453. res2.Cainfo = ressix10265.Cainfo
  26454. res2.WarnMsg = ressix10265.WarnMsg
  26455. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26456. res2.Infcode = infocode
  26457. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26458. 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)
  26459. saveLog(result, requestLog, "2203", "上传就诊信息")
  26460. var respJSON2 map[string]interface{}
  26461. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26464. return
  26465. }
  26466. userJSONBytes2, _ := json.Marshal(respJSON2)
  26467. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26468. utils.ErrorLog("解析失败:%v", err)
  26469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26470. return
  26471. }
  26472. 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)
  26473. fmt.Println(result2)
  26474. fmt.Println(src_request)
  26475. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26476. data := make(map[string]interface{})
  26477. client := &http.Client{}
  26478. data["psn_no"] = his.PsnNo
  26479. data["mdtrt_id"] = his.Number
  26480. data["doctor"] = roles.UserName
  26481. data["department"] = department.Name
  26482. data["org_name"] = miConfig.OrgName
  26483. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26484. data["doctor_id"] = doctor_info.DoctorNumber
  26485. data["new_doctor_name"] = doctor_info.UserName
  26486. data["fixmedins_code"] = miConfig.Code
  26487. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26488. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26489. data["secret_key"] = miConfig.SecretKey
  26490. data["sick_code"] = sickConfig.CountryCode
  26491. data["sick_name"] = sickConfig.ClassName
  26492. data["url"] = miConfig.Url
  26493. data["ak"] = miConfig.AccessKey
  26494. data["begin_time"] = begin_time
  26495. data["cainfo"] = miConfig.Cainfo
  26496. data["dept"] = strconv.FormatInt(department.ID, 10)
  26497. data["config"] = config
  26498. bytesData, _ := json.Marshal(data)
  26499. var req *http.Request
  26500. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  26501. resp, _ := client.Do(req)
  26502. defer resp.Body.Close()
  26503. body, ioErr := ioutil.ReadAll(resp.Body)
  26504. if ioErr != nil {
  26505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26507. return
  26508. }
  26509. var respJSON map[string]interface{}
  26510. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26513. return
  26514. }
  26515. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26516. userJSONBytes, _ := json.Marshal(respJSON)
  26517. fmt.Println("log")
  26518. fmt.Println(string(userJSONBytes))
  26519. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26520. utils.ErrorLog("解析失败:%v", err)
  26521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26522. return
  26523. }
  26524. } else {
  26525. if miConfig.MdtrtareaAdmvs == "440781" { //
  26526. 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)
  26527. } else {
  26528. if miConfig.Code == "H15049901371" {
  26529. //赤峰地区国家医保医疗类别
  26530. //职工透析:医疗类别选特殊情况门诊990502
  26531. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26532. var med_type string
  26533. if his.Insutype == "390" {
  26534. if reg_type == 14 {
  26535. med_type = "9933"
  26536. } else if reg_type == 11 {
  26537. med_type = "11"
  26538. }
  26539. } else if his.Insutype == "310" {
  26540. if reg_type == 14 {
  26541. med_type = "990502"
  26542. } else if reg_type == 11 {
  26543. med_type = "11"
  26544. }
  26545. }
  26546. 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)
  26547. } else {
  26548. 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)
  26549. }
  26550. }
  26551. saveLog(result, requestLog, "2203", "上传就诊信息")
  26552. var respJSON2 map[string]interface{}
  26553. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26556. return
  26557. }
  26558. userJSONBytes2, _ := json.Marshal(respJSON2)
  26559. if miConfig.Code == "H15049901371" {
  26560. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  26561. utils.ErrorLog("解析失败:%v", err)
  26562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26563. return
  26564. }
  26565. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26566. res2.Output = ressix10265.Output
  26567. res2.ErrMsg = ressix10265.ErrMsg
  26568. res2.Cainfo = ressix10265.Cainfo
  26569. res2.WarnMsg = ressix10265.WarnMsg
  26570. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26571. res2.Infcode = infocode
  26572. } else {
  26573. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26574. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26575. utils.ErrorLog("解析失败:%v", err)
  26576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26577. return
  26578. }
  26579. res2.Infcode = res3.Infcode
  26580. } else {
  26581. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26582. utils.ErrorLog("解析失败:%v", err)
  26583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26584. return
  26585. }
  26586. }
  26587. }
  26588. }
  26589. if res2.Infcode == -1 {
  26590. adminUser := c.GetAdminUserInfo()
  26591. errlog := &models.HisOrderError{
  26592. UserOrgId: adminUser.CurrentOrgId,
  26593. Ctime: time.Now().Unix(),
  26594. Mtime: time.Now().Unix(),
  26595. ErrMsg: res2.ErrMsg,
  26596. Status: 1,
  26597. PatientId: id,
  26598. RecordTime: recordDateTime,
  26599. Stage: 3,
  26600. }
  26601. service.CreateErrMsgLog(errlog)
  26602. c.ServeSuccessJSON(map[string]interface{}{
  26603. "failed_code": -10,
  26604. "msg": res2.ErrMsg,
  26605. })
  26606. return
  26607. } else {
  26608. his.Diagnosis = diagnosis_id
  26609. his.SickType = sickConfig.ID
  26610. //var p_type int64
  26611. //if reg_type == 1111 || reg_type == 1112 {
  26612. // p_type = 11
  26613. //
  26614. //}
  26615. his.PType = fmt.Sprintf("%d", reg_type)
  26616. service.UpdateHisPatientThree(&his)
  26617. data := make(map[string]interface{})
  26618. if settle_accounts_type == 1 { //日结
  26619. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26620. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26621. } else {
  26622. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26623. }
  26624. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  26625. data["pre"] = prescriptions
  26626. } else { //月结
  26627. start_time_str := c.GetString("start_time")
  26628. end_time_str := c.GetString("end_time")
  26629. timeLayout := "2006-01-02"
  26630. loc, _ := time.LoadLocation("Local")
  26631. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26632. if err != nil {
  26633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26634. return
  26635. }
  26636. recordStartTime := theStartTime.Unix()
  26637. start_time = recordStartTime
  26638. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26639. if err != nil {
  26640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26641. return
  26642. }
  26643. recordEndTime := theEndTime.Unix()
  26644. end_time = recordEndTime
  26645. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26646. data["pre"] = prescriptions
  26647. }
  26648. timestamp := time.Now().Unix()
  26649. tempTime := time.Unix(timestamp, 0)
  26650. timeFormat := tempTime.Format("20060102150405")
  26651. chrgBchno := rand.Intn(100000) + 10000
  26652. new_chrg_bchno := ""
  26653. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  26654. new_chrg_bchno = chrg_bchno
  26655. strconv.FormatInt(his.PatientId, 10)
  26656. client := &http.Client{}
  26657. if adminUser.CurrentOrgId == 10265 {
  26658. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26659. new_chrg_bchno = "0000"
  26660. }
  26661. }
  26662. data["psn_no"] = his.PsnNo
  26663. data["mdtrt_id"] = his.Number
  26664. data["chrg_bchno"] = new_chrg_bchno
  26665. data["org_name"] = miConfig.OrgName
  26666. data["doctor"] = doctor_info.UserName
  26667. data["doctor_id"] = doctor_info.DoctorNumber
  26668. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  26669. data["fixmedins_code"] = miConfig.Code
  26670. data["dept_code"] = department.Number
  26671. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26672. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26673. data["secret_key"] = miConfig.SecretKey
  26674. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26675. data["url"] = miConfig.Url
  26676. data["ak"] = miConfig.AccessKey
  26677. data["new_doctor_name"] = patientPrescription.Doctor
  26678. data["diag_code"] = sickConfig.CountryCode
  26679. data["cainfo"] = miConfig.Cainfo
  26680. data["opter"] = roles.UserName
  26681. var ids []int64
  26682. for _, item := range prescriptions {
  26683. ids = append(ids, item.ID)
  26684. }
  26685. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26686. if config.IsOpen == 1 { //对接了医保,走医保流程
  26687. var res ResultFour
  26688. var resFour10265 ResultFour10265
  26689. if miConfig.MdtrtareaAdmvs == "421300" {
  26690. bytesData, _ := json.Marshal(data)
  26691. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26692. resp, _ := client.Do(req)
  26693. defer resp.Body.Close()
  26694. body, ioErr := ioutil.ReadAll(resp.Body)
  26695. if ioErr != nil {
  26696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26698. return
  26699. }
  26700. var respJSON map[string]interface{}
  26701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26704. return
  26705. }
  26706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26707. userJSONBytes, _ := json.Marshal(respJSON)
  26708. fmt.Println("log")
  26709. fmt.Println(string(userJSONBytes))
  26710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26711. utils.ErrorLog("解析失败:%v", err)
  26712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26713. return
  26714. }
  26715. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26716. bytesData, _ := json.Marshal(data)
  26717. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26718. resp, _ := client.Do(req)
  26719. defer resp.Body.Close()
  26720. body, ioErr := ioutil.ReadAll(resp.Body)
  26721. if ioErr != nil {
  26722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26724. return
  26725. }
  26726. var respJSON map[string]interface{}
  26727. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26730. return
  26731. }
  26732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26733. userJSONBytes, _ := json.Marshal(respJSON)
  26734. fmt.Println("log")
  26735. fmt.Println(string(userJSONBytes))
  26736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26737. utils.ErrorLog("解析失败:%v", err)
  26738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26739. return
  26740. }
  26741. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26742. bytesData, _ := json.Marshal(data)
  26743. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26744. resp, _ := client.Do(req)
  26745. defer resp.Body.Close()
  26746. body, ioErr := ioutil.ReadAll(resp.Body)
  26747. if ioErr != nil {
  26748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26750. return
  26751. }
  26752. var respJSON map[string]interface{}
  26753. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26756. return
  26757. }
  26758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26759. userJSONBytes, _ := json.Marshal(respJSON)
  26760. fmt.Println("log")
  26761. fmt.Println(string(userJSONBytes))
  26762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26763. utils.ErrorLog("解析失败:%v", err)
  26764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26765. return
  26766. }
  26767. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26768. bytesData, _ := json.Marshal(data)
  26769. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26770. resp, _ := client.Do(req)
  26771. defer resp.Body.Close()
  26772. body, ioErr := ioutil.ReadAll(resp.Body)
  26773. if ioErr != nil {
  26774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26776. return
  26777. }
  26778. var respJSON map[string]interface{}
  26779. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26782. return
  26783. }
  26784. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26785. userJSONBytes, _ := json.Marshal(respJSON)
  26786. fmt.Println("log")
  26787. fmt.Println(string(userJSONBytes))
  26788. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26789. utils.ErrorLog("解析失败:%v", err)
  26790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26791. return
  26792. }
  26793. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26794. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26795. var result3101 Result3101
  26796. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26797. result3101.Infcode = "0"
  26798. if result3101.Infcode == "0" {
  26799. if len(result3101.Output.Result) > 0 {
  26800. var errMsgs []string
  26801. for _, item := range result3101.Output.Result {
  26802. errMsgs = append(errMsgs, item.VolaCont)
  26803. }
  26804. c.ServeSuccessJSON(map[string]interface{}{
  26805. "failed_code": -10,
  26806. "msg": errMsgs,
  26807. })
  26808. return
  26809. }
  26810. }
  26811. bytesData, _ := json.Marshal(data)
  26812. var req *http.Request
  26813. if miConfig.MdtrtareaAdmvs == "320830" {
  26814. data["diag_code"] = sickConfig.CountryCode
  26815. fmt.Println(data)
  26816. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  26817. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26818. data["diag_code"] = sickConfig.CountryCode
  26819. fmt.Println(data)
  26820. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26821. } else {
  26822. data["diag_code"] = sickConfig.CountryCode
  26823. fmt.Println(data)
  26824. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26825. }
  26826. resp, _ := client.Do(req)
  26827. defer resp.Body.Close()
  26828. body, ioErr := ioutil.ReadAll(resp.Body)
  26829. if ioErr != nil {
  26830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26832. return
  26833. }
  26834. var respJSON map[string]interface{}
  26835. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26838. return
  26839. }
  26840. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26841. userJSONBytes, _ := json.Marshal(respJSON)
  26842. fmt.Println("log")
  26843. fmt.Println(string(userJSONBytes))
  26844. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26845. utils.ErrorLog("解析失败:%v", err)
  26846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26847. return
  26848. }
  26849. res.InfRefmsgid = resFour10265.InfRefmsgid
  26850. res.Output = resFour10265.Output
  26851. res.ErrMsg = resFour10265.ErrMsg
  26852. res.Cainfo = resFour10265.Cainfo
  26853. res.WarnMsg = resFour10265.WarnMsg
  26854. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26855. res.Infcode = infocode
  26856. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26857. var pagesize int = 2
  26858. var start int = 1
  26859. var stop int
  26860. var pagecount int
  26861. var curpage int
  26862. var isSuccess bool = true
  26863. data["doctor_id"] = doctor_info.DoctorNumber
  26864. //总页数,向上取整,注意除之前要先转换类型为float64
  26865. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  26866. for curpage = 1; curpage <= pagecount; curpage++ {
  26867. if curpage == 1 {
  26868. start = 1
  26869. } else {
  26870. start = (curpage-1)*pagesize + 1
  26871. }
  26872. stop = curpage * pagesize
  26873. if stop > len(prescriptions) {
  26874. stop = len(prescriptions)
  26875. }
  26876. //var requestLog string
  26877. data["pre"] = prescriptions[start-1 : stop]
  26878. fmt.Println(data["pre"])
  26879. bytesData, _ := json.Marshal(data)
  26880. var req *http.Request
  26881. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  26882. resp, _ := client.Do(req)
  26883. defer resp.Body.Close()
  26884. body, ioErr := ioutil.ReadAll(resp.Body)
  26885. if ioErr != nil {
  26886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26888. return
  26889. }
  26890. var respJSON map[string]interface{}
  26891. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26894. return
  26895. }
  26896. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26897. userJSONBytes, _ := json.Marshal(respJSON)
  26898. fmt.Println("log")
  26899. fmt.Println(string(userJSONBytes))
  26900. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26901. utils.ErrorLog("解析失败:%v", err)
  26902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26903. return
  26904. }
  26905. res.InfRefmsgid = resFour10265.InfRefmsgid
  26906. res.Output = resFour10265.Output
  26907. res.ErrMsg = resFour10265.ErrMsg
  26908. res.Cainfo = resFour10265.Cainfo
  26909. res.WarnMsg = resFour10265.WarnMsg
  26910. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26911. res.Infcode = infocode
  26912. if infocode == 0 {
  26913. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  26914. } else {
  26915. isSuccess = false
  26916. errlog := &models.HisOrderError{
  26917. UserOrgId: adminUser.CurrentOrgId,
  26918. Ctime: time.Now().Unix(),
  26919. Mtime: time.Now().Unix(),
  26920. Number: chrg_bchno,
  26921. ErrMsg: "",
  26922. Status: 1,
  26923. PatientId: id,
  26924. RecordTime: recordDateTime,
  26925. Stage: 4,
  26926. }
  26927. service.CreateErrMsgLog(errlog)
  26928. c.ServeSuccessJSON(map[string]interface{}{
  26929. "failed_code": -10,
  26930. "msg": res.ErrMsg,
  26931. })
  26932. return
  26933. }
  26934. }
  26935. if isSuccess {
  26936. res.Infcode = 0
  26937. }
  26938. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26939. 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)
  26940. var dat map[string]interface{}
  26941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26942. fmt.Println(dat)
  26943. } else {
  26944. fmt.Println(err)
  26945. }
  26946. saveLog(result, request_log, "2204", "上传费用明细")
  26947. userJSONBytes, _ := json.Marshal(dat)
  26948. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26949. utils.ErrorLog("解析失败:%v", err)
  26950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26951. return
  26952. }
  26953. res.InfRefmsgid = resFour10265.InfRefmsgid
  26954. res.Output = resFour10265.Output
  26955. res.ErrMsg = resFour10265.ErrMsg
  26956. res.Cainfo = resFour10265.Cainfo
  26957. res.WarnMsg = resFour10265.WarnMsg
  26958. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26959. res.Infcode = infocode
  26960. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26961. bytesData, _ := json.Marshal(data)
  26962. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  26963. resp, _ := client.Do(req)
  26964. defer resp.Body.Close()
  26965. body, ioErr := ioutil.ReadAll(resp.Body)
  26966. if ioErr != nil {
  26967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26969. return
  26970. }
  26971. var respJSON map[string]interface{}
  26972. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26975. return
  26976. }
  26977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26978. userJSONBytes, _ := json.Marshal(respJSON)
  26979. fmt.Println("log")
  26980. fmt.Println(string(userJSONBytes))
  26981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26982. utils.ErrorLog("解析失败:%v", err)
  26983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26984. return
  26985. }
  26986. } else {
  26987. if miConfig.Code == "H15049901371" {
  26988. 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)
  26989. var dat map[string]interface{}
  26990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26991. fmt.Println(dat)
  26992. } else {
  26993. fmt.Println(err)
  26994. }
  26995. saveLog(result, request_log, "2204", "上传费用明细")
  26996. userJSONBytes, _ := json.Marshal(dat)
  26997. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26998. utils.ErrorLog("解析失败:%v", err)
  26999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27000. return
  27001. }
  27002. res.InfRefmsgid = resFour10265.InfRefmsgid
  27003. res.Output = resFour10265.Output
  27004. res.ErrMsg = resFour10265.ErrMsg
  27005. res.Cainfo = resFour10265.Cainfo
  27006. res.WarnMsg = resFour10265.WarnMsg
  27007. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27008. res.Infcode = infocode
  27009. } else {
  27010. 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)
  27011. var dat map[string]interface{}
  27012. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27013. fmt.Println(dat)
  27014. } else {
  27015. fmt.Println(err)
  27016. }
  27017. saveLog(result, request_log, "2204", "上传费用明细")
  27018. userJSONBytes, _ := json.Marshal(dat)
  27019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27020. utils.ErrorLog("解析失败:%v", err)
  27021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27022. return
  27023. }
  27024. }
  27025. }
  27026. if res.Infcode == 0 {
  27027. order := &models.HisOrder{
  27028. UserOrgId: adminUser.CurrentOrgId,
  27029. HisPatientId: his.ID,
  27030. PatientId: his.PatientId,
  27031. SettleAccountsDate: recordDateTime,
  27032. MdtrtId: his.Number,
  27033. PsnNo: his.PsnNo,
  27034. MedType: strconv.FormatInt(reg_type, 10),
  27035. Ctime: time.Now().Unix(),
  27036. Mtime: time.Now().Unix(),
  27037. Status: 1,
  27038. Number: chrg_bchno,
  27039. Infcode: res.Infcode,
  27040. WarnMsg: res.WarnMsg,
  27041. Cainfo: res.Cainfo,
  27042. ErrMsg: res.ErrMsg,
  27043. RespondTime: res.RefmsgTime,
  27044. InfRefmsgid: res.InfRefmsgid,
  27045. OrderStatus: 1,
  27046. PayWay: pay_way,
  27047. PayWays: pay_ways,
  27048. OthDesc: oth_desc,
  27049. PayPrice: pay_price,
  27050. PayCardNo: pay_card_no,
  27051. DiscountPrice: discount_price,
  27052. PreferentialPrice: preferential_price,
  27053. RealityPrice: reality_price,
  27054. FoundPrice: found_price,
  27055. MedicalInsurancePrice: medical_insurance_price,
  27056. PrivatePrice: private_price,
  27057. IsMedicineInsurance: 1,
  27058. SettleType: settle_accounts_type,
  27059. SettleStartTime: start_time,
  27060. SettleEndTime: end_time,
  27061. Creator: roles.AdminUserId,
  27062. Modify: roles.AdminUserId,
  27063. FaPiaoNumber: fapiao_number,
  27064. FaPiaoCode: fapiao_code,
  27065. PType: 2,
  27066. Diagnosis: diagnosis_id,
  27067. CashPay: cash_pay,
  27068. WechatPay: wechat_pay,
  27069. AliPay: ali_pay,
  27070. JifenPay: jifen_pay,
  27071. BandCardPay: band_card_pay,
  27072. }
  27073. err = service.CreateOrder(order)
  27074. if err != nil {
  27075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27076. return
  27077. }
  27078. for _, item := range res.Output.Result {
  27079. temp := strings.Split(item.FeedetlSn, "-")
  27080. var advice_id int64 = 0
  27081. var project_id int64 = 0
  27082. var types int64 = 0
  27083. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27084. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27085. if temp[1] == "1" {
  27086. advice_id = id
  27087. project_id = 0
  27088. } else if temp[1] == "2" {
  27089. advice_id = 0
  27090. project_id = id
  27091. }
  27092. if item.MedChrgitmType == "9" {
  27093. item.MedChrgitmType = "09"
  27094. }
  27095. info := &models.HisOrderInfo{
  27096. OrderNumber: order.Number,
  27097. FeedetlSn: item.FeedetlSn,
  27098. UploadDate: time.Now().Unix(),
  27099. AdviceId: advice_id,
  27100. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27101. Cnt: item.Cnt,
  27102. Pric: float64(item.Pric),
  27103. PatientId: his.PatientId,
  27104. PricUplmtAmt: item.PricUplmtAmt,
  27105. SelfpayProp: item.SelfpayProp,
  27106. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27107. OverlmtAmt: item.OverlmtAmt,
  27108. PreselfpayAmt: item.PreselfpayAmt,
  27109. BasMednFlag: item.BasMednFlag,
  27110. MedChrgitmType: item.MedChrgitmType,
  27111. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27112. Status: 1,
  27113. Memo: item.Memo,
  27114. Mtime: time.Now().Unix(),
  27115. InscpScpAmt: item.InscpScpAmt,
  27116. DrtReimFlag: item.DrtReimFlag,
  27117. Ctime: time.Now().Unix(),
  27118. ListSpItemFlag: item.ListSpItemFlag,
  27119. ChldMedcFlag: item.ChldMedcFlag,
  27120. LmtUsedFlag: item.LmtUsedFlag,
  27121. ChrgitmLv: item.ChrgitmLv,
  27122. UserOrgId: adminUser.CurrentOrgId,
  27123. HisPatientId: his.ID,
  27124. OrderId: order.ID,
  27125. ProjectId: project_id,
  27126. Type: types,
  27127. }
  27128. service.CreateOrderInfo(info)
  27129. }
  27130. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27131. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27132. var total float64
  27133. for _, item := range prescriptions {
  27134. if item.Type == 1 { //药品
  27135. for _, subItem := range item.HisDoctorAdviceInfo {
  27136. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27137. total_one := price * subItem.PrescribingNumber
  27138. total = total + total_one
  27139. }
  27140. }
  27141. if item.Type == 2 { //项目
  27142. for _, subItem := range item.HisPrescriptionProject {
  27143. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27144. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27145. total_one := price * cnt
  27146. total = total + total_one
  27147. }
  27148. }
  27149. }
  27150. allTotal := fmt.Sprintf("%.2f", total)
  27151. //if adminUser.CurrentOrgId == 9919 {
  27152. //
  27153. // allTotal = fmt.Sprintf("%.2f", total)
  27154. //
  27155. //} else {
  27156. //
  27157. // allTotal = fmt.Sprintf("%.2f", total)
  27158. //
  27159. //}
  27160. if res.Infcode == 0 {
  27161. var rf []*ResultFive
  27162. json.Unmarshal([]byte(his.Iinfo), &rf)
  27163. chrg_bchno := chrg_bchno
  27164. cert_no := his.Certno
  27165. var insutypes []string
  27166. var insutype string
  27167. var is390 int = 0
  27168. var is310 int = 0
  27169. for _, item := range rf {
  27170. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27171. insutypes = append(insutypes, item.Insutype)
  27172. }
  27173. }
  27174. if len(insutypes) == 1 {
  27175. insutype = insutypes[0]
  27176. } else {
  27177. for _, i := range insutypes {
  27178. if i == "390" {
  27179. is390 = 1
  27180. }
  27181. if i == "310" {
  27182. is310 = 1
  27183. }
  27184. }
  27185. }
  27186. if is390 == 1 {
  27187. insutype = "390"
  27188. }
  27189. if is310 == 1 {
  27190. insutype = "310"
  27191. }
  27192. if len(insutypes) == 0 {
  27193. insutype = "310"
  27194. }
  27195. if len(insutypes) == 2 {
  27196. insutype = strconv.FormatInt(his.SocialType, 10)
  27197. }
  27198. insutype = strconv.FormatInt(his.SocialType, 10)
  27199. //insutype = "390"
  27200. if his.IdCardType == 1 {
  27201. // cert_no = his.MedicalInsuranceNumber
  27202. cert_no = his.Certno
  27203. } else {
  27204. cert_no = his.Certno
  27205. }
  27206. var res ResultSeven
  27207. var resSeven10265 ResultSeven10265
  27208. var gzresSeven10265Two GZResultSeven10265Two
  27209. var src_resquest string
  27210. var result2 string
  27211. if miConfig.MdtrtareaAdmvs == "421300" {
  27212. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27213. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27214. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27215. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27216. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27217. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27218. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27219. resp, requestErr := http.Get(api)
  27220. if requestErr != nil {
  27221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27222. return
  27223. }
  27224. body, ioErr := ioutil.ReadAll(resp.Body)
  27225. if ioErr != nil {
  27226. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27228. return
  27229. }
  27230. var respJSON map[string]interface{}
  27231. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27234. return
  27235. }
  27236. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27237. result, _ := json.Marshal(respJSON)
  27238. if miConfig.Code == "H15049901371" {
  27239. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27240. utils.ErrorLog("解析失败:%v", err)
  27241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27242. return
  27243. }
  27244. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27245. res.Output = resSeven10265.Output
  27246. res.ErrMsg = resSeven10265.ErrMsg
  27247. res.Cainfo = resSeven10265.Cainfo
  27248. res.WarnMsg = resSeven10265.WarnMsg
  27249. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27250. res.Infcode = infocode
  27251. } else {
  27252. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27253. utils.ErrorLog("解析失败:%v", err)
  27254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27255. return
  27256. }
  27257. }
  27258. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27259. if reg_type == 11 && his.Insutype == "390" {
  27260. reg_type = 110104
  27261. }
  27262. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27263. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27264. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27265. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27266. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27267. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27268. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27269. resp, requestErr := http.Get(api)
  27270. if requestErr != nil {
  27271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27272. return
  27273. }
  27274. body, ioErr := ioutil.ReadAll(resp.Body)
  27275. if ioErr != nil {
  27276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27278. return
  27279. }
  27280. var respJSON map[string]interface{}
  27281. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27284. return
  27285. }
  27286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27287. result, _ := json.Marshal(respJSON)
  27288. if miConfig.Code == "H15049901371" {
  27289. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27290. utils.ErrorLog("解析失败:%v", err)
  27291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27292. return
  27293. }
  27294. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27295. res.Output = resSeven10265.Output
  27296. res.ErrMsg = resSeven10265.ErrMsg
  27297. res.Cainfo = resSeven10265.Cainfo
  27298. res.WarnMsg = resSeven10265.WarnMsg
  27299. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27300. res.Infcode = infocode
  27301. } else {
  27302. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27303. utils.ErrorLog("解析失败:%v", err)
  27304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27305. return
  27306. }
  27307. }
  27308. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27309. if reg_type == 11 && his.Insutype == "390" {
  27310. reg_type = 110104
  27311. }
  27312. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27313. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27314. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27315. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27316. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27317. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27318. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27319. resp, requestErr := http.Get(api)
  27320. if requestErr != nil {
  27321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27322. return
  27323. }
  27324. body, ioErr := ioutil.ReadAll(resp.Body)
  27325. if ioErr != nil {
  27326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27328. return
  27329. }
  27330. var respJSON map[string]interface{}
  27331. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27334. return
  27335. }
  27336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27337. result, _ := json.Marshal(respJSON)
  27338. if miConfig.Code == "H15049901371" {
  27339. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27340. utils.ErrorLog("解析失败:%v", err)
  27341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27342. return
  27343. }
  27344. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27345. res.Output = resSeven10265.Output
  27346. res.ErrMsg = resSeven10265.ErrMsg
  27347. res.Cainfo = resSeven10265.Cainfo
  27348. res.WarnMsg = resSeven10265.WarnMsg
  27349. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27350. res.Infcode = infocode
  27351. } else {
  27352. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27353. utils.ErrorLog("解析失败:%v", err)
  27354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27355. return
  27356. }
  27357. }
  27358. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27359. if reg_type == 11 && his.Insutype == "390" {
  27360. reg_type = 110104
  27361. }
  27362. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27363. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27364. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27365. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27366. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27367. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27368. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27369. resp, requestErr := http.Get(api)
  27370. if requestErr != nil {
  27371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27372. return
  27373. }
  27374. body, ioErr := ioutil.ReadAll(resp.Body)
  27375. if ioErr != nil {
  27376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27378. return
  27379. }
  27380. var respJSON map[string]interface{}
  27381. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27384. return
  27385. }
  27386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27387. result, _ := json.Marshal(respJSON)
  27388. if miConfig.Code == "H15049901371" {
  27389. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27390. utils.ErrorLog("解析失败:%v", err)
  27391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27392. return
  27393. }
  27394. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27395. res.Output = resSeven10265.Output
  27396. res.ErrMsg = resSeven10265.ErrMsg
  27397. res.Cainfo = resSeven10265.Cainfo
  27398. res.WarnMsg = resSeven10265.WarnMsg
  27399. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27400. res.Infcode = infocode
  27401. } else {
  27402. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27403. utils.ErrorLog("解析失败:%v", err)
  27404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27405. return
  27406. }
  27407. }
  27408. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27409. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  27410. var result3101 Result3101
  27411. //utils.ErrorLog("解析失败:%v", result3101)
  27412. result3101.Infcode = "0"
  27413. if result3101.Infcode == "0" {
  27414. if len(result3101.Output.Result) > 0 {
  27415. var errMsgs []string
  27416. for _, item := range result3101.Output.Result {
  27417. errMsgs = append(errMsgs, item.VolaCont)
  27418. }
  27419. c.ServeSuccessJSON(map[string]interface{}{
  27420. "failed_code": -10,
  27421. "msg": errMsgs,
  27422. })
  27423. return
  27424. } else {
  27425. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27426. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27427. bas := strings.Split(psn_info.CardInfo, "|")
  27428. if his.IdCardType == 1 {
  27429. cert_no = bas[2]
  27430. } else if his.IdCardType == 3 {
  27431. cert_no = his.Certno
  27432. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27433. } else if his.IdCardType == 4 {
  27434. cert_no = his.Certno
  27435. psn_info.VerifyNumber = psn_info.VerifyNumber
  27436. }
  27437. var api string
  27438. if miConfig.MdtrtareaAdmvs == "320830" {
  27439. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27440. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27441. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27442. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27443. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27444. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27445. "&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
  27446. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27447. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27448. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27449. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27450. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27451. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27452. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27453. "&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
  27454. } else {
  27455. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27456. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27457. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27458. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27459. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27460. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27461. "&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
  27462. }
  27463. resp, requestErr := http.Get(api)
  27464. if requestErr != nil {
  27465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27466. return
  27467. }
  27468. body, ioErr := ioutil.ReadAll(resp.Body)
  27469. if ioErr != nil {
  27470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27472. return
  27473. }
  27474. var respJSON map[string]interface{}
  27475. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27478. return
  27479. }
  27480. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27481. result, _ := json.Marshal(respJSON)
  27482. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27483. utils.ErrorLog("解析失败:%v", err)
  27484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27485. return
  27486. }
  27487. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27488. res.Output = resSeven10265.Output
  27489. res.ErrMsg = resSeven10265.ErrMsg
  27490. res.Cainfo = resSeven10265.Cainfo
  27491. res.WarnMsg = resSeven10265.WarnMsg
  27492. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27493. res.Infcode = infocode
  27494. }
  27495. }
  27496. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27497. psn_info, _ := service.GetPsnByPatientId(id)
  27498. var verify_number string
  27499. if psn_info.IdCardType == 4 {
  27500. verify_number = psn_info.VerifyNumber
  27501. } else if psn_info.IdCardType == 1 {
  27502. bas := strings.Split(psn_info.CardInfo, "|")
  27503. cardNumber := bas[2]
  27504. verify_number = cardNumber
  27505. } else {
  27506. psn_info.IdCardType = 2
  27507. verify_number = psn_info.Certno
  27508. }
  27509. var api string
  27510. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27511. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27512. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27513. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27514. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27515. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27516. "&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
  27517. resp, requestErr := http.Get(api)
  27518. if requestErr != nil {
  27519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27520. return
  27521. }
  27522. body, ioErr := ioutil.ReadAll(resp.Body)
  27523. if ioErr != nil {
  27524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27526. return
  27527. }
  27528. var respJSON map[string]interface{}
  27529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27532. return
  27533. }
  27534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27535. result, _ := json.Marshal(respJSON)
  27536. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27537. utils.ErrorLog("解析失败:%v", err)
  27538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27539. return
  27540. }
  27541. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27542. res.Output = resSeven10265.Output
  27543. res.ErrMsg = resSeven10265.ErrMsg
  27544. res.Cainfo = resSeven10265.Cainfo
  27545. res.WarnMsg = resSeven10265.WarnMsg
  27546. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27547. res.Infcode = infocode
  27548. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27549. var cert_no string
  27550. if his.IdCardType == 4 {
  27551. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27552. cert_no = psn_info.VerifyNumber
  27553. 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)
  27554. } else if his.IdCardType == 1 {
  27555. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27556. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27557. 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)
  27558. }
  27559. //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)
  27560. var dat map[string]interface{}
  27561. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27562. fmt.Println(dat)
  27563. } else {
  27564. fmt.Println(err)
  27565. }
  27566. saveLog(result2, src_resquest, "2207", "结算")
  27567. userJSONBytes, _ := json.Marshal(dat)
  27568. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27569. utils.ErrorLog("解析失败:%v", err)
  27570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27571. return
  27572. }
  27573. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27574. res.Output = resSeven10265.Output
  27575. res.ErrMsg = resSeven10265.ErrMsg
  27576. res.Cainfo = resSeven10265.Cainfo
  27577. res.WarnMsg = resSeven10265.WarnMsg
  27578. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27579. res.Infcode = infocode
  27580. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27581. res2 := c.GetoleInfo()
  27582. if res2.Infcode == 0 {
  27583. var result string
  27584. var request_log string
  27585. var result_log string
  27586. if res2.Output.MdtrtCertType == "02" {
  27587. 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)
  27588. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27589. } else if res2.Output.MdtrtCertType == "01" {
  27590. 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)
  27591. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27592. } else {
  27593. 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)
  27594. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27595. }
  27596. var dat map[string]interface{}
  27597. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27598. fmt.Println(dat)
  27599. } else {
  27600. fmt.Println(err)
  27601. }
  27602. userJSONBytes, _ := json.Marshal(dat)
  27603. var res5 ResultTwo
  27604. //var resTwo10265 ResultTwo10265
  27605. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27606. utils.ErrorLog("解析失败:%v", err)
  27607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27608. return
  27609. }
  27610. if res5.Infcode == -1 {
  27611. c.ServeSuccessJSON(map[string]interface{}{
  27612. "failed_code": -10,
  27613. "msg": res5.ErrMsg,
  27614. })
  27615. return
  27616. }
  27617. var insutypes []string
  27618. var insutype string
  27619. var is390 int = 0
  27620. var is310 int = 0
  27621. for _, item := range res5.Output.Iinfo {
  27622. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27623. insutypes = append(insutypes, item.Insutype)
  27624. }
  27625. }
  27626. if len(insutypes) == 1 {
  27627. insutype = insutypes[0]
  27628. } else {
  27629. for _, i := range insutypes {
  27630. if i == "390" {
  27631. is390 = 1
  27632. }
  27633. if i == "310" {
  27634. is310 = 1
  27635. }
  27636. }
  27637. }
  27638. if is390 == 1 {
  27639. insutype = "390"
  27640. }
  27641. if is310 == 1 {
  27642. insutype = "310"
  27643. }
  27644. if len(insutypes) == 0 {
  27645. insutype = "310"
  27646. }
  27647. fmt.Println(insutype)
  27648. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27649. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27650. infoStr := string(Iinfos)
  27651. idetinfoStr := string(Idetinfos)
  27652. psn := &models.HisPsn{
  27653. PsnNo: res5.Output.Baseinfo.PsnNo,
  27654. PatientId: id,
  27655. Certno: res5.Output.Baseinfo.Certno,
  27656. Gend: res5.Output.Baseinfo.Gend,
  27657. Naty: res5.Output.Baseinfo.Naty,
  27658. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27659. PsnName: res5.Output.Baseinfo.PsnName,
  27660. Idetinfo: idetinfoStr,
  27661. Insuinfo: infoStr,
  27662. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27663. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27664. VerifyNumber: res2.Output.EcToken,
  27665. }
  27666. if res2.Output.MdtrtCertType == "01" {
  27667. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27668. psn.VerifyNumber = res2.Output.EcToken
  27669. } else if res2.Output.MdtrtCertType == "02" {
  27670. psn.VerifyNumber = res2.Output.CardNo
  27671. } else {
  27672. psn.VerifyNumber = res2.Output.MdtrtCertNo
  27673. }
  27674. service.CreateHisPsn(psn)
  27675. if res2.Output.MdtrtCertType == "01" {
  27676. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27677. token := res2.Output.EcToken
  27678. 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)
  27679. } else if res2.Output.MdtrtCertType == "02" {
  27680. 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)
  27681. } else {
  27682. 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)
  27683. }
  27684. var dat2 map[string]interface{}
  27685. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27686. fmt.Println(dat2)
  27687. } else {
  27688. fmt.Println(err)
  27689. }
  27690. userJSONBytes3, _ := json.Marshal(dat2)
  27691. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27692. utils.ErrorLog("解析失败:%v", err)
  27693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27694. return
  27695. }
  27696. saveLog(result2, src_resquest, "2207", "结算")
  27697. } else {
  27698. c.ServeSuccessJSON(map[string]interface{}{
  27699. "failed_code": -10,
  27700. "msg": res2.ErrMsg,
  27701. })
  27702. return
  27703. }
  27704. } else {
  27705. if miConfig.Code == "H15049901371" {
  27706. //赤峰地区国家医保医疗类别
  27707. //职工透析:医疗类别选特殊情况门诊990502
  27708. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27709. var med_type string
  27710. if his.Insutype == "390" {
  27711. if reg_type == 14 {
  27712. med_type = "9933"
  27713. } else if reg_type == 11 {
  27714. med_type = "11"
  27715. }
  27716. } else if his.Insutype == "310" {
  27717. if reg_type == 14 {
  27718. med_type = "990502"
  27719. } else if reg_type == 11 {
  27720. med_type = "11"
  27721. }
  27722. }
  27723. 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)
  27724. } else {
  27725. if his.IdCardType == 4 {
  27726. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27727. var token string
  27728. token = psn_info.VerifyNumber
  27729. 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)
  27730. } else {
  27731. if his.IdCardType == 1 {
  27732. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27733. bas := strings.Split(psn_info.CardInfo, "|")
  27734. basNumber := bas[2]
  27735. cert_no = basNumber
  27736. }
  27737. 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)
  27738. }
  27739. }
  27740. //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)
  27741. var dat map[string]interface{}
  27742. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27743. fmt.Println(dat)
  27744. } else {
  27745. fmt.Println(err)
  27746. }
  27747. saveLog(result2, src_resquest, "2207", "结算")
  27748. userJSONBytes, _ := json.Marshal(dat)
  27749. if miConfig.Code == "H15049901371" {
  27750. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27751. utils.ErrorLog("解析失败:%v", err)
  27752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27753. return
  27754. }
  27755. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27756. res.Output = resSeven10265.Output
  27757. res.ErrMsg = resSeven10265.ErrMsg
  27758. res.Cainfo = resSeven10265.Cainfo
  27759. res.WarnMsg = resSeven10265.WarnMsg
  27760. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27761. res.Infcode = infocode
  27762. } else {
  27763. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27764. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27765. utils.ErrorLog("解析失败:%v", err)
  27766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27767. return
  27768. }
  27769. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27770. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27771. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27772. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27773. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27774. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27775. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27776. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27777. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27778. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27779. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27780. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27781. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27782. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27783. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27784. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27785. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27786. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27787. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27788. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27789. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27790. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27791. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27792. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27793. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27794. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27795. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27796. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27797. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27798. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27799. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27800. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27801. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27802. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27803. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27804. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27805. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27806. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27807. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27808. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27809. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27810. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27811. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27812. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27813. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27814. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27815. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27816. res.Cainfo = gzresSeven10265Two.Cainfo
  27817. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27818. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27819. //res.Infcode = infocode
  27820. } else {
  27821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27822. utils.ErrorLog("解析失败:%v", err)
  27823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27824. return
  27825. }
  27826. }
  27827. }
  27828. }
  27829. if res.Infcode == -1 {
  27830. errlog := &models.HisOrderError{
  27831. UserOrgId: adminUser.CurrentOrgId,
  27832. Ctime: time.Now().Unix(),
  27833. Mtime: time.Now().Unix(),
  27834. Number: chrg_bchno,
  27835. ErrMsg: res.ErrMsg,
  27836. Status: 1,
  27837. PatientId: id,
  27838. RecordTime: recordDateTime,
  27839. Stage: 6,
  27840. }
  27841. service.CreateErrMsgLog(errlog)
  27842. c.ServeSuccessJSON(map[string]interface{}{
  27843. "failed_code": -10,
  27844. "msg": res.ErrMsg,
  27845. })
  27846. return
  27847. } else {
  27848. sickConfig, _ := service.FindSickById(his.SickType)
  27849. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27850. order.OrderStatus = 2
  27851. order.Status = 1
  27852. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27853. order.SetlId = res.Output.Setlinfo.SetlID
  27854. order.PsnNo = res.Output.Setlinfo.PsnNo
  27855. order.PsnName = res.Output.Setlinfo.PsnName
  27856. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27857. order.Certno = res.Output.Setlinfo.Certno
  27858. order.Gend = res.Output.Setlinfo.Gend
  27859. order.Naty = res.Output.Setlinfo.Naty
  27860. order.Age = res.Output.Setlinfo.Age
  27861. order.Insutype = res.Output.Setlinfo.Insutype
  27862. order.PsnType = res.Output.Setlinfo.PsnType
  27863. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27864. order.SetlTime = res.Output.Setlinfo.SetlTime
  27865. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27866. if res.Output.Setlinfo.MedType == "140101" {
  27867. order.MedType = "14"
  27868. } else {
  27869. if res.Output.Setlinfo.MedType == "110104" {
  27870. order.MedType = "11"
  27871. } else {
  27872. order.MedType = res.Output.Setlinfo.MedType
  27873. }
  27874. }
  27875. if reg_type == 1112 {
  27876. order.MedType = "1112"
  27877. }
  27878. if reg_type == 1111 {
  27879. order.MedType = "1111"
  27880. }
  27881. order.ClrType = res.Output.Setlinfo.ClrType
  27882. if adminUser.CurrentOrgId == 10480 {
  27883. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27884. order.ClrType = "11"
  27885. } else {
  27886. order.ClrType = "9903"
  27887. }
  27888. }
  27889. if adminUser.CurrentOrgId == 10721 {
  27890. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27891. order.ClrType = "11"
  27892. } else {
  27893. order.ClrType = "9903"
  27894. }
  27895. }
  27896. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27897. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27898. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27899. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27900. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27901. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27902. order.HifpPay = res.Output.Setlinfo.HifpPay
  27903. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27904. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27905. order.HifesPay = res.Output.Setlinfo.HifesPay
  27906. order.HifobPay = res.Output.Setlinfo.HifobPay
  27907. order.MafPay = res.Output.Setlinfo.MafPay
  27908. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27909. order.OthPay = res.Output.Setlinfo.OthPay
  27910. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27911. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27912. order.AcctPay = res.Output.Setlinfo.AcctPay
  27913. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27914. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27915. order.Balc = res.Output.Setlinfo.Balc
  27916. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27917. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27918. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27919. //order.ClrType = res.Output.Setlinfo.ClrType
  27920. order.ClrWay = res.Output.Setlinfo.ClrWay
  27921. order.Creator = order.Creator
  27922. order.Modify = roles.AdminUserId
  27923. order.RequestLog = src_resquest
  27924. order.FaPiaoNumber = fapiao_number
  27925. order.FaPiaoCode = fapiao_code
  27926. order.SickName = sickConfig.ClassName
  27927. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27928. //detailStr := string(setlDetail)
  27929. //order.SetlDetail = detailStr
  27930. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27931. err = service.UpDateOrder(order)
  27932. if err == nil {
  27933. //判断是否使用了押金
  27934. if dec_way == "true" {
  27935. tmpstring := strconv.FormatInt(order.ID, 10)
  27936. order.Decimal = decimal
  27937. service.UpDateOrder(order)
  27938. //扣押金
  27939. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27940. if errmsg != nil {
  27941. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27942. return
  27943. }
  27944. }
  27945. c.ServeSuccessJSON(map[string]interface{}{
  27946. "msg": "结算成功",
  27947. })
  27948. } else {
  27949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27950. return
  27951. }
  27952. }
  27953. } else {
  27954. adminUser := c.GetAdminUserInfo()
  27955. errlog := &models.HisOrderError{
  27956. UserOrgId: adminUser.CurrentOrgId,
  27957. Ctime: time.Now().Unix(),
  27958. Mtime: time.Now().Unix(),
  27959. ErrMsg: res.ErrMsg,
  27960. Status: 1,
  27961. PatientId: id,
  27962. RecordTime: recordDateTime,
  27963. Stage: 4,
  27964. }
  27965. service.CreateErrMsgLog(errlog)
  27966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  27967. return
  27968. }
  27969. } else {
  27970. adminUser := c.GetAdminUserInfo()
  27971. errlog := &models.HisOrderError{
  27972. UserOrgId: adminUser.CurrentOrgId,
  27973. Ctime: time.Now().Unix(),
  27974. Mtime: time.Now().Unix(),
  27975. ErrMsg: res.ErrMsg,
  27976. Status: 1,
  27977. PatientId: id,
  27978. RecordTime: recordDateTime,
  27979. Stage: 4,
  27980. }
  27981. service.CreateErrMsgLog(errlog)
  27982. c.ServeSuccessJSON(map[string]interface{}{
  27983. "failed_code": -10,
  27984. "msg": res.ErrMsg,
  27985. })
  27986. return
  27987. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  27988. //return
  27989. }
  27990. }
  27991. }
  27992. } else if tempOrder.ID > 0 {
  27993. if tempOrder.IsPre == 1 {
  27994. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  27995. var rf []*ResultFive
  27996. json.Unmarshal([]byte(his.Iinfo), &rf)
  27997. chrg_bchno := tempOrder.Number
  27998. cert_no := his.Certno
  27999. var insutypes []string
  28000. var insutype string
  28001. var is390 int = 0
  28002. var is310 int = 0
  28003. for _, item := range rf {
  28004. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28005. insutypes = append(insutypes, item.Insutype)
  28006. }
  28007. }
  28008. if len(insutypes) == 1 {
  28009. insutype = insutypes[0]
  28010. } else {
  28011. for _, i := range insutypes {
  28012. if i == "390" {
  28013. is390 = 1
  28014. }
  28015. if i == "310" {
  28016. is310 = 1
  28017. }
  28018. }
  28019. }
  28020. if is390 == 1 {
  28021. insutype = "390"
  28022. }
  28023. if is310 == 1 {
  28024. insutype = "310"
  28025. }
  28026. if len(insutypes) == 0 {
  28027. insutype = "310"
  28028. }
  28029. if len(insutypes) == 2 {
  28030. insutype = strconv.FormatInt(his.SocialType, 10)
  28031. }
  28032. //insutype = "390"
  28033. if his.IdCardType == 1 {
  28034. // cert_no = his.MedicalInsuranceNumber
  28035. cert_no = his.Certno
  28036. } else {
  28037. cert_no = his.Certno
  28038. }
  28039. var res ResultSeven
  28040. var ahres ResultSevenAH
  28041. var resSeven10265 ResultSeven10265
  28042. var gzresSeven10265Two GZResultSeven10265Two
  28043. var src_resquest string
  28044. var result2 string
  28045. if miConfig.MdtrtareaAdmvs == "450721" {
  28046. res2 := c.GetoleInfo()
  28047. if res2.Infcode == 0 {
  28048. var result string
  28049. var request_log string
  28050. var result_log string
  28051. if res2.Output.MdtrtCertType == "02" {
  28052. 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)
  28053. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28054. } else if res2.Output.MdtrtCertType == "01" {
  28055. 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)
  28056. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28057. } else {
  28058. 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)
  28059. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28060. }
  28061. var dat map[string]interface{}
  28062. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28063. fmt.Println(dat)
  28064. } else {
  28065. fmt.Println(err)
  28066. }
  28067. userJSONBytes, _ := json.Marshal(dat)
  28068. var res5 ResultTwo
  28069. //var resTwo10265 ResultTwo10265
  28070. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  28071. utils.ErrorLog("解析失败:%v", err)
  28072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28073. return
  28074. }
  28075. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  28076. if res5.Infcode == -1 {
  28077. c.ServeSuccessJSON(map[string]interface{}{
  28078. "failed_code": -10,
  28079. "msg": res5.ErrMsg,
  28080. })
  28081. return
  28082. }
  28083. var insutypes []string
  28084. var insutype string
  28085. var is390 int = 0
  28086. var is310 int = 0
  28087. for _, item := range res5.Output.Iinfo {
  28088. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28089. insutypes = append(insutypes, item.Insutype)
  28090. }
  28091. }
  28092. if len(insutypes) == 1 {
  28093. insutype = insutypes[0]
  28094. } else {
  28095. for _, i := range insutypes {
  28096. if i == "390" {
  28097. is390 = 1
  28098. }
  28099. if i == "310" {
  28100. is310 = 1
  28101. }
  28102. }
  28103. }
  28104. if is390 == 1 {
  28105. insutype = "390"
  28106. }
  28107. if is310 == 1 {
  28108. insutype = "310"
  28109. }
  28110. if len(insutypes) == 0 {
  28111. insutype = "310"
  28112. }
  28113. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  28114. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  28115. infoStr := string(Iinfos)
  28116. idetinfoStr := string(Idetinfos)
  28117. psn := &models.HisPsn{
  28118. PsnNo: res5.Output.Baseinfo.PsnNo,
  28119. PatientId: id,
  28120. Certno: res5.Output.Baseinfo.Certno,
  28121. Gend: res5.Output.Baseinfo.Gend,
  28122. Naty: res5.Output.Baseinfo.Naty,
  28123. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28124. PsnName: res5.Output.Baseinfo.PsnName,
  28125. Idetinfo: idetinfoStr,
  28126. Insuinfo: infoStr,
  28127. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28128. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28129. VerifyNumber: res2.Output.EcToken,
  28130. }
  28131. service.CreateHisPsn(psn)
  28132. if res2.Output.MdtrtCertType == "01" {
  28133. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28134. token := res2.Output.EcToken
  28135. 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)
  28136. } else if res2.Output.MdtrtCertType == "02" {
  28137. 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)
  28138. } else {
  28139. 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)
  28140. }
  28141. var dat2 map[string]interface{}
  28142. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28143. fmt.Println(dat2)
  28144. } else {
  28145. fmt.Println(err)
  28146. }
  28147. userJSONBytes3, _ := json.Marshal(dat2)
  28148. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28149. utils.ErrorLog("解析失败:%v", err)
  28150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28151. return
  28152. }
  28153. saveLog(result2, src_resquest, "2207", "结算")
  28154. } else {
  28155. c.ServeSuccessJSON(map[string]interface{}{
  28156. "failed_code": -10,
  28157. "msg": res2.ErrMsg,
  28158. })
  28159. return
  28160. }
  28161. } else if miConfig.MdtrtareaAdmvs == "421300" {
  28162. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28163. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28164. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28165. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28166. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28167. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28168. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28169. resp, requestErr := http.Get(api)
  28170. if requestErr != nil {
  28171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28172. return
  28173. }
  28174. body, ioErr := ioutil.ReadAll(resp.Body)
  28175. if ioErr != nil {
  28176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28178. return
  28179. }
  28180. var respJSON map[string]interface{}
  28181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28184. return
  28185. }
  28186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28187. result, _ := json.Marshal(respJSON)
  28188. fmt.Println("log")
  28189. fmt.Println(string(result))
  28190. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28191. utils.ErrorLog("解析失败:%v", err)
  28192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28193. return
  28194. }
  28195. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28196. if reg_type == 11 && his.Insutype == "390" {
  28197. reg_type = 110104
  28198. }
  28199. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28200. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28201. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28202. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28203. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28204. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28205. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28206. resp, requestErr := http.Get(api)
  28207. if requestErr != nil {
  28208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28209. return
  28210. }
  28211. body, ioErr := ioutil.ReadAll(resp.Body)
  28212. if ioErr != nil {
  28213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28215. return
  28216. }
  28217. var respJSON map[string]interface{}
  28218. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28221. return
  28222. }
  28223. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28224. result, _ := json.Marshal(respJSON)
  28225. fmt.Println("log")
  28226. fmt.Println(string(result))
  28227. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28228. utils.ErrorLog("解析失败:%v", err)
  28229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28230. return
  28231. }
  28232. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28233. if reg_type == 11 && his.Insutype == "390" {
  28234. reg_type = 110104
  28235. }
  28236. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28237. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28238. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28239. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28240. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28241. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28242. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28243. resp, requestErr := http.Get(api)
  28244. if requestErr != nil {
  28245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28246. return
  28247. }
  28248. body, ioErr := ioutil.ReadAll(resp.Body)
  28249. if ioErr != nil {
  28250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28252. return
  28253. }
  28254. var respJSON map[string]interface{}
  28255. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28258. return
  28259. }
  28260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28261. result, _ := json.Marshal(respJSON)
  28262. fmt.Println("log")
  28263. fmt.Println(string(result))
  28264. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28265. utils.ErrorLog("解析失败:%v", err)
  28266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28267. return
  28268. }
  28269. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28270. if reg_type == 11 && his.Insutype == "390" {
  28271. reg_type = 110104
  28272. }
  28273. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28274. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28275. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28276. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28277. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28278. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28279. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28280. resp, requestErr := http.Get(api)
  28281. if requestErr != nil {
  28282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28283. return
  28284. }
  28285. body, ioErr := ioutil.ReadAll(resp.Body)
  28286. if ioErr != nil {
  28287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28289. return
  28290. }
  28291. var respJSON map[string]interface{}
  28292. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28295. return
  28296. }
  28297. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28298. result, _ := json.Marshal(respJSON)
  28299. fmt.Println("log")
  28300. fmt.Println(string(result))
  28301. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28302. utils.ErrorLog("解析失败:%v", err)
  28303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28304. return
  28305. }
  28306. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  28307. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28308. var result3101 Result3101
  28309. //utils.ErrorLog("解析失败:%v", result3101)
  28310. result3101.Infcode = "0"
  28311. if result3101.Infcode == "0" {
  28312. if len(result3101.Output.Result) > 0 {
  28313. var errMsgs []string
  28314. for _, item := range result3101.Output.Result {
  28315. errMsgs = append(errMsgs, item.VolaCont)
  28316. }
  28317. c.ServeSuccessJSON(map[string]interface{}{
  28318. "failed_code": -10,
  28319. "msg": errMsgs,
  28320. })
  28321. return
  28322. } else {
  28323. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28324. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28325. bas := strings.Split(psn_info.CardInfo, "|")
  28326. if his.IdCardType == 1 {
  28327. cert_no = bas[2]
  28328. } else if his.IdCardType == 3 {
  28329. cert_no = his.Certno
  28330. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28331. } else if his.IdCardType == 4 {
  28332. cert_no = his.Certno
  28333. psn_info.VerifyNumber = psn_info.VerifyNumber
  28334. }
  28335. //江苏地区国家医保医疗类别
  28336. //职工透析:医疗类别选特殊情况门诊9933
  28337. //居民血透门慢: 医疗类别选门诊慢病1402
  28338. //var med_type string
  28339. //if his.Insutype == "310" {
  28340. // if reg_type == 14 {
  28341. // med_type = "9933"
  28342. // } else if reg_type == 11 {
  28343. // med_type = "11"
  28344. //
  28345. // }
  28346. //} else if his.Insutype == "390" {
  28347. // if reg_type == 14 {
  28348. // med_type = "1402"
  28349. // } else if reg_type == 11 {
  28350. // med_type = "11"
  28351. // }
  28352. //}
  28353. var api string
  28354. if miConfig.MdtrtareaAdmvs == "320830" {
  28355. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28356. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28357. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28358. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28359. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28360. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28361. "&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
  28362. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28363. } else if miConfig.MdtrtareaAdmvs == "320921" {
  28364. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28365. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28366. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28367. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28368. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28369. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28370. "&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
  28371. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28372. } else {
  28373. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28374. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28375. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28376. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28377. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28378. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28379. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28380. "&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
  28381. }
  28382. resp, requestErr := http.Get(api)
  28383. if requestErr != nil {
  28384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28385. return
  28386. }
  28387. body, ioErr := ioutil.ReadAll(resp.Body)
  28388. if ioErr != nil {
  28389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28391. return
  28392. }
  28393. var respJSON map[string]interface{}
  28394. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28397. return
  28398. }
  28399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28400. result, _ := json.Marshal(respJSON)
  28401. fmt.Println("log")
  28402. fmt.Println(string(result))
  28403. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28404. utils.ErrorLog("解析失败:%v", err)
  28405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28406. return
  28407. }
  28408. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28409. res.Output = resSeven10265.Output
  28410. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28411. res.ErrMsg = resSeven10265.ErrMsg
  28412. res.Cainfo = resSeven10265.Cainfo
  28413. res.WarnMsg = resSeven10265.WarnMsg
  28414. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28415. res.Infcode = infocode
  28416. }
  28417. }
  28418. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28419. psn_info, _ := service.GetPsnByPatientId(id)
  28420. var verify_number string
  28421. if psn_info.IdCardType == 4 {
  28422. verify_number = psn_info.VerifyNumber
  28423. } else if psn_info.IdCardType == 1 {
  28424. bas := strings.Split(psn_info.CardInfo, "|")
  28425. cardNumber := bas[2]
  28426. verify_number = cardNumber
  28427. } else {
  28428. verify_number = psn_info.Certno
  28429. psn_info.IdCardType = 2
  28430. }
  28431. var api string
  28432. new_chrg_bchno := chrg_bchno
  28433. if adminUser.CurrentOrgId == 10265 {
  28434. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28435. new_chrg_bchno = "0000"
  28436. }
  28437. }
  28438. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28439. his.Number + "&chrg_bchno=" + new_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(psn_info.IdCardType, 10) +
  28443. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28444. "&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
  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), &resSeven10265); err != nil {
  28467. utils.ErrorLog("解析失败:%v", err)
  28468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28469. return
  28470. }
  28471. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28472. res.Output = resSeven10265.Output
  28473. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28474. res.ErrMsg = resSeven10265.ErrMsg
  28475. res.Cainfo = resSeven10265.Cainfo
  28476. res.WarnMsg = resSeven10265.WarnMsg
  28477. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28478. res.Infcode = infocode
  28479. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28480. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28481. var cert_no string
  28482. if his.IdCardType == 1 {
  28483. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28484. } else {
  28485. cert_no = psn_info.VerifyNumber
  28486. }
  28487. 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)
  28488. var dat map[string]interface{}
  28489. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28490. fmt.Println(dat)
  28491. } else {
  28492. fmt.Println(err)
  28493. }
  28494. saveLog(result2, src_resquest, "2207", "结算")
  28495. userJSONBytes, _ := json.Marshal(dat)
  28496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28497. utils.ErrorLog("解析失败:%v", err)
  28498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28499. return
  28500. }
  28501. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28502. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28503. var cert_no string
  28504. var card_sn string
  28505. if his.IdCardType == 1 {
  28506. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28507. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28508. bas := strings.Split(psn_info.CardInfo, "|")
  28509. card_sn = bas[3]
  28510. } else if his.IdCardType == 2 {
  28511. cert_no = his.IdCardNo
  28512. } else {
  28513. cert_no = psn_info.VerifyNumber
  28514. }
  28515. var rf []*ResultFive
  28516. json.Unmarshal([]byte(his.Iinfo), &rf)
  28517. var psn_type string
  28518. for _, item := range rf {
  28519. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28520. psn_type = item.PsnType
  28521. }
  28522. }
  28523. 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)
  28524. var dat map[string]interface{}
  28525. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28526. fmt.Println(dat)
  28527. } else {
  28528. fmt.Println(err)
  28529. }
  28530. saveLog(result2, src_resquest, "2207", "结算")
  28531. userJSONBytes, _ := json.Marshal(dat)
  28532. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28533. utils.ErrorLog("解析失败:%v", err)
  28534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28535. return
  28536. }
  28537. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28538. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28539. var cert_no string
  28540. var card_sn string
  28541. if his.IdCardType == 1 {
  28542. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28543. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28544. //bas := strings.Split(psn_info.CardInfo, "|")
  28545. card_sn = ""
  28546. } else if his.IdCardType == 2 {
  28547. cert_no = his.IdCardNo
  28548. } else {
  28549. cert_no = psn_info.VerifyNumber
  28550. }
  28551. var rf []*ResultFive
  28552. json.Unmarshal([]byte(his.Iinfo), &rf)
  28553. var psn_type string
  28554. for _, item := range rf {
  28555. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28556. psn_type = item.PsnType
  28557. }
  28558. }
  28559. 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)
  28560. var dat map[string]interface{}
  28561. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28562. fmt.Println(dat)
  28563. } else {
  28564. fmt.Println(err)
  28565. }
  28566. saveLog(result2, src_resquest, "2207", "结算")
  28567. userJSONBytes, _ := json.Marshal(dat)
  28568. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28569. utils.ErrorLog("解析失败:%v", err)
  28570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28571. return
  28572. }
  28573. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28574. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28575. var cert_no string
  28576. var card_sn string
  28577. if his.IdCardType == 1 {
  28578. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28579. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28580. //bas := strings.Split(psn_info.CardInfo, "|")
  28581. card_sn = ""
  28582. } else if his.IdCardType == 2 {
  28583. cert_no = his.IdCardNo
  28584. } else {
  28585. cert_no = psn_info.VerifyNumber
  28586. }
  28587. var rf []*ResultFive
  28588. json.Unmarshal([]byte(his.Iinfo), &rf)
  28589. var psn_type string
  28590. for _, item := range rf {
  28591. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28592. psn_type = item.PsnType
  28593. }
  28594. }
  28595. 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)
  28596. var dat map[string]interface{}
  28597. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28598. fmt.Println(dat)
  28599. } else {
  28600. fmt.Println(err)
  28601. }
  28602. saveLog(result2, src_resquest, "2207", "结算")
  28603. userJSONBytes, _ := json.Marshal(dat)
  28604. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28605. utils.ErrorLog("解析失败:%v", err)
  28606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28607. return
  28608. }
  28609. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28610. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28611. if his.IdCardType == 1 {
  28612. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28613. bas := strings.Split(psn_info.CardInfo, "|")
  28614. cert_no = bas[2]
  28615. } else if his.IdCardType == 3 {
  28616. cert_no = his.Certno
  28617. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28618. } else if his.IdCardType == 4 {
  28619. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28620. cert_no = psn_info.VerifyNumber
  28621. psn_info.VerifyNumber = psn_info.VerifyNumber
  28622. } else {
  28623. cert_no = his.Certno
  28624. psn_info.VerifyNumber = his.Certno
  28625. }
  28626. var api string
  28627. var med_type string
  28628. if his.Insutype == "390" {
  28629. if reg_type == 992102 {
  28630. med_type = "992102"
  28631. }
  28632. if reg_type == 1104 {
  28633. med_type = "1104"
  28634. }
  28635. if reg_type == 1104 {
  28636. med_type = "1104"
  28637. }
  28638. if reg_type == 140104 {
  28639. med_type = "140104"
  28640. }
  28641. if reg_type == 140201 {
  28642. med_type = "140201"
  28643. }
  28644. if reg_type == 14 {
  28645. med_type = "14"
  28646. }
  28647. } else if his.Insutype == "310" {
  28648. if reg_type == 1104 {
  28649. med_type = "1104"
  28650. }
  28651. if reg_type == 992102 {
  28652. med_type = "992102"
  28653. }
  28654. if reg_type == 140104 {
  28655. med_type = "140104"
  28656. }
  28657. if reg_type == 140201 {
  28658. med_type = "140201"
  28659. }
  28660. if reg_type == 14 {
  28661. med_type = "14"
  28662. }
  28663. }
  28664. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28665. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28666. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28667. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28668. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28669. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28670. "&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
  28671. resp, requestErr := http.Get(api)
  28672. if requestErr != nil {
  28673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28674. return
  28675. }
  28676. body, ioErr := ioutil.ReadAll(resp.Body)
  28677. if ioErr != nil {
  28678. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28680. return
  28681. }
  28682. var respJSON map[string]interface{}
  28683. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28686. return
  28687. }
  28688. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28689. if status == "0" {
  28690. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28691. c.ServeSuccessJSON(map[string]interface{}{
  28692. "failed_code": -10,
  28693. "msg": err_msg,
  28694. })
  28695. return
  28696. }
  28697. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28698. result, _ := json.Marshal(respJSON)
  28699. fmt.Println("log")
  28700. fmt.Println(string(result))
  28701. if err := json.Unmarshal(result, &ahres); err != nil {
  28702. utils.ErrorLog("解析失败:%v", err)
  28703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28704. return
  28705. }
  28706. res.InfRefmsgid = ahres.InfRefmsgid
  28707. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28708. // 创建对应的Time类型
  28709. t := time.UnixMilli(timestamp)
  28710. // 格式化成指定的日期字符串
  28711. str := t.Format("2006-01-02 15:04:05")
  28712. res.Output.Setlinfo.SetlTime = str
  28713. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28714. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28715. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28716. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28717. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28718. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28719. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28720. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28721. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28722. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28723. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28724. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28725. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28726. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28727. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28728. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28729. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28730. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28731. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28732. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28733. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28734. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28735. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28736. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28737. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28738. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28739. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28740. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28741. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28742. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28743. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28744. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28745. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28746. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28747. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28748. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28749. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28750. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28751. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28752. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28753. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28754. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28755. res.Output.Setldetail = ahres.Output.Setldetail
  28756. res.ErrMsg = ahres.ErrMsg
  28757. res.Cainfo = ahres.Cainfo
  28758. res.WarnMsg = ahres.WarnMsg
  28759. res.Infcode = ahres.Infcode
  28760. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28761. res.Output.Setlinfo.ClrType = "11"
  28762. } else {
  28763. res.Output.Setlinfo.ClrType = "9903"
  28764. }
  28765. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28766. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28767. if his.IdCardType == 1 {
  28768. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28769. bas := strings.Split(psn_info.CardInfo, "|")
  28770. cert_no = bas[2]
  28771. } else if his.IdCardType == 3 {
  28772. cert_no = his.Certno
  28773. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28774. } else if his.IdCardType == 4 {
  28775. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28776. cert_no = his.Certno
  28777. psn_info.VerifyNumber = psn_info.VerifyNumber
  28778. } else {
  28779. cert_no = his.Certno
  28780. psn_info.VerifyNumber = his.Certno
  28781. }
  28782. var api string
  28783. var med_type string
  28784. if his.Insutype == "390" {
  28785. if reg_type == 1104 {
  28786. med_type = "1104"
  28787. }
  28788. if reg_type == 992102 {
  28789. med_type = "992102"
  28790. }
  28791. if reg_type == 140104 {
  28792. med_type = "140104"
  28793. }
  28794. if reg_type == 14 {
  28795. med_type = "14"
  28796. }
  28797. if reg_type == 140201 {
  28798. med_type = "140201"
  28799. }
  28800. } else if his.Insutype == "310" {
  28801. if reg_type == 1104 {
  28802. med_type = "1104"
  28803. }
  28804. if reg_type == 992102 {
  28805. med_type = "992102"
  28806. }
  28807. if reg_type == 14 {
  28808. med_type = "14"
  28809. }
  28810. if reg_type == 140104 {
  28811. med_type = "140104"
  28812. }
  28813. if reg_type == 140201 {
  28814. med_type = "140201"
  28815. }
  28816. }
  28817. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28818. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28819. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28820. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28821. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28822. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28823. "&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
  28824. resp, requestErr := http.Get(api)
  28825. if requestErr != nil {
  28826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28827. return
  28828. }
  28829. body, ioErr := ioutil.ReadAll(resp.Body)
  28830. if ioErr != nil {
  28831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28833. return
  28834. }
  28835. var respJSON map[string]interface{}
  28836. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28839. return
  28840. }
  28841. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28842. if status == "0" {
  28843. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28844. c.ServeSuccessJSON(map[string]interface{}{
  28845. "failed_code": -10,
  28846. "msg": err_msg,
  28847. })
  28848. return
  28849. }
  28850. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28851. result, _ := json.Marshal(respJSON)
  28852. fmt.Println("log")
  28853. fmt.Println(string(result))
  28854. if err := json.Unmarshal(result, &ahres); err != nil {
  28855. utils.ErrorLog("解析失败:%v", err)
  28856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28857. return
  28858. }
  28859. res.InfRefmsgid = ahres.InfRefmsgid
  28860. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28861. // 创建对应的Time类型
  28862. t := time.UnixMilli(timestamp)
  28863. // 格式化成指定的日期字符串
  28864. str := t.Format("2006-01-02 15:04:05")
  28865. res.Output.Setlinfo.SetlTime = str
  28866. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28867. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28868. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28869. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28870. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28871. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28872. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28873. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28874. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28875. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28876. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28877. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28878. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28879. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28880. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28881. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28882. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28883. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28884. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28885. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28886. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28887. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28888. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28889. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28890. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28891. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28892. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28893. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28894. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28895. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28896. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28897. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28898. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28899. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28900. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28901. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28902. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28903. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28904. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28905. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28906. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28907. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28908. res.Output.Setldetail = ahres.Output.Setldetail
  28909. res.ErrMsg = ahres.ErrMsg
  28910. res.Cainfo = ahres.Cainfo
  28911. res.WarnMsg = ahres.WarnMsg
  28912. res.Infcode = ahres.Infcode
  28913. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28914. res.Output.Setlinfo.ClrType = "11"
  28915. } else {
  28916. res.Output.Setlinfo.ClrType = "9903"
  28917. }
  28918. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28919. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28920. var cert_no string
  28921. if his.IdCardType == 1 {
  28922. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28923. } else if his.IdCardType == 2 {
  28924. cert_no = his.IdCardNo
  28925. } else {
  28926. cert_no = psn_info.VerifyNumber
  28927. }
  28928. 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, "")
  28929. var dat map[string]interface{}
  28930. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28931. fmt.Println(dat)
  28932. } else {
  28933. fmt.Println(err)
  28934. }
  28935. saveLog(result2, src_resquest, "2207", "结算")
  28936. userJSONBytes, _ := json.Marshal(dat)
  28937. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28938. utils.ErrorLog("解析失败:%v", err)
  28939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28940. return
  28941. }
  28942. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28943. psn_info, _ := service.GetPsnByPatientId(id)
  28944. var verify_number string
  28945. if psn_info.IdCardType == 4 {
  28946. verify_number = psn_info.VerifyNumber
  28947. } else if psn_info.IdCardType == 1 {
  28948. bas := strings.Split(psn_info.CardInfo, "|")
  28949. cardNumber := bas[2]
  28950. verify_number = cardNumber
  28951. } else {
  28952. verify_number = psn_info.Certno
  28953. psn_info.IdCardType = 2
  28954. }
  28955. var api string
  28956. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28957. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28958. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28959. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28960. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28961. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28962. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  28963. resp, requestErr := http.Get(api)
  28964. if requestErr != nil {
  28965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28966. return
  28967. }
  28968. body, ioErr := ioutil.ReadAll(resp.Body)
  28969. if ioErr != nil {
  28970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28972. return
  28973. }
  28974. var respJSON map[string]interface{}
  28975. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28978. return
  28979. }
  28980. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28981. result, _ := json.Marshal(respJSON)
  28982. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28983. utils.ErrorLog("解析失败:%v", err)
  28984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28985. return
  28986. }
  28987. } else {
  28988. var src_resquest string
  28989. if miConfig.Code == "H15049901371" {
  28990. //赤峰地区国家医保医疗类别
  28991. //职工透析:医疗类别选特殊情况门诊990502
  28992. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28993. var med_type string
  28994. if his.Insutype == "390" {
  28995. if reg_type == 14 {
  28996. med_type = "9933"
  28997. } else if reg_type == 11 {
  28998. med_type = "11"
  28999. }
  29000. } else if his.Insutype == "310" {
  29001. if reg_type == 14 {
  29002. med_type = "990502"
  29003. } else if reg_type == 11 {
  29004. med_type = "11"
  29005. }
  29006. }
  29007. 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)
  29008. } else {
  29009. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  29010. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  29011. if result3101.Infcode == 0 {
  29012. if len(result3101.Output.Result) > 0 {
  29013. c.ServeSuccessJSON(map[string]interface{}{
  29014. "failed_code": -10,
  29015. "failed_type": 100,
  29016. "warm_type": 2,
  29017. "msg": result3101,
  29018. })
  29019. return
  29020. }
  29021. } else {
  29022. c.ServeSuccessJSON(map[string]interface{}{
  29023. "failed_code": -10,
  29024. "msg": result3101.ErrMsg,
  29025. })
  29026. return
  29027. }
  29028. }
  29029. if his.IdCardType == 4 {
  29030. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29031. token := psn_info.VerifyNumber
  29032. 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)
  29033. } else {
  29034. 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)
  29035. }
  29036. }
  29037. var dat map[string]interface{}
  29038. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29039. fmt.Println(dat)
  29040. } else {
  29041. fmt.Println(err)
  29042. }
  29043. saveLog(result2, src_resquest, "2207", "结算")
  29044. userJSONBytes, _ := json.Marshal(dat)
  29045. if miConfig.Code == "H15049901371" {
  29046. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29047. utils.ErrorLog("解析失败:%v", err)
  29048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29049. return
  29050. }
  29051. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29052. res.Output = resSeven10265.Output
  29053. res.ErrMsg = resSeven10265.ErrMsg
  29054. res.Cainfo = resSeven10265.Cainfo
  29055. res.WarnMsg = resSeven10265.WarnMsg
  29056. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29057. res.Infcode = infocode
  29058. } else {
  29059. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29060. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29061. utils.ErrorLog("解析失败:%v", err)
  29062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29063. return
  29064. }
  29065. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29066. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29067. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29068. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29069. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29070. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29071. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29072. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29073. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29074. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29075. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29076. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29077. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29078. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29079. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29080. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29081. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29082. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29083. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29084. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29085. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29086. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29087. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29088. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29089. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29090. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29091. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29092. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29093. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29094. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29095. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29096. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29097. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29098. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29099. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29100. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29101. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29102. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29103. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29104. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29105. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29106. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29107. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29108. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29109. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29110. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29111. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29112. res.Cainfo = gzresSeven10265Two.Cainfo
  29113. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29114. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29115. //res.Infcode = infocode
  29116. } else {
  29117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29118. utils.ErrorLog("解析失败:%v", err)
  29119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29120. return
  29121. }
  29122. }
  29123. }
  29124. }
  29125. if res.Infcode == -1 {
  29126. errlog := &models.HisOrderError{
  29127. UserOrgId: adminUser.CurrentOrgId,
  29128. Ctime: time.Now().Unix(),
  29129. Mtime: time.Now().Unix(),
  29130. Number: chrg_bchno,
  29131. ErrMsg: res.ErrMsg,
  29132. Status: 1,
  29133. PatientId: id,
  29134. RecordTime: recordDateTime,
  29135. Stage: 6,
  29136. }
  29137. service.CreateErrMsgLog(errlog)
  29138. c.ServeSuccessJSON(map[string]interface{}{
  29139. "failed_code": -10,
  29140. "msg": res.ErrMsg,
  29141. })
  29142. return
  29143. } else {
  29144. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29145. order.OrderStatus = 2
  29146. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29147. order.SetlId = res.Output.Setlinfo.SetlID
  29148. order.PsnNo = res.Output.Setlinfo.PsnNo
  29149. order.PsnName = res.Output.Setlinfo.PsnName
  29150. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29151. order.Certno = res.Output.Setlinfo.Certno
  29152. order.Gend = res.Output.Setlinfo.Gend
  29153. order.Naty = res.Output.Setlinfo.Naty
  29154. order.Age = res.Output.Setlinfo.Age
  29155. order.Insutype = res.Output.Setlinfo.Insutype
  29156. order.PsnType = res.Output.Setlinfo.PsnType
  29157. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29158. order.SetlTime = res.Output.Setlinfo.SetlTime
  29159. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29160. order.PayWays = pay_ways
  29161. order.AcctUsedFlag = acct_used_flag
  29162. order.WechatPay = wechat_pay
  29163. order.AliPay = ali_pay
  29164. order.JifenPay = jifen_pay
  29165. order.BandCardPay = band_card_pay
  29166. order.CashPay = cash_pay
  29167. order.OthDesc = oth_desc
  29168. //order.MedType = res.Output.Setlinfo.MedType
  29169. if reg_type == 1112 {
  29170. order.MedType = "1112"
  29171. }
  29172. if reg_type == 1111 {
  29173. order.MedType = "1111"
  29174. }
  29175. order.ClrType = res.Output.Setlinfo.ClrType
  29176. if adminUser.CurrentOrgId == 10480 {
  29177. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29178. order.ClrType = "11"
  29179. } else {
  29180. order.ClrType = "9903"
  29181. }
  29182. }
  29183. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29184. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29185. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29186. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29187. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29188. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29189. order.HifpPay = res.Output.Setlinfo.HifpPay
  29190. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29191. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29192. order.HifesPay = res.Output.Setlinfo.HifesPay
  29193. order.HifobPay = res.Output.Setlinfo.HifobPay
  29194. order.MafPay = res.Output.Setlinfo.MafPay
  29195. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29196. order.OthPay = res.Output.Setlinfo.OthPay
  29197. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29198. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29199. order.AcctPay = res.Output.Setlinfo.AcctPay
  29200. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29201. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29202. order.Balc = res.Output.Setlinfo.Balc
  29203. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29204. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29205. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29206. order.ClrWay = res.Output.Setlinfo.ClrWay
  29207. order.Creator = order.Creator
  29208. order.Modify = roles.AdminUserId
  29209. order.RequestLog = src_resquest
  29210. order.Diagnosis = diagnosis_id
  29211. order.FaPiaoNumber = fapiao_number
  29212. order.FaPiaoCode = fapiao_code
  29213. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29214. detailStr := string(setlDetail)
  29215. order.SetlDetail = detailStr
  29216. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29217. err = service.UpDateOrder(order)
  29218. if err == nil {
  29219. //判断是否使用了押金
  29220. if dec_way == "true" {
  29221. tmpstring := strconv.FormatInt(order.ID, 10)
  29222. //扣押金
  29223. order.Decimal = decimal
  29224. service.UpDateOrder(order)
  29225. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  29226. if errmsg != nil {
  29227. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  29228. return
  29229. }
  29230. }
  29231. c.ServeSuccessJSON(map[string]interface{}{
  29232. "msg": "结算成功",
  29233. })
  29234. } else {
  29235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29236. return
  29237. }
  29238. }
  29239. }
  29240. }
  29241. }
  29242. // 上传明细-预结算-
  29243. func (c *HisApiController) GetPreUploadInfo() {
  29244. id, _ := c.GetInt64("id")
  29245. record_time := c.GetString("record_time")
  29246. his_patient_id, _ := c.GetInt64("his_patient_id")
  29247. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  29248. admin_user_id, _ := c.GetInt64("admin_user_id")
  29249. diagnosis_id := c.GetString("diagnosis")
  29250. sick_type, _ := c.GetInt64("sick_type")
  29251. reg_type, _ := c.GetInt64("p_type")
  29252. begin_time := c.GetString("begin_time")
  29253. acct_used_flag := c.GetString("acct_used_flag")
  29254. id_str := c.GetString("ids")
  29255. ids_arr := strings.Split(id_str, ",")
  29256. timeLayout := "2006-01-02"
  29257. loc, _ := time.LoadLocation("Local")
  29258. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29259. if err != nil {
  29260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29261. return
  29262. }
  29263. recordDateTime := theTime.Unix()
  29264. adminUser := c.GetAdminUserInfo()
  29265. diagnosis_ids := strings.Split(diagnosis_id, ",")
  29266. var config []*models.HisXtDiagnoseConfig
  29267. for _, item := range diagnosis_ids {
  29268. id, _ := strconv.ParseInt(item, 10, 64)
  29269. if id > 0 {
  29270. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29271. config = append(config, &diagnosisConfig)
  29272. }
  29273. }
  29274. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  29275. sickConfig, _ := service.FindSickById(sick_type)
  29276. var prescriptions []*models.HisPrescription
  29277. var start_time int64
  29278. var end_time int64
  29279. var isSuccess bool = true
  29280. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29281. fmt.Println(his_patient_id)
  29282. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29283. timestamp := time.Now().Unix()
  29284. tempTime := time.Unix(timestamp, 0)
  29285. timeFormat := tempTime.Format("20060102150405")
  29286. chrgBchno := rand.Intn(100000) + 10000
  29287. new_chrg_bchno := ""
  29288. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  29289. new_chrg_bchno = chrg_bchno
  29290. if adminUser.CurrentOrgId == 10265 {
  29291. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29292. new_chrg_bchno = "0000"
  29293. }
  29294. }
  29295. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29296. var patientPrescription models.HisPrescriptionInfo
  29297. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29298. if patientPrescription.ID == 0 {
  29299. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  29300. }
  29301. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29302. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29303. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29304. strconv.FormatInt(his.PatientId, 10)
  29305. var res2406 Result2406
  29306. //安徽单病种处理
  29307. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  29308. data := make(map[string]interface{})
  29309. client := &http.Client{}
  29310. data["psn_no"] = his.PsnNo
  29311. data["mdtrt_id"] = his.Number
  29312. data["operator"] = roles.UserName
  29313. data["cert_no"] = his.IdCardNo
  29314. data["org_name"] = miConfig.OrgName
  29315. data["psn_name"] = his.Name
  29316. data["ipt_otp_no"] = his.IptOtpNo
  29317. data["ipt_psn_sp_flag_type"] = "0901"
  29318. data["ipt_psn_sp_flag"] = "1"
  29319. data["fixmedins_code"] = miConfig.Code
  29320. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29321. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29322. data["url"] = miConfig.Url
  29323. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29324. bytesData, _ := json.Marshal(data)
  29325. var req *http.Request
  29326. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29327. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29328. resp, _ := client.Do(req)
  29329. defer resp.Body.Close()
  29330. body, ioErr := ioutil.ReadAll(resp.Body)
  29331. if ioErr != nil {
  29332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29334. return
  29335. }
  29336. var respJSON map[string]interface{}
  29337. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29340. return
  29341. }
  29342. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29343. if status == "0" {
  29344. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29345. c.ServeSuccessJSON(map[string]interface{}{
  29346. "failed_code": -10,
  29347. "msg": err_msg,
  29348. })
  29349. return
  29350. }
  29351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29352. userJSONBytes, _ := json.Marshal(respJSON)
  29353. fmt.Println("log")
  29354. fmt.Println(string(userJSONBytes))
  29355. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29356. utils.ErrorLog("解析失败:%v", err)
  29357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29358. return
  29359. }
  29360. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  29361. data := make(map[string]interface{})
  29362. client := &http.Client{}
  29363. data["psn_no"] = his.PsnNo
  29364. data["mdtrt_id"] = his.Number
  29365. data["operator"] = roles.UserName
  29366. data["cert_no"] = his.IdCardNo
  29367. data["org_name"] = miConfig.OrgName
  29368. data["psn_name"] = his.Name
  29369. data["ipt_otp_no"] = his.IptOtpNo
  29370. data["ipt_psn_sp_flag_type"] = "0901"
  29371. data["ipt_psn_sp_flag"] = "1"
  29372. data["fixmedins_code"] = miConfig.Code
  29373. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29374. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29375. data["url"] = miConfig.Url
  29376. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29377. bytesData, _ := json.Marshal(data)
  29378. var req *http.Request
  29379. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29380. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29381. resp, _ := client.Do(req)
  29382. defer resp.Body.Close()
  29383. body, ioErr := ioutil.ReadAll(resp.Body)
  29384. if ioErr != nil {
  29385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29387. return
  29388. }
  29389. var respJSON map[string]interface{}
  29390. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29393. return
  29394. }
  29395. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29396. if status == "0" {
  29397. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29398. c.ServeSuccessJSON(map[string]interface{}{
  29399. "failed_code": -10,
  29400. "msg": err_msg,
  29401. })
  29402. return
  29403. }
  29404. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29405. userJSONBytes, _ := json.Marshal(respJSON)
  29406. fmt.Println("log")
  29407. fmt.Println(string(userJSONBytes))
  29408. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29409. utils.ErrorLog("解析失败:%v", err)
  29410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29411. return
  29412. }
  29413. }
  29414. if res2406.Infcode != 0 {
  29415. adminUser := c.GetAdminUserInfo()
  29416. errlog := &models.HisOrderError{
  29417. UserOrgId: adminUser.CurrentOrgId,
  29418. Ctime: time.Now().Unix(),
  29419. Mtime: time.Now().Unix(),
  29420. ErrMsg: res2406.ErrMsg,
  29421. Status: 1,
  29422. PatientId: id,
  29423. RecordTime: recordDateTime,
  29424. Stage: 3,
  29425. }
  29426. service.CreateErrMsgLog(errlog)
  29427. c.ServeSuccessJSON(map[string]interface{}{
  29428. "failed_code": -10,
  29429. "msg": res2406.ErrMsg,
  29430. })
  29431. return
  29432. }
  29433. var res2 ResultSix
  29434. var res3 GZResultSix
  29435. var resSix10265 ResultSix10265
  29436. //var time_stamp string
  29437. if miConfig.MdtrtareaAdmvs == "421300" {
  29438. data := make(map[string]interface{})
  29439. client := &http.Client{}
  29440. data["psn_no"] = his.PsnNo
  29441. data["mdtrt_id"] = his.Number
  29442. data["department"] = department.Name
  29443. data["org_name"] = miConfig.OrgName
  29444. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29445. data["doctor_id"] = doctor_info.DoctorNumber
  29446. data["doctor_name"] = roles.UserName
  29447. data["fixmedins_code"] = miConfig.Code
  29448. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29449. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29450. data["secret_key"] = miConfig.SecretKey
  29451. data["sick_code"] = sickConfig.CountryCode
  29452. data["sick_name"] = sickConfig.ClassName
  29453. data["begin_time"] = begin_time
  29454. data["dept"] = strconv.FormatInt(department.ID, 10)
  29455. data["config"] = config
  29456. data["opter"] = roles.UserName
  29457. fmt.Println(data)
  29458. bytesData, _ := json.Marshal(data)
  29459. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29460. resp, _ := client.Do(req)
  29461. defer resp.Body.Close()
  29462. body, ioErr := ioutil.ReadAll(resp.Body)
  29463. if ioErr != nil {
  29464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29466. return
  29467. }
  29468. var respJSON map[string]interface{}
  29469. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29472. return
  29473. }
  29474. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29475. userJSONBytes, _ := json.Marshal(respJSON)
  29476. fmt.Println("log")
  29477. fmt.Println(string(userJSONBytes))
  29478. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29479. utils.ErrorLog("解析失败:%v", err)
  29480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29481. return
  29482. }
  29483. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29484. data := make(map[string]interface{})
  29485. client := &http.Client{}
  29486. data["psn_no"] = his.PsnNo
  29487. data["mdtrt_id"] = his.Number
  29488. data["department"] = department.Name
  29489. data["org_name"] = miConfig.OrgName
  29490. if reg_type == 11 && his.Insutype == "390" {
  29491. data["med_type"] = "110104"
  29492. } else {
  29493. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29494. }
  29495. data["doctor_id"] = doctor_info.DoctorNumber
  29496. data["doctor_name"] = roles.UserName
  29497. data["fixmedins_code"] = miConfig.Code
  29498. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29499. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29500. data["secret_key"] = miConfig.SecretKey
  29501. data["sick_code"] = sickConfig.CountryCode
  29502. data["sick_name"] = sickConfig.ClassName
  29503. data["begin_time"] = begin_time
  29504. data["dept"] = strconv.FormatInt(department.ID, 10)
  29505. data["config"] = config
  29506. data["opter"] = roles.UserName
  29507. fmt.Println(data)
  29508. bytesData, _ := json.Marshal(data)
  29509. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29510. resp, _ := client.Do(req)
  29511. defer resp.Body.Close()
  29512. body, ioErr := ioutil.ReadAll(resp.Body)
  29513. if ioErr != nil {
  29514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29516. return
  29517. }
  29518. var respJSON map[string]interface{}
  29519. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29522. return
  29523. }
  29524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29525. userJSONBytes, _ := json.Marshal(respJSON)
  29526. fmt.Println("log")
  29527. fmt.Println(string(userJSONBytes))
  29528. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29529. utils.ErrorLog("解析失败:%v", err)
  29530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29531. return
  29532. }
  29533. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29534. data := make(map[string]interface{})
  29535. client := &http.Client{}
  29536. data["psn_no"] = his.PsnNo
  29537. data["mdtrt_id"] = his.Number
  29538. data["department"] = department.Name
  29539. data["org_name"] = miConfig.OrgName
  29540. if reg_type == 11 && his.Insutype == "390" {
  29541. data["med_type"] = "110104"
  29542. } else {
  29543. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29544. }
  29545. data["doctor_id"] = doctor_info.DoctorNumber
  29546. data["doctor_name"] = roles.UserName
  29547. data["fixmedins_code"] = miConfig.Code
  29548. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29549. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29550. data["secret_key"] = miConfig.SecretKey
  29551. data["sick_code"] = sickConfig.CountryCode
  29552. data["sick_name"] = sickConfig.ClassName
  29553. data["begin_time"] = begin_time
  29554. data["dept"] = strconv.FormatInt(department.ID, 10)
  29555. data["config"] = config
  29556. data["opter"] = roles.UserName
  29557. fmt.Println(data)
  29558. bytesData, _ := json.Marshal(data)
  29559. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29560. resp, _ := client.Do(req)
  29561. defer resp.Body.Close()
  29562. body, ioErr := ioutil.ReadAll(resp.Body)
  29563. if ioErr != nil {
  29564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29566. return
  29567. }
  29568. var respJSON map[string]interface{}
  29569. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29572. return
  29573. }
  29574. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29575. userJSONBytes, _ := json.Marshal(respJSON)
  29576. fmt.Println("log")
  29577. fmt.Println(string(userJSONBytes))
  29578. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29579. utils.ErrorLog("解析失败:%v", err)
  29580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29581. return
  29582. }
  29583. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29584. data := make(map[string]interface{})
  29585. client := &http.Client{}
  29586. data["psn_no"] = his.PsnNo
  29587. data["mdtrt_id"] = his.Number
  29588. data["department"] = department.Name
  29589. data["org_name"] = miConfig.OrgName
  29590. if reg_type == 11 && his.Insutype == "390" {
  29591. data["med_type"] = "110104"
  29592. } else {
  29593. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29594. }
  29595. data["doctor_id"] = doctor_info.DoctorNumber
  29596. data["doctor_name"] = roles.UserName
  29597. data["fixmedins_code"] = miConfig.Code
  29598. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29599. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29600. data["secret_key"] = miConfig.SecretKey
  29601. data["sick_code"] = sickConfig.CountryCode
  29602. data["sick_name"] = sickConfig.ClassName
  29603. data["begin_time"] = begin_time
  29604. data["dept"] = strconv.FormatInt(department.ID, 10)
  29605. data["config"] = config
  29606. data["opter"] = roles.UserName
  29607. fmt.Println(data)
  29608. bytesData, _ := json.Marshal(data)
  29609. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29610. resp, _ := client.Do(req)
  29611. defer resp.Body.Close()
  29612. body, ioErr := ioutil.ReadAll(resp.Body)
  29613. if ioErr != nil {
  29614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29616. return
  29617. }
  29618. var respJSON map[string]interface{}
  29619. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29622. return
  29623. }
  29624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29625. userJSONBytes, _ := json.Marshal(respJSON)
  29626. fmt.Println("log")
  29627. fmt.Println(string(userJSONBytes))
  29628. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29629. utils.ErrorLog("解析失败:%v", err)
  29630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29631. return
  29632. }
  29633. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  29634. data := make(map[string]interface{})
  29635. client := &http.Client{}
  29636. data["psn_no"] = his.PsnNo
  29637. data["mdtrt_id"] = his.Number
  29638. data["doctor"] = roles.UserName
  29639. data["department"] = department.Name
  29640. data["org_name"] = miConfig.OrgName
  29641. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29642. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  29643. data["fixmedins_code"] = miConfig.Code
  29644. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29645. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29646. data["secret_key"] = miConfig.SecretKey
  29647. data["sick_code"] = sickConfig.CountryCode
  29648. data["sick_name"] = sickConfig.ClassName
  29649. data["begin_time"] = begin_time
  29650. data["dept"] = strconv.FormatInt(department.ID, 10)
  29651. data["config"] = config
  29652. data["url"] = miConfig.Url
  29653. data["ak"] = miConfig.AccessKey
  29654. data["cainfo"] = miConfig.Cainfo
  29655. bytesData, _ := json.Marshal(data)
  29656. var req *http.Request
  29657. if miConfig.MdtrtareaAdmvs == "320830" {
  29658. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  29659. } else if miConfig.MdtrtareaAdmvs == "320921" {
  29660. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29661. } else {
  29662. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29663. }
  29664. resp, _ := client.Do(req)
  29665. defer resp.Body.Close()
  29666. body, ioErr := ioutil.ReadAll(resp.Body)
  29667. if ioErr != nil {
  29668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29670. return
  29671. }
  29672. var respJSON map[string]interface{}
  29673. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29676. return
  29677. }
  29678. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29679. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29680. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29681. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29682. userJSONBytes, _ := json.Marshal(respJSON)
  29683. fmt.Println("log")
  29684. fmt.Println(string(userJSONBytes))
  29685. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29686. utils.ErrorLog("解析失败:%v", err)
  29687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29688. return
  29689. }
  29690. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29691. res2.Output = resSix10265.Output
  29692. res2.ErrMsg = resSix10265.ErrMsg
  29693. res2.Cainfo = resSix10265.Cainfo
  29694. res2.WarnMsg = resSix10265.WarnMsg
  29695. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29696. res2.Infcode = infocode
  29697. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29698. data := make(map[string]interface{})
  29699. client := &http.Client{}
  29700. data["psn_no"] = his.PsnNo
  29701. data["mdtrt_id"] = his.Number
  29702. data["doctor"] = roles.UserName
  29703. data["department"] = department.Name
  29704. data["org_name"] = miConfig.OrgName
  29705. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29706. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  29707. data["fixmedins_code"] = miConfig.Code
  29708. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29709. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29710. data["secret_key"] = miConfig.SecretKey
  29711. data["sick_code"] = sickConfig.CountryCode
  29712. data["sick_name"] = sickConfig.ClassName
  29713. data["begin_time"] = begin_time
  29714. data["dept"] = strconv.FormatInt(department.ID, 10)
  29715. data["config"] = config
  29716. //data["url"] = miConfig.Url
  29717. //data["ak"] = miConfig.AccessKey
  29718. data["cainfo"] = miConfig.Cainfo
  29719. fmt.Println(data)
  29720. bytesData, _ := json.Marshal(data)
  29721. var req *http.Request
  29722. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  29723. resp, _ := client.Do(req)
  29724. defer resp.Body.Close()
  29725. body, ioErr := ioutil.ReadAll(resp.Body)
  29726. if ioErr != nil {
  29727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29729. return
  29730. }
  29731. var respJSON map[string]interface{}
  29732. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29735. return
  29736. }
  29737. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29738. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29739. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29741. userJSONBytes, _ := json.Marshal(respJSON)
  29742. fmt.Println("log")
  29743. fmt.Println(string(userJSONBytes))
  29744. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29745. utils.ErrorLog("解析失败:%v", err)
  29746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29747. return
  29748. }
  29749. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29750. res2.Output = resSix10265.Output
  29751. res2.ErrMsg = resSix10265.ErrMsg
  29752. res2.Cainfo = resSix10265.Cainfo
  29753. res2.WarnMsg = resSix10265.WarnMsg
  29754. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29755. res2.Infcode = infocode
  29756. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29757. 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)
  29758. saveLog(result, requestLog, "2203", "上传就诊信息")
  29759. var respJSON2 map[string]interface{}
  29760. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29763. return
  29764. }
  29765. userJSONBytes2, _ := json.Marshal(respJSON2)
  29766. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29767. utils.ErrorLog("解析失败:%v", err)
  29768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29769. return
  29770. }
  29771. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29772. var result string
  29773. var requestLog string
  29774. 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, "")
  29775. saveLog(result, requestLog, "2203", "上传就诊信息")
  29776. var respJSON2 map[string]interface{}
  29777. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29780. return
  29781. }
  29782. userJSONBytes2, _ := json.Marshal(respJSON2)
  29783. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29784. utils.ErrorLog("解析失败:%v", err)
  29785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29786. return
  29787. }
  29788. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29789. var result string
  29790. var requestLog string
  29791. 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, "")
  29792. saveLog(result, requestLog, "2203", "上传就诊信息")
  29793. var respJSON2 map[string]interface{}
  29794. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29797. return
  29798. }
  29799. userJSONBytes2, _ := json.Marshal(respJSON2)
  29800. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29801. utils.ErrorLog("解析失败:%v", err)
  29802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29803. return
  29804. }
  29805. } else if miConfig.MdtrtareaAdmvs == "360100" {
  29806. var result string
  29807. var requestLog string
  29808. 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, "")
  29809. saveLog(result, requestLog, "2203", "上传就诊信息")
  29810. var respJSON2 map[string]interface{}
  29811. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29814. return
  29815. }
  29816. userJSONBytes2, _ := json.Marshal(respJSON2)
  29817. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29818. utils.ErrorLog("解析失败:%v", err)
  29819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29820. return
  29821. }
  29822. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29823. data := make(map[string]interface{})
  29824. client := &http.Client{}
  29825. data["psn_no"] = his.PsnNo
  29826. data["mdtrt_id"] = his.Number
  29827. data["operator"] = roles.UserName
  29828. data["department"] = department.Name
  29829. data["org_name"] = miConfig.OrgName
  29830. var med_type string
  29831. if his.Insutype == "390" {
  29832. if reg_type == 992102 {
  29833. med_type = "992102"
  29834. data["sick_code"] = "ZDZ940"
  29835. data["sick_name"] = "慢性肾衰竭"
  29836. }
  29837. if reg_type == 140104 {
  29838. med_type = "140104"
  29839. data["sick_code"] = sickConfig.CountryCode
  29840. data["sick_name"] = sickConfig.ClassName
  29841. }
  29842. if reg_type == 14 {
  29843. med_type = "140104"
  29844. data["sick_code"] = sickConfig.CountryCode
  29845. data["sick_name"] = sickConfig.ClassName
  29846. }
  29847. if reg_type == 1104 {
  29848. med_type = "1104"
  29849. data["sick_code"] = sickConfig.CountryCode
  29850. data["sick_name"] = sickConfig.ClassName
  29851. }
  29852. } else if his.Insutype == "310" {
  29853. if reg_type == 992102 {
  29854. med_type = "992102"
  29855. data["sick_code"] = "ZDZ940"
  29856. data["sick_name"] = "慢性肾衰竭"
  29857. }
  29858. if reg_type == 140104 {
  29859. med_type = "140104"
  29860. data["sick_code"] = sickConfig.CountryCode
  29861. data["sick_name"] = sickConfig.ClassName
  29862. }
  29863. if reg_type == 14 {
  29864. med_type = "14"
  29865. data["sick_code"] = sickConfig.CountryCode
  29866. data["sick_name"] = sickConfig.ClassName
  29867. }
  29868. if reg_type == 1104 {
  29869. med_type = "1104"
  29870. data["sick_code"] = sickConfig.CountryCode
  29871. data["sick_name"] = sickConfig.ClassName
  29872. }
  29873. }
  29874. data["med_type"] = med_type
  29875. data["doctor_number"] = doctor_info.DoctorNumber
  29876. data["doctor_name"] = doctor_info.UserName
  29877. data["fixmedins_code"] = miConfig.Code
  29878. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29879. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29880. data["secret_key"] = miConfig.SecretKey
  29881. data["begin_time"] = begin_time
  29882. data["dept"] = strconv.FormatInt(department.ID, 10)
  29883. data["config"] = config
  29884. data["url"] = miConfig.Url
  29885. data["ak"] = miConfig.AccessKey
  29886. data["cainfo"] = miConfig.Cainfo
  29887. bytesData, _ := json.Marshal(data)
  29888. var req *http.Request
  29889. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  29890. resp, _ := client.Do(req)
  29891. defer resp.Body.Close()
  29892. body, ioErr := ioutil.ReadAll(resp.Body)
  29893. if ioErr != nil {
  29894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29896. return
  29897. }
  29898. var respJSON map[string]interface{}
  29899. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29902. return
  29903. }
  29904. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29905. if status == "0" {
  29906. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29907. c.ServeSuccessJSON(map[string]interface{}{
  29908. "failed_code": -10,
  29909. "msg": err_msg,
  29910. })
  29911. return
  29912. }
  29913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29914. userJSONBytes, _ := json.Marshal(respJSON)
  29915. fmt.Println("log")
  29916. fmt.Println(string(userJSONBytes))
  29917. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29918. utils.ErrorLog("解析失败:%v", err)
  29919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29920. return
  29921. }
  29922. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29923. data := make(map[string]interface{})
  29924. client := &http.Client{}
  29925. data["psn_no"] = his.PsnNo
  29926. data["mdtrt_id"] = his.Number
  29927. data["operator"] = roles.UserName
  29928. data["department"] = department.Name
  29929. data["org_name"] = miConfig.OrgName
  29930. var med_type string
  29931. if his.Insutype == "390" {
  29932. if reg_type == 992102 {
  29933. med_type = "992102"
  29934. data["sick_code"] = sickConfig.CountryCode
  29935. data["sick_name"] = sickConfig.ClassName
  29936. }
  29937. if reg_type == 140104 {
  29938. med_type = "140104"
  29939. data["sick_code"] = sickConfig.CountryCode
  29940. data["sick_name"] = sickConfig.ClassName
  29941. }
  29942. if reg_type == 140201 {
  29943. med_type = "140201"
  29944. data["sick_code"] = sickConfig.CountryCode
  29945. data["sick_name"] = sickConfig.ClassName
  29946. }
  29947. if reg_type == 14 {
  29948. med_type = "14"
  29949. data["sick_code"] = sickConfig.CountryCode
  29950. data["sick_name"] = sickConfig.ClassName
  29951. }
  29952. if reg_type == 11 {
  29953. med_type = "11"
  29954. data["sick_code"] = sickConfig.CountryCode
  29955. data["sick_name"] = sickConfig.ClassName
  29956. }
  29957. } else if his.Insutype == "310" {
  29958. if reg_type == 992102 {
  29959. med_type = "992102"
  29960. data["sick_code"] = sickConfig.CountryCode
  29961. data["sick_name"] = sickConfig.ClassName
  29962. }
  29963. if reg_type == 140104 {
  29964. med_type = "140104"
  29965. data["sick_code"] = sickConfig.CountryCode
  29966. data["sick_name"] = sickConfig.ClassName
  29967. }
  29968. if reg_type == 140201 {
  29969. med_type = "140201"
  29970. data["sick_code"] = sickConfig.CountryCode
  29971. data["sick_name"] = sickConfig.ClassName
  29972. }
  29973. if reg_type == 14 {
  29974. med_type = "14"
  29975. data["sick_code"] = sickConfig.CountryCode
  29976. data["sick_name"] = sickConfig.ClassName
  29977. }
  29978. if reg_type == 11 {
  29979. med_type = "11"
  29980. data["sick_code"] = sickConfig.CountryCode
  29981. data["sick_name"] = sickConfig.ClassName
  29982. }
  29983. }
  29984. data["med_type"] = med_type
  29985. data["doctor_number"] = doctor_info.DoctorNumber
  29986. data["doctor_name"] = doctor_info.UserName
  29987. data["fixmedins_code"] = miConfig.Code
  29988. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29989. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29990. data["secret_key"] = miConfig.SecretKey
  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. bytesData, _ := json.Marshal(data)
  29998. var req *http.Request
  29999. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30000. resp, _ := client.Do(req)
  30001. defer resp.Body.Close()
  30002. body, ioErr := ioutil.ReadAll(resp.Body)
  30003. if ioErr != nil {
  30004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30006. return
  30007. }
  30008. var respJSON map[string]interface{}
  30009. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30012. return
  30013. }
  30014. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30015. if status == "0" {
  30016. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30017. c.ServeSuccessJSON(map[string]interface{}{
  30018. "failed_code": -10,
  30019. "msg": err_msg,
  30020. })
  30021. return
  30022. }
  30023. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30024. userJSONBytes, _ := json.Marshal(respJSON)
  30025. fmt.Println("log")
  30026. fmt.Println(string(userJSONBytes))
  30027. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30028. utils.ErrorLog("解析失败:%v", err)
  30029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30030. return
  30031. }
  30032. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30033. var result string
  30034. var requestLog string
  30035. 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)
  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 == "441799" {
  30050. data := make(map[string]interface{})
  30051. client := &http.Client{}
  30052. data["psn_no"] = his.PsnNo
  30053. data["mdtrt_id"] = his.Number
  30054. data["doctor"] = roles.UserName
  30055. data["department"] = department.Name
  30056. data["org_name"] = miConfig.OrgName
  30057. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30058. data["doctor_id"] = doctor_info.DoctorNumber
  30059. data["fixmedins_code"] = miConfig.Code
  30060. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30061. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30062. data["secret_key"] = miConfig.SecretKey
  30063. data["sick_code"] = sickConfig.CountryCode
  30064. data["sick_name"] = sickConfig.ClassName
  30065. data["begin_time"] = begin_time
  30066. data["new_doctor_name"] = doctor_info.UserName
  30067. data["dept"] = strconv.FormatInt(department.ID, 10)
  30068. data["config"] = config
  30069. bytesData, _ := json.Marshal(data)
  30070. var req *http.Request
  30071. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  30072. resp, _ := client.Do(req)
  30073. defer resp.Body.Close()
  30074. body, ioErr := ioutil.ReadAll(resp.Body)
  30075. if ioErr != nil {
  30076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30078. return
  30079. }
  30080. var respJSON map[string]interface{}
  30081. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30084. return
  30085. }
  30086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30087. userJSONBytes, _ := json.Marshal(respJSON)
  30088. fmt.Println("log")
  30089. fmt.Println(string(userJSONBytes))
  30090. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30091. utils.ErrorLog("解析失败:%v", err)
  30092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30093. return
  30094. }
  30095. } else {
  30096. var result string
  30097. var requestLog string
  30098. if miConfig.MdtrtareaAdmvs == "440781" { //
  30099. 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)
  30100. } else {
  30101. if miConfig.Code == "H15049901371" {
  30102. //赤峰地区国家医保医疗类别
  30103. //职工透析:医疗类别选特殊情况门诊990502
  30104. //居民定额血透门慢: 医疗类别选门诊慢病140104
  30105. var med_type string
  30106. if his.Insutype == "390" {
  30107. if reg_type == 14 {
  30108. med_type = "9933"
  30109. } else if reg_type == 11 {
  30110. med_type = "11"
  30111. }
  30112. } else if his.Insutype == "310" {
  30113. if reg_type == 14 {
  30114. med_type = "990502"
  30115. } else if reg_type == 11 {
  30116. med_type = "11"
  30117. }
  30118. }
  30119. 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)
  30120. } else {
  30121. 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)
  30122. }
  30123. saveLog(result, requestLog, "2203", "上传就诊信息")
  30124. var respJSON2 map[string]interface{}
  30125. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30128. return
  30129. }
  30130. userJSONBytes2, _ := json.Marshal(respJSON2)
  30131. if miConfig.Code == "H15049901371" {
  30132. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  30133. utils.ErrorLog("解析失败:%v", err)
  30134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30135. return
  30136. }
  30137. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30138. res2.Output = resSix10265.Output
  30139. res2.ErrMsg = resSix10265.ErrMsg
  30140. res2.Cainfo = resSix10265.Cainfo
  30141. res2.WarnMsg = resSix10265.WarnMsg
  30142. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30143. res2.Infcode = infocode
  30144. } else {
  30145. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30146. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  30147. utils.ErrorLog("解析失败:%v", err)
  30148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30149. return
  30150. }
  30151. res2.Infcode = res3.Infcode
  30152. } else {
  30153. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30154. utils.ErrorLog("解析失败:%v", err)
  30155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30156. return
  30157. }
  30158. }
  30159. }
  30160. }
  30161. }
  30162. if res2.Infcode == -1 {
  30163. adminUser := c.GetAdminUserInfo()
  30164. errlog := &models.HisOrderError{
  30165. UserOrgId: adminUser.CurrentOrgId,
  30166. Ctime: time.Now().Unix(),
  30167. Mtime: time.Now().Unix(),
  30168. ErrMsg: res2.ErrMsg,
  30169. Status: 1,
  30170. PatientId: id,
  30171. RecordTime: recordDateTime,
  30172. Stage: 3,
  30173. }
  30174. service.CreateErrMsgLog(errlog)
  30175. c.ServeSuccessJSON(map[string]interface{}{
  30176. "failed_code": -10,
  30177. "msg": res2.ErrMsg,
  30178. })
  30179. return
  30180. }
  30181. if res2.Infcode != 0 {
  30182. adminUser := c.GetAdminUserInfo()
  30183. errlog := &models.HisOrderError{
  30184. UserOrgId: adminUser.CurrentOrgId,
  30185. Ctime: time.Now().Unix(),
  30186. Mtime: time.Now().Unix(),
  30187. ErrMsg: res2.ErrMsg,
  30188. Status: 1,
  30189. PatientId: id,
  30190. RecordTime: recordDateTime,
  30191. Stage: 3,
  30192. }
  30193. service.CreateErrMsgLog(errlog)
  30194. c.ServeSuccessJSON(map[string]interface{}{
  30195. "failed_code": -10,
  30196. "msg": res2.ErrMsg,
  30197. })
  30198. return
  30199. } else {
  30200. his.Diagnosis = diagnosis_id
  30201. his.SickType = sickConfig.ID
  30202. his.PType = fmt.Sprintf("%d", reg_type)
  30203. service.UpdateHisPatientThree(&his)
  30204. data := make(map[string]interface{})
  30205. if settle_accounts_type == 1 { //日结
  30206. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  30207. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  30208. } else {
  30209. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  30210. }
  30211. data["pre"] = prescriptions
  30212. } else { //月结
  30213. start_time_str := c.GetString("start_time")
  30214. end_time_str := c.GetString("end_time")
  30215. timeLayout := "2006-01-02"
  30216. loc, _ := time.LoadLocation("Local")
  30217. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  30218. if err != nil {
  30219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30220. return
  30221. }
  30222. recordStartTime := theStartTime.Unix()
  30223. start_time = recordStartTime
  30224. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  30225. if err != nil {
  30226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30227. return
  30228. }
  30229. recordEndTime := theEndTime.Unix()
  30230. end_time = recordEndTime
  30231. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  30232. data["pre"] = prescriptions
  30233. }
  30234. client := &http.Client{}
  30235. data["psn_no"] = his.PsnNo
  30236. data["mdtrt_id"] = his.Number
  30237. data["chrg_bchno"] = new_chrg_bchno
  30238. data["org_name"] = miConfig.OrgName
  30239. data["doctor"] = doctor_info.UserName
  30240. data["doctor_id"] = doctor_info.DoctorNumber
  30241. data["dept"] = department.Name
  30242. data["fixmedins_code"] = miConfig.Code
  30243. data["opter"] = roles.UserName
  30244. data["dept_code"] = department.Number
  30245. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30246. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30247. data["secret_key"] = miConfig.SecretKey
  30248. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  30249. data["url"] = miConfig.Url
  30250. data["ak"] = miConfig.AccessKey
  30251. data["new_doctor_name"] = patientPrescription.Doctor
  30252. if his.Insutype == "390" {
  30253. if reg_type == 992102 {
  30254. data["diag_code"] = "ZDZ940"
  30255. }
  30256. if reg_type == 140104 {
  30257. data["diag_code"] = sickConfig.CountryCode
  30258. }
  30259. if reg_type == 140201 {
  30260. data["diag_code"] = sickConfig.CountryCode
  30261. }
  30262. if reg_type == 14 {
  30263. data["diag_code"] = sickConfig.CountryCode
  30264. }
  30265. if reg_type == 1104 {
  30266. data["diag_code"] = sickConfig.CountryCode
  30267. }
  30268. } else if his.Insutype == "310" {
  30269. if miConfig.MdtrtareaAdmvs == "341203" {
  30270. if reg_type == 992102 {
  30271. data["diag_code"] = "ZDZ940"
  30272. }
  30273. if reg_type != 992102 {
  30274. data["diag_code"] = sickConfig.CountryCode
  30275. }
  30276. } else {
  30277. data["diag_code"] = sickConfig.CountryCode
  30278. }
  30279. }
  30280. data["cainfo"] = miConfig.Cainfo
  30281. data["opter"] = roles.UserName
  30282. var ids []int64
  30283. for _, item := range prescriptions {
  30284. ids = append(ids, item.ID)
  30285. }
  30286. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30287. if config.IsOpen == 1 { //对接了医保,走医保流程
  30288. var res ResultFour
  30289. var resFour10265 ResultFour10265
  30290. if miConfig.MdtrtareaAdmvs == "421300" {
  30291. bytesData, _ := json.Marshal(data)
  30292. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30293. resp, _ := client.Do(req)
  30294. defer resp.Body.Close()
  30295. body, ioErr := ioutil.ReadAll(resp.Body)
  30296. if ioErr != nil {
  30297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30299. return
  30300. }
  30301. var respJSON map[string]interface{}
  30302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30305. return
  30306. }
  30307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30308. userJSONBytes, _ := json.Marshal(respJSON)
  30309. fmt.Println("log")
  30310. fmt.Println(string(userJSONBytes))
  30311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30312. utils.ErrorLog("解析失败:%v", err)
  30313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30314. return
  30315. }
  30316. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30317. bytesData, _ := json.Marshal(data)
  30318. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30319. resp, _ := client.Do(req)
  30320. defer resp.Body.Close()
  30321. body, ioErr := ioutil.ReadAll(resp.Body)
  30322. if ioErr != nil {
  30323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30325. return
  30326. }
  30327. var respJSON map[string]interface{}
  30328. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30331. return
  30332. }
  30333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30334. userJSONBytes, _ := json.Marshal(respJSON)
  30335. fmt.Println("log")
  30336. fmt.Println(string(userJSONBytes))
  30337. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30338. utils.ErrorLog("解析失败:%v", err)
  30339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30340. return
  30341. }
  30342. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30343. bytesData, _ := json.Marshal(data)
  30344. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30345. resp, _ := client.Do(req)
  30346. defer resp.Body.Close()
  30347. body, ioErr := ioutil.ReadAll(resp.Body)
  30348. if ioErr != nil {
  30349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30351. return
  30352. }
  30353. var respJSON map[string]interface{}
  30354. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30357. return
  30358. }
  30359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30360. userJSONBytes, _ := json.Marshal(respJSON)
  30361. fmt.Println("log")
  30362. fmt.Println(string(userJSONBytes))
  30363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30364. utils.ErrorLog("解析失败:%v", err)
  30365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30366. return
  30367. }
  30368. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30369. bytesData, _ := json.Marshal(data)
  30370. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30371. resp, _ := client.Do(req)
  30372. defer resp.Body.Close()
  30373. body, ioErr := ioutil.ReadAll(resp.Body)
  30374. if ioErr != nil {
  30375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30377. return
  30378. }
  30379. var respJSON map[string]interface{}
  30380. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30383. return
  30384. }
  30385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30386. userJSONBytes, _ := json.Marshal(respJSON)
  30387. fmt.Println("log")
  30388. fmt.Println(string(userJSONBytes))
  30389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30390. utils.ErrorLog("解析失败:%v", err)
  30391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30392. return
  30393. }
  30394. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  30395. var result3101 Result3101
  30396. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30397. result3101.Infcode = "0"
  30398. if result3101.Infcode == "0" {
  30399. if len(result3101.Output.Result) > 0 {
  30400. var errMsgs []string
  30401. for _, item := range result3101.Output.Result {
  30402. errMsgs = append(errMsgs, item.VolaCont)
  30403. }
  30404. c.ServeSuccessJSON(map[string]interface{}{
  30405. "failed_code": -10,
  30406. "msg": errMsgs,
  30407. })
  30408. return
  30409. } else {
  30410. if miConfig.MdtrtareaAdmvs == "320921" {
  30411. data["doctor_id"] = doctor_info.DoctorNumber
  30412. } else {
  30413. data["doctor_id"] = doctor_info.DoctorNumber
  30414. }
  30415. bytesData, _ := json.Marshal(data)
  30416. var req *http.Request
  30417. if miConfig.MdtrtareaAdmvs == "320830" {
  30418. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  30419. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30420. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30421. } else {
  30422. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30423. }
  30424. resp, _ := client.Do(req)
  30425. defer resp.Body.Close()
  30426. body, ioErr := ioutil.ReadAll(resp.Body)
  30427. if ioErr != nil {
  30428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30430. return
  30431. }
  30432. var respJSON map[string]interface{}
  30433. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30436. return
  30437. }
  30438. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30439. userJSONBytes, _ := json.Marshal(respJSON)
  30440. fmt.Println("log")
  30441. fmt.Println(string(userJSONBytes))
  30442. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30443. utils.ErrorLog("解析失败:%v", err)
  30444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30445. return
  30446. }
  30447. res.InfRefmsgid = resFour10265.InfRefmsgid
  30448. res.Output = resFour10265.Output
  30449. res.ErrMsg = resFour10265.ErrMsg
  30450. res.Cainfo = resFour10265.Cainfo
  30451. res.WarnMsg = resFour10265.WarnMsg
  30452. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30453. res.Infcode = infocode
  30454. }
  30455. }
  30456. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30457. var pagesize int = 5
  30458. var start int = 1
  30459. var stop int
  30460. var pagecount int
  30461. var curpage int
  30462. data["doctor_id"] = doctor_info.DoctorNumber
  30463. var res2 ResultFour
  30464. //var result res.
  30465. //总页数,向上取整,注意除之前要先转换类型为float64
  30466. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  30467. for curpage = 1; curpage <= pagecount; curpage++ {
  30468. if curpage == 1 {
  30469. start = 1
  30470. } else {
  30471. start = (curpage-1)*pagesize + 1
  30472. }
  30473. stop = curpage * pagesize
  30474. if stop > len(prescriptions) {
  30475. stop = len(prescriptions)
  30476. }
  30477. //var requestLog string
  30478. data["pre"] = prescriptions[start-1 : stop]
  30479. fmt.Println(data["pre"])
  30480. bytesData, _ := json.Marshal(data)
  30481. var req *http.Request
  30482. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  30483. resp, _ := client.Do(req)
  30484. defer resp.Body.Close()
  30485. body, ioErr := ioutil.ReadAll(resp.Body)
  30486. if ioErr != nil {
  30487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30489. return
  30490. }
  30491. var respJSON map[string]interface{}
  30492. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30495. return
  30496. }
  30497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30498. userJSONBytes, _ := json.Marshal(respJSON)
  30499. fmt.Println("log")
  30500. fmt.Println(string(userJSONBytes))
  30501. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30502. utils.ErrorLog("解析失败:%v", err)
  30503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30504. return
  30505. }
  30506. res.InfRefmsgid = resFour10265.InfRefmsgid
  30507. res.Output = resFour10265.Output
  30508. res.ErrMsg = resFour10265.ErrMsg
  30509. res.Cainfo = resFour10265.Cainfo
  30510. res.WarnMsg = resFour10265.WarnMsg
  30511. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30512. res.Infcode = infocode
  30513. if infocode == 0 {
  30514. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  30515. } else {
  30516. isSuccess = false
  30517. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  30518. res.Infcode = -1
  30519. res.ErrMsg = resFour10265.ErrMsg
  30520. errlog := &models.HisOrderError{
  30521. UserOrgId: adminUser.CurrentOrgId,
  30522. Ctime: time.Now().Unix(),
  30523. Mtime: time.Now().Unix(),
  30524. Number: chrg_bchno,
  30525. ErrMsg: "",
  30526. Status: 1,
  30527. PatientId: id,
  30528. RecordTime: recordDateTime,
  30529. Stage: 4,
  30530. }
  30531. service.CreateErrMsgLog(errlog)
  30532. }
  30533. }
  30534. if isSuccess {
  30535. res.Infcode = 0
  30536. res.Output.Result = res2.Output.Result
  30537. } else {
  30538. order := &models.HisOrder{
  30539. UserOrgId: adminUser.CurrentOrgId,
  30540. HisPatientId: his.ID,
  30541. PatientId: his.PatientId,
  30542. SettleAccountsDate: recordDateTime,
  30543. Ctime: time.Now().Unix(),
  30544. Mtime: time.Now().Unix(),
  30545. MdtrtId: his.Number,
  30546. PsnNo: his.PsnNo,
  30547. MedType: strconv.FormatInt(reg_type, 10),
  30548. Status: 1,
  30549. Number: chrg_bchno,
  30550. Infcode: res.Infcode,
  30551. WarnMsg: res.WarnMsg,
  30552. Cainfo: res.Cainfo,
  30553. ErrMsg: res.ErrMsg,
  30554. RespondTime: res.RefmsgTime,
  30555. InfRefmsgid: res.InfRefmsgid,
  30556. OrderStatus: 1,
  30557. IsMedicineInsurance: 1,
  30558. SettleType: settle_accounts_type,
  30559. SettleStartTime: start_time,
  30560. SettleEndTime: end_time,
  30561. Creator: roles.AdminUserId,
  30562. Modify: roles.AdminUserId,
  30563. PType: 2,
  30564. Diagnosis: diagnosis_id,
  30565. }
  30566. err = service.CreateOrder(order)
  30567. if err != nil {
  30568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30569. return
  30570. }
  30571. c.ServeSuccessJSON(map[string]interface{}{
  30572. "failed_code": -10,
  30573. "msg": res2.ErrMsg,
  30574. })
  30575. return
  30576. }
  30577. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30578. 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)
  30579. var dat map[string]interface{}
  30580. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30581. fmt.Println(dat)
  30582. } else {
  30583. fmt.Println(err)
  30584. }
  30585. saveLog(result, request_log, "2204", "上传费用明细")
  30586. userJSONBytes, _ := json.Marshal(dat)
  30587. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30588. utils.ErrorLog("解析失败:%v", err)
  30589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30590. return
  30591. }
  30592. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30593. 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, "", "")
  30594. var dat map[string]interface{}
  30595. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30596. fmt.Println(dat)
  30597. } else {
  30598. fmt.Println(err)
  30599. }
  30600. saveLog(result, request_log, "2204", "上传费用明细")
  30601. userJSONBytes, _ := json.Marshal(dat)
  30602. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30603. utils.ErrorLog("解析失败:%v", err)
  30604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30605. return
  30606. }
  30607. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30608. 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, "", "")
  30609. var dat map[string]interface{}
  30610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30611. fmt.Println(dat)
  30612. } else {
  30613. fmt.Println(err)
  30614. }
  30615. saveLog(result, request_log, "2204", "上传费用明细")
  30616. userJSONBytes, _ := json.Marshal(dat)
  30617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30618. utils.ErrorLog("解析失败:%v", err)
  30619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30620. return
  30621. }
  30622. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30623. 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, "", "")
  30624. var dat map[string]interface{}
  30625. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30626. fmt.Println(dat)
  30627. } else {
  30628. fmt.Println(err)
  30629. }
  30630. saveLog(result, request_log, "2204", "上传费用明细")
  30631. userJSONBytes, _ := json.Marshal(dat)
  30632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30633. utils.ErrorLog("解析失败:%v", err)
  30634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30635. return
  30636. }
  30637. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30638. bytesData, _ := json.Marshal(data)
  30639. var req *http.Request
  30640. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30641. resp, _ := client.Do(req)
  30642. defer resp.Body.Close()
  30643. body, ioErr := ioutil.ReadAll(resp.Body)
  30644. if ioErr != nil {
  30645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30647. return
  30648. }
  30649. var respJSON map[string]interface{}
  30650. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30653. return
  30654. }
  30655. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30656. if status == "0" {
  30657. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30658. c.ServeSuccessJSON(map[string]interface{}{
  30659. "failed_code": -10,
  30660. "msg": err_msg,
  30661. })
  30662. return
  30663. }
  30664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30665. userJSONBytes, _ := json.Marshal(respJSON)
  30666. fmt.Println("log")
  30667. fmt.Println(string(userJSONBytes))
  30668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30669. utils.ErrorLog("解析失败:%v", err)
  30670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30671. return
  30672. }
  30673. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30674. bytesData, _ := json.Marshal(data)
  30675. var req *http.Request
  30676. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30677. resp, _ := client.Do(req)
  30678. defer resp.Body.Close()
  30679. body, ioErr := ioutil.ReadAll(resp.Body)
  30680. if ioErr != nil {
  30681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30683. return
  30684. }
  30685. var respJSON map[string]interface{}
  30686. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30689. return
  30690. }
  30691. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30692. if status == "0" {
  30693. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30694. c.ServeSuccessJSON(map[string]interface{}{
  30695. "failed_code": -10,
  30696. "msg": err_msg,
  30697. })
  30698. return
  30699. }
  30700. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30701. userJSONBytes, _ := json.Marshal(respJSON)
  30702. fmt.Println("log")
  30703. fmt.Println(string(userJSONBytes))
  30704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30705. utils.ErrorLog("解析失败:%v", err)
  30706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30707. return
  30708. }
  30709. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30710. 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, "", "")
  30711. var dat map[string]interface{}
  30712. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30713. fmt.Println(dat)
  30714. } else {
  30715. fmt.Println(err)
  30716. }
  30717. saveLog(result, request_log, "2204", "上传费用明细")
  30718. userJSONBytes, _ := json.Marshal(dat)
  30719. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30720. utils.ErrorLog("解析失败:%v", err)
  30721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30722. return
  30723. }
  30724. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30725. bytesData, _ := json.Marshal(data)
  30726. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  30727. resp, _ := client.Do(req)
  30728. defer resp.Body.Close()
  30729. body, ioErr := ioutil.ReadAll(resp.Body)
  30730. if ioErr != nil {
  30731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30733. return
  30734. }
  30735. var respJSON map[string]interface{}
  30736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30739. return
  30740. }
  30741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30742. userJSONBytes, _ := json.Marshal(respJSON)
  30743. fmt.Println("log")
  30744. fmt.Println(string(userJSONBytes))
  30745. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30746. utils.ErrorLog("解析失败:%v", err)
  30747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30748. return
  30749. }
  30750. } else {
  30751. if miConfig.MdtrtareaAdmvs == "441202" {
  30752. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30753. if result3101.Infcode == 0 {
  30754. if len(result3101.Output.Result) > 0 {
  30755. var errMsgs []string
  30756. for _, item := range result3101.Output.Result {
  30757. errMsgs = append(errMsgs, item.VolaCont)
  30758. }
  30759. c.ServeSuccessJSON(map[string]interface{}{
  30760. "failed_code": -10,
  30761. "msg": errMsgs,
  30762. })
  30763. return
  30764. } else {
  30765. 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)
  30766. var dat map[string]interface{}
  30767. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30768. fmt.Println(dat)
  30769. } else {
  30770. fmt.Println(err)
  30771. }
  30772. saveLog(result, request_log, "2204", "上传费用明细")
  30773. userJSONBytes, _ := json.Marshal(dat)
  30774. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30775. utils.ErrorLog("解析失败:%v", err)
  30776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30777. return
  30778. }
  30779. }
  30780. } else {
  30781. c.ServeSuccessJSON(map[string]interface{}{
  30782. "failed_code": -10,
  30783. "msg": result3101.ErrMsg,
  30784. })
  30785. return
  30786. }
  30787. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30788. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30789. if result3101.Infcode == 0 {
  30790. if len(result3101.Output.Result) > 0 {
  30791. var errMsgs []string
  30792. for _, item := range result3101.Output.Result {
  30793. errMsgs = append(errMsgs, item.VolaCont)
  30794. }
  30795. c.ServeSuccessJSON(map[string]interface{}{
  30796. "failed_code": -10,
  30797. "msg": errMsgs,
  30798. })
  30799. return
  30800. } else {
  30801. 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)
  30802. var dat map[string]interface{}
  30803. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30804. fmt.Println(dat)
  30805. } else {
  30806. fmt.Println(err)
  30807. }
  30808. saveLog(result, request_log, "2204", "上传费用明细")
  30809. userJSONBytes, _ := json.Marshal(dat)
  30810. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30811. utils.ErrorLog("解析失败:%v", err)
  30812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30813. return
  30814. }
  30815. }
  30816. } else {
  30817. c.ServeSuccessJSON(map[string]interface{}{
  30818. "failed_code": -10,
  30819. "msg": result3101.ErrMsg,
  30820. })
  30821. return
  30822. }
  30823. } else {
  30824. if miConfig.Code == "H15049901371" {
  30825. 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)
  30826. var dat map[string]interface{}
  30827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30828. fmt.Println(dat)
  30829. } else {
  30830. fmt.Println(err)
  30831. }
  30832. saveLog(result, request_log, "2204", "上传费用明细")
  30833. userJSONBytes, _ := json.Marshal(dat)
  30834. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30835. utils.ErrorLog("解析失败:%v", err)
  30836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30837. return
  30838. }
  30839. res.InfRefmsgid = resFour10265.InfRefmsgid
  30840. res.Output = resFour10265.Output
  30841. res.ErrMsg = resFour10265.ErrMsg
  30842. res.Cainfo = resFour10265.Cainfo
  30843. res.WarnMsg = resFour10265.WarnMsg
  30844. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30845. res.Infcode = infocode
  30846. } else {
  30847. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  30848. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30849. if result3101.Infcode == 0 {
  30850. if len(result3101.Output.Result) > 0 {
  30851. c.ServeSuccessJSON(map[string]interface{}{
  30852. "failed_code": -10,
  30853. "failed_type": 100,
  30854. "warm_type": 1,
  30855. "msg": result3101,
  30856. })
  30857. return
  30858. } else {
  30859. 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)
  30860. var dat map[string]interface{}
  30861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30862. fmt.Println(dat)
  30863. } else {
  30864. fmt.Println(err)
  30865. }
  30866. saveLog(result, request_log, "2204", "上传费用明细")
  30867. userJSONBytes, _ := json.Marshal(dat)
  30868. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30869. utils.ErrorLog("解析失败:%v", err)
  30870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30871. return
  30872. }
  30873. }
  30874. } else {
  30875. c.ServeSuccessJSON(map[string]interface{}{
  30876. "failed_code": -10,
  30877. "msg": result3101.ErrMsg,
  30878. })
  30879. return
  30880. }
  30881. } else {
  30882. 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)
  30883. var dat map[string]interface{}
  30884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30885. fmt.Println(dat)
  30886. } else {
  30887. fmt.Println(err)
  30888. }
  30889. saveLog(result, request_log, "2204", "上传费用明细")
  30890. userJSONBytes, _ := json.Marshal(dat)
  30891. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30892. utils.ErrorLog("解析失败:%v", err)
  30893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30894. return
  30895. }
  30896. }
  30897. }
  30898. }
  30899. }
  30900. var total_two float64
  30901. if res.Infcode == -1 {
  30902. errlog := &models.HisOrderError{
  30903. UserOrgId: adminUser.CurrentOrgId,
  30904. Ctime: time.Now().Unix(),
  30905. Mtime: time.Now().Unix(),
  30906. Number: chrg_bchno,
  30907. ErrMsg: res.ErrMsg,
  30908. Status: 1,
  30909. PatientId: id,
  30910. RecordTime: recordDateTime,
  30911. Stage: 4,
  30912. }
  30913. service.CreateErrMsgLog(errlog)
  30914. c.ServeSuccessJSON(map[string]interface{}{
  30915. "failed_code": -10,
  30916. "msg": res.ErrMsg,
  30917. })
  30918. return
  30919. }
  30920. if res.Infcode == 0 {
  30921. order := &models.HisOrder{
  30922. UserOrgId: adminUser.CurrentOrgId,
  30923. HisPatientId: his.ID,
  30924. PatientId: his.PatientId,
  30925. SettleAccountsDate: recordDateTime,
  30926. Ctime: time.Now().Unix(),
  30927. Mtime: time.Now().Unix(),
  30928. MdtrtId: his.Number,
  30929. PsnNo: his.PsnNo,
  30930. MedType: strconv.FormatInt(reg_type, 10),
  30931. Status: 1,
  30932. Number: chrg_bchno,
  30933. Infcode: res.Infcode,
  30934. WarnMsg: res.WarnMsg,
  30935. Cainfo: res.Cainfo,
  30936. ErrMsg: res.ErrMsg,
  30937. RespondTime: res.RefmsgTime,
  30938. InfRefmsgid: res.InfRefmsgid,
  30939. OrderStatus: 1,
  30940. IsMedicineInsurance: 1,
  30941. SettleType: settle_accounts_type,
  30942. SettleStartTime: start_time,
  30943. SettleEndTime: end_time,
  30944. Creator: roles.AdminUserId,
  30945. Modify: roles.AdminUserId,
  30946. PType: 2,
  30947. Diagnosis: diagnosis_id,
  30948. }
  30949. err = service.CreateOrder(order)
  30950. if err != nil {
  30951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30952. return
  30953. }
  30954. for _, item := range res.Output.Result {
  30955. temp := strings.Split(item.FeedetlSn, "-")
  30956. var advice_id int64 = 0
  30957. var project_id int64 = 0
  30958. var types int64 = 0
  30959. id, _ := strconv.ParseInt(temp[2], 10, 64)
  30960. types, _ = strconv.ParseInt(temp[1], 10, 64)
  30961. if temp[1] == "1" {
  30962. advice_id = id
  30963. project_id = 0
  30964. } else if temp[1] == "2" {
  30965. advice_id = 0
  30966. project_id = id
  30967. }
  30968. total_two = total_two + item.DetItemFeeSumamt
  30969. info := &models.HisOrderInfo{
  30970. OrderNumber: order.Number,
  30971. FeedetlSn: item.FeedetlSn,
  30972. UploadDate: time.Now().Unix(),
  30973. AdviceId: advice_id,
  30974. DetItemFeeSumamt: item.DetItemFeeSumamt,
  30975. Cnt: item.Cnt,
  30976. Pric: float64(item.Pric),
  30977. PatientId: his.PatientId,
  30978. PricUplmtAmt: item.PricUplmtAmt,
  30979. SelfpayProp: item.SelfpayProp,
  30980. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  30981. OverlmtAmt: item.OverlmtAmt,
  30982. PreselfpayAmt: item.PreselfpayAmt,
  30983. BasMednFlag: item.BasMednFlag,
  30984. MedChrgitmType: item.MedChrgitmType,
  30985. HiNegoDrugFlag: item.HiNegoDrugFlag,
  30986. Status: 1,
  30987. Memo: item.Memo,
  30988. Mtime: time.Now().Unix(),
  30989. InscpScpAmt: item.InscpScpAmt,
  30990. DrtReimFlag: item.DrtReimFlag,
  30991. Ctime: time.Now().Unix(),
  30992. ListSpItemFlag: item.ListSpItemFlag,
  30993. ChldMedcFlag: item.ChldMedcFlag,
  30994. LmtUsedFlag: item.LmtUsedFlag,
  30995. ChrgitmLv: item.ChrgitmLv,
  30996. UserOrgId: adminUser.CurrentOrgId,
  30997. HisPatientId: his.ID,
  30998. OrderId: order.ID,
  30999. ProjectId: project_id,
  31000. Type: types,
  31001. }
  31002. service.CreateOrderInfo(info)
  31003. }
  31004. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  31005. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  31006. var total float64
  31007. for _, item := range prescriptions {
  31008. if item.Type == 1 { //药品
  31009. for _, subItem := range item.HisDoctorAdviceInfo {
  31010. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  31011. total_one := price * subItem.PrescribingNumber
  31012. fmt.Println("subItem")
  31013. fmt.Println(subItem.Price)
  31014. fmt.Println("price")
  31015. fmt.Println(price)
  31016. fmt.Println("total_one")
  31017. fmt.Println(total_one)
  31018. total = total + total_one
  31019. fmt.Println(total)
  31020. }
  31021. }
  31022. if item.Type == 2 { //项目
  31023. for _, subItem := range item.HisPrescriptionProject {
  31024. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  31025. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  31026. total_one := price * cnt
  31027. total = total + total_one
  31028. }
  31029. }
  31030. }
  31031. allTotal := fmt.Sprintf("%.2f", total)
  31032. if res.Infcode == 0 {
  31033. var rf []*ResultFive
  31034. json.Unmarshal([]byte(his.Iinfo), &rf)
  31035. chrg_bchno := chrg_bchno
  31036. cert_no := his.Certno
  31037. var insutypes []string
  31038. var insutype string
  31039. var is390 int = 0
  31040. var is310 int = 0
  31041. for _, item := range rf {
  31042. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  31043. insutypes = append(insutypes, item.Insutype)
  31044. }
  31045. }
  31046. if len(insutypes) == 1 {
  31047. insutype = insutypes[0]
  31048. } else {
  31049. for _, i := range insutypes {
  31050. if i == "390" {
  31051. is390 = 1
  31052. }
  31053. if i == "310" {
  31054. is310 = 1
  31055. }
  31056. }
  31057. }
  31058. if is390 == 1 {
  31059. insutype = "390"
  31060. }
  31061. if is310 == 1 {
  31062. insutype = "310"
  31063. }
  31064. if len(insutypes) == 0 {
  31065. insutype = "390"
  31066. }
  31067. if len(insutypes) == 2 {
  31068. insutype = strconv.FormatInt(his.SocialType, 10)
  31069. }
  31070. //insutype = "390"
  31071. if his.IdCardType == 1 {
  31072. cert_no = his.MedicalInsuranceNumber
  31073. } else {
  31074. cert_no = his.Certno
  31075. }
  31076. var res ResultSeven
  31077. var ahres ResultSevenAH
  31078. var resSeven10265 ResultSeven10265
  31079. var resSeven10265Two ResultSeven10265Two
  31080. var gzresSeven10265Two GZResultSeven10265Two
  31081. if miConfig.MdtrtareaAdmvs == "421300" {
  31082. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  31083. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31084. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31085. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31086. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31087. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31088. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31089. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31090. resp, requestErr := http.Get(api)
  31091. if requestErr != nil {
  31092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31093. return
  31094. }
  31095. body, ioErr := ioutil.ReadAll(resp.Body)
  31096. if ioErr != nil {
  31097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31099. return
  31100. }
  31101. var respJSON map[string]interface{}
  31102. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31105. return
  31106. }
  31107. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31108. result, _ := json.Marshal(respJSON)
  31109. fmt.Println("log")
  31110. fmt.Println(string(result))
  31111. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31112. utils.ErrorLog("解析失败:%v", err)
  31113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31114. return
  31115. }
  31116. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31117. if reg_type == 11 && his.Insutype == "390" {
  31118. reg_type = 110104
  31119. }
  31120. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31121. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31122. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31123. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31124. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31125. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31126. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31127. resp, requestErr := http.Get(api)
  31128. if requestErr != nil {
  31129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31130. return
  31131. }
  31132. body, ioErr := ioutil.ReadAll(resp.Body)
  31133. if ioErr != nil {
  31134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31136. return
  31137. }
  31138. var respJSON map[string]interface{}
  31139. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31142. return
  31143. }
  31144. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31145. result, _ := json.Marshal(respJSON)
  31146. fmt.Println("log")
  31147. fmt.Println(string(result))
  31148. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31149. utils.ErrorLog("解析失败:%v", err)
  31150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31151. return
  31152. }
  31153. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31154. if reg_type == 11 && his.Insutype == "390" {
  31155. reg_type = 110104
  31156. }
  31157. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31158. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31159. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31160. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31161. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31162. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31163. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31164. resp, requestErr := http.Get(api)
  31165. if requestErr != nil {
  31166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31167. return
  31168. }
  31169. body, ioErr := ioutil.ReadAll(resp.Body)
  31170. if ioErr != nil {
  31171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31173. return
  31174. }
  31175. var respJSON map[string]interface{}
  31176. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31179. return
  31180. }
  31181. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31182. result, _ := json.Marshal(respJSON)
  31183. fmt.Println("log")
  31184. fmt.Println(string(result))
  31185. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31186. utils.ErrorLog("解析失败:%v", err)
  31187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31188. return
  31189. }
  31190. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31191. if reg_type == 11 && his.Insutype == "390" {
  31192. reg_type = 110104
  31193. }
  31194. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31195. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31196. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31197. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31198. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31199. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31200. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31201. resp, requestErr := http.Get(api)
  31202. if requestErr != nil {
  31203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31204. return
  31205. }
  31206. body, ioErr := ioutil.ReadAll(resp.Body)
  31207. if ioErr != nil {
  31208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31210. return
  31211. }
  31212. var respJSON map[string]interface{}
  31213. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31216. return
  31217. }
  31218. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31219. result, _ := json.Marshal(respJSON)
  31220. fmt.Println("log")
  31221. fmt.Println(string(result))
  31222. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31223. utils.ErrorLog("解析失败:%v", err)
  31224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31225. return
  31226. }
  31227. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  31228. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31229. var result3101 Result3101
  31230. //utils.ErrorLog("解析失败:%v", result3101)
  31231. result3101.Infcode = "0"
  31232. if result3101.Infcode == "0" {
  31233. if len(result3101.Output.Result) > 0 {
  31234. var errMsgs []string
  31235. for _, item := range result3101.Output.Result {
  31236. errMsgs = append(errMsgs, item.VolaCont)
  31237. }
  31238. c.ServeSuccessJSON(map[string]interface{}{
  31239. "failed_code": -10,
  31240. "msg": errMsgs,
  31241. })
  31242. return
  31243. } else {
  31244. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31245. if his.IdCardType != 4 {
  31246. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31247. bas := strings.Split(psn_info.CardInfo, "|")
  31248. if his.IdCardType == 1 {
  31249. cert_no = bas[2]
  31250. } else {
  31251. cert_no = bas[1]
  31252. }
  31253. } else {
  31254. cert_no = his.Certno
  31255. }
  31256. //江苏地区国家医保医疗类别
  31257. //职工透析:医疗类别选特殊情况门诊9933
  31258. //居民血透门慢: 医疗类别选门诊慢病1402
  31259. //var med_type string
  31260. //if his.Insutype == "310" {
  31261. // if reg_type == 14 {
  31262. // med_type = "9933"
  31263. // } else if reg_type == 11 {
  31264. // med_type = "11"
  31265. //
  31266. // }
  31267. //} else if his.Insutype == "390" {
  31268. // if reg_type == 14 {
  31269. // med_type = "1402"
  31270. // } else if reg_type == 11 {
  31271. // med_type = "11"
  31272. // }
  31273. //}
  31274. var api string
  31275. if miConfig.MdtrtareaAdmvs == "320830" {
  31276. api = miConfig.AppSecret + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31277. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31278. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31279. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31280. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31281. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31282. "&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
  31283. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31284. } else if miConfig.MdtrtareaAdmvs == "320921" {
  31285. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31286. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31287. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31288. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31289. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31290. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31291. "&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
  31292. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31293. } else {
  31294. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31295. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31296. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31297. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31298. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31299. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31300. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31301. "&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
  31302. }
  31303. resp, requestErr := http.Get(api)
  31304. if requestErr != nil {
  31305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31306. return
  31307. }
  31308. body, ioErr := ioutil.ReadAll(resp.Body)
  31309. if ioErr != nil {
  31310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31312. return
  31313. }
  31314. var respJSON map[string]interface{}
  31315. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31318. return
  31319. }
  31320. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31321. result, _ := json.Marshal(respJSON)
  31322. fmt.Println("log")
  31323. fmt.Println(string(result))
  31324. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  31325. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31326. utils.ErrorLog("解析失败:%v", err)
  31327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31328. return
  31329. }
  31330. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31331. res.Output = resSeven10265.Output
  31332. res.ErrMsg = resSeven10265.ErrMsg
  31333. res.Cainfo = resSeven10265.Cainfo
  31334. res.WarnMsg = resSeven10265.WarnMsg
  31335. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31336. res.Infcode = infocode
  31337. } else {
  31338. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31339. utils.ErrorLog("解析失败:%v", err)
  31340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31341. return
  31342. }
  31343. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31344. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31345. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31346. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31347. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31348. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31349. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31350. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31351. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31352. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31353. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31354. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31355. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31356. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31357. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31358. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31359. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31360. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31361. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31362. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31363. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31364. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31365. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31366. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31367. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31368. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31369. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31370. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31371. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31372. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31373. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31374. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31375. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31376. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31377. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31378. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31379. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31380. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31381. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31382. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31383. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31384. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31385. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31386. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31387. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31388. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31389. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31390. res.ErrMsg = resSeven10265Two.ErrMsg
  31391. res.Cainfo = resSeven10265Two.Cainfo
  31392. res.WarnMsg = resSeven10265Two.WarnMsg
  31393. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31394. res.Infcode = infocode
  31395. }
  31396. }
  31397. }
  31398. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31399. psn_info, _ := service.GetPsnByPatientId(id)
  31400. var verify_number string
  31401. if psn_info.IdCardType == 4 {
  31402. verify_number = psn_info.VerifyNumber
  31403. } else if psn_info.IdCardType == 1 {
  31404. bas := strings.Split(psn_info.CardInfo, "|")
  31405. cardNumber := bas[2]
  31406. verify_number = cardNumber
  31407. } else {
  31408. psn_info.IdCardType = 2
  31409. verify_number = psn_info.Certno
  31410. }
  31411. var api string
  31412. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31413. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  31414. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31415. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31416. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  31417. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31418. "&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
  31419. resp, requestErr := http.Get(api)
  31420. if requestErr != nil {
  31421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31422. return
  31423. }
  31424. body, ioErr := ioutil.ReadAll(resp.Body)
  31425. if ioErr != nil {
  31426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31428. return
  31429. }
  31430. var respJSON map[string]interface{}
  31431. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31434. return
  31435. }
  31436. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31437. result, _ := json.Marshal(respJSON)
  31438. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31439. utils.ErrorLog("解析失败:%v", err)
  31440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31441. return
  31442. }
  31443. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31444. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  31445. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  31446. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31447. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  31448. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  31449. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  31450. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  31451. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  31452. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  31453. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  31454. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  31455. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  31456. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31457. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  31458. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  31459. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  31460. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  31461. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  31462. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  31463. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31464. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  31465. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  31466. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  31467. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  31468. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  31469. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  31470. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  31471. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  31472. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  31473. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  31474. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  31475. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  31476. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  31477. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31478. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  31479. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  31480. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  31481. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  31482. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  31483. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  31484. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  31485. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  31486. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  31487. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  31488. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  31489. res.ErrMsg = resSeven10265.ErrMsg
  31490. res.Cainfo = resSeven10265.Cainfo
  31491. res.WarnMsg = resSeven10265.WarnMsg
  31492. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31493. res.Infcode = infocode
  31494. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31495. acct_used_flag := "1"
  31496. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  31497. var result string
  31498. var request_log string
  31499. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  31500. 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)
  31501. } else {
  31502. 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)
  31503. }
  31504. var dat map[string]interface{}
  31505. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31506. fmt.Println(dat)
  31507. } else {
  31508. fmt.Println(err)
  31509. }
  31510. saveLog(result, request_log, "2206", "预结算")
  31511. userJSONBytes, _ := json.Marshal(dat)
  31512. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31513. utils.ErrorLog("解析失败:%v", err)
  31514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31515. return
  31516. }
  31517. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31518. var result string
  31519. var request_log string
  31520. if his.IdCardType == 2 {
  31521. insutype = strconv.FormatInt(his.SocialType, 10)
  31522. 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, "")
  31523. } else if his.IdCardType == 1 {
  31524. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31525. bas := strings.Split(psn_info.CardInfo, "|")
  31526. basNumber := bas[2]
  31527. card_sn := bas[3]
  31528. var rf []*ResultFive
  31529. json.Unmarshal([]byte(his.Iinfo), &rf)
  31530. var psn_type string
  31531. for _, item := range rf {
  31532. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31533. psn_type = item.PsnType
  31534. }
  31535. }
  31536. insutype = strconv.FormatInt(his.SocialType, 10)
  31537. 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)
  31538. } else {
  31539. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31540. //bas := strings.Split(psn_info.CardInfo, "|")
  31541. //basNumber := bas[2]
  31542. //card_sn := bas[3]
  31543. var rf []*ResultFive
  31544. json.Unmarshal([]byte(his.Iinfo), &rf)
  31545. var psn_type string
  31546. for _, item := range rf {
  31547. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31548. psn_type = item.PsnType
  31549. }
  31550. }
  31551. insutype = strconv.FormatInt(his.SocialType, 10)
  31552. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31553. 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)
  31554. }
  31555. var dat map[string]interface{}
  31556. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31557. fmt.Println(dat)
  31558. } else {
  31559. fmt.Println(err)
  31560. }
  31561. saveLog(result, request_log, "2206", "预结算")
  31562. userJSONBytes, _ := json.Marshal(dat)
  31563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31564. utils.ErrorLog("解析失败:%v", err)
  31565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31566. return
  31567. }
  31568. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31569. var result string
  31570. var request_log string
  31571. if his.IdCardType == 2 {
  31572. insutype = strconv.FormatInt(his.SocialType, 10)
  31573. 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, "")
  31574. } else if his.IdCardType == 1 {
  31575. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31576. bas := strings.Split(psn_info.CardInfo, "|")
  31577. basNumber := bas[0]
  31578. card_sn := ""
  31579. var rf []*ResultFive
  31580. json.Unmarshal([]byte(his.Iinfo), &rf)
  31581. var psn_type string
  31582. for _, item := range rf {
  31583. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31584. psn_type = item.PsnType
  31585. }
  31586. }
  31587. insutype = strconv.FormatInt(his.SocialType, 10)
  31588. 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)
  31589. } else {
  31590. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31591. //bas := strings.Split(psn_info.CardInfo, "|")
  31592. //basNumber := bas[2]
  31593. //card_sn := bas[3]
  31594. var rf []*ResultFive
  31595. json.Unmarshal([]byte(his.Iinfo), &rf)
  31596. var psn_type string
  31597. for _, item := range rf {
  31598. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31599. psn_type = item.PsnType
  31600. }
  31601. }
  31602. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31603. 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)
  31604. }
  31605. var dat map[string]interface{}
  31606. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31607. fmt.Println(dat)
  31608. } else {
  31609. fmt.Println(err)
  31610. }
  31611. saveLog(result, request_log, "2206", "预结算")
  31612. userJSONBytes, _ := json.Marshal(dat)
  31613. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31614. utils.ErrorLog("解析失败:%v", err)
  31615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31616. return
  31617. }
  31618. } else if miConfig.MdtrtareaAdmvs == "360100" {
  31619. var result string
  31620. var request_log string
  31621. if his.IdCardType == 2 {
  31622. insutype = strconv.FormatInt(his.SocialType, 10)
  31623. 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, "")
  31624. } else if his.IdCardType == 1 {
  31625. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31626. bas := strings.Split(psn_info.CardInfo, "|")
  31627. basNumber := bas[0]
  31628. card_sn := ""
  31629. var rf []*ResultFive
  31630. json.Unmarshal([]byte(his.Iinfo), &rf)
  31631. var psn_type string
  31632. for _, item := range rf {
  31633. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31634. psn_type = item.PsnType
  31635. }
  31636. }
  31637. insutype = strconv.FormatInt(his.SocialType, 10)
  31638. 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)
  31639. } else {
  31640. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31641. //bas := strings.Split(psn_info.CardInfo, "|")
  31642. //basNumber := bas[2]
  31643. //card_sn := bas[3]
  31644. var rf []*ResultFive
  31645. json.Unmarshal([]byte(his.Iinfo), &rf)
  31646. var psn_type string
  31647. for _, item := range rf {
  31648. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31649. psn_type = item.PsnType
  31650. }
  31651. }
  31652. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31653. 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)
  31654. }
  31655. var dat map[string]interface{}
  31656. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31657. fmt.Println(dat)
  31658. } else {
  31659. fmt.Println(err)
  31660. }
  31661. saveLog(result, request_log, "2206", "预结算")
  31662. userJSONBytes, _ := json.Marshal(dat)
  31663. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31664. utils.ErrorLog("解析失败:%v", err)
  31665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31666. return
  31667. }
  31668. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31669. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31670. if his.IdCardType == 4 {
  31671. psn_info.VerifyNumber = psn_info.VerifyNumber
  31672. cert_no = psn_info.VerifyNumber
  31673. } else if his.IdCardType == 2 {
  31674. cert_no = psn_info.Certno
  31675. psn_info.VerifyNumber = psn_info.Certno
  31676. } else {
  31677. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31678. bas := strings.Split(psn_info.CardInfo, "|")
  31679. if his.IdCardType == 1 {
  31680. cert_no = bas[2]
  31681. } else {
  31682. cert_no = bas[1]
  31683. }
  31684. }
  31685. var api string
  31686. var med_type string
  31687. if his.Insutype == "390" {
  31688. if reg_type == 992102 {
  31689. med_type = "992102"
  31690. }
  31691. if reg_type == 140104 {
  31692. med_type = "140104"
  31693. }
  31694. if reg_type == 140201 {
  31695. med_type = "140201"
  31696. }
  31697. if reg_type == 14 {
  31698. med_type = "140104"
  31699. }
  31700. if reg_type == 1104 {
  31701. med_type = "1104"
  31702. }
  31703. } else if his.Insutype == "310" {
  31704. if reg_type == 1104 {
  31705. med_type = "1104"
  31706. }
  31707. if reg_type == 992102 {
  31708. med_type = "992102"
  31709. }
  31710. if reg_type == 140104 {
  31711. med_type = "140104"
  31712. }
  31713. if reg_type == 140201 {
  31714. med_type = "140201"
  31715. }
  31716. if reg_type == 14 {
  31717. med_type = "140104"
  31718. }
  31719. }
  31720. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31721. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31722. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31723. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31724. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31725. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31726. "&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
  31727. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31728. resp, requestErr := http.Get(api)
  31729. if requestErr != nil {
  31730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31731. return
  31732. }
  31733. body, ioErr := ioutil.ReadAll(resp.Body)
  31734. if ioErr != nil {
  31735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31737. return
  31738. }
  31739. var respJSON map[string]interface{}
  31740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31743. return
  31744. }
  31745. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31746. if status == "0" {
  31747. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31748. c.ServeSuccessJSON(map[string]interface{}{
  31749. "failed_code": -10,
  31750. "msg": err_msg,
  31751. })
  31752. return
  31753. }
  31754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31755. result, _ := json.Marshal(respJSON)
  31756. fmt.Println("log")
  31757. fmt.Println(string(result))
  31758. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  31759. utils.ErrorLog("解析失败:%v", err)
  31760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31761. return
  31762. }
  31763. res.InfRefmsgid = ahres.InfRefmsgid
  31764. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31765. // 创建对应的Time类型
  31766. t := time.UnixMilli(timestamp)
  31767. // 格式化成指定的日期字符串
  31768. str := t.Format("2006-01-02 15:04:05")
  31769. res.Output.Setlinfo.SetlTime = str
  31770. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31771. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31772. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31773. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31774. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31775. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31776. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31777. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31778. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31779. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31780. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31781. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31782. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31783. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31784. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31785. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31786. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31787. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31788. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31789. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31790. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31791. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31792. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31793. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31794. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31795. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31796. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31797. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31798. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31799. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31800. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31801. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31802. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31803. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  31804. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31805. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  31806. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  31807. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  31808. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  31809. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31810. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  31811. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31812. //res.Output.Setldetail = ahres.Output.Setldetail
  31813. res.ErrMsg = ahres.ErrMsg
  31814. res.Cainfo = ahres.Cainfo
  31815. res.WarnMsg = ahres.WarnMsg
  31816. res.Infcode = ahres.Infcode
  31817. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31818. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31819. if his.IdCardType == 4 {
  31820. psn_info.VerifyNumber = psn_info.VerifyNumber
  31821. cert_no = psn_info.Certno
  31822. } else if his.IdCardType == 2 {
  31823. cert_no = psn_info.Certno
  31824. psn_info.VerifyNumber = psn_info.Certno
  31825. } else {
  31826. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31827. bas := strings.Split(psn_info.CardInfo, "|")
  31828. if his.IdCardType == 1 {
  31829. cert_no = bas[2]
  31830. } else {
  31831. cert_no = bas[1]
  31832. }
  31833. }
  31834. var api string
  31835. var med_type string
  31836. if his.Insutype == "390" {
  31837. if reg_type == 992102 {
  31838. med_type = "992102"
  31839. }
  31840. if reg_type == 140104 {
  31841. med_type = "140104"
  31842. }
  31843. if reg_type == 140201 {
  31844. med_type = "140201"
  31845. }
  31846. if reg_type == 14 {
  31847. med_type = "14"
  31848. }
  31849. } else if his.Insutype == "310" {
  31850. if reg_type == 992102 {
  31851. med_type = "992102"
  31852. }
  31853. if reg_type == 140104 {
  31854. med_type = "140104"
  31855. }
  31856. if reg_type == 140201 {
  31857. med_type = "140201"
  31858. }
  31859. if reg_type == 14 {
  31860. med_type = "14"
  31861. }
  31862. }
  31863. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31864. his.Number + "&chrg_bchno=" + 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(his.IdCardType, 10) +
  31868. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31869. "&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
  31870. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31871. resp, requestErr := http.Get(api)
  31872. if requestErr != nil {
  31873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31874. return
  31875. }
  31876. body, ioErr := ioutil.ReadAll(resp.Body)
  31877. if ioErr != nil {
  31878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31880. return
  31881. }
  31882. var respJSON map[string]interface{}
  31883. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31886. return
  31887. }
  31888. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31889. if status == "0" {
  31890. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31891. c.ServeSuccessJSON(map[string]interface{}{
  31892. "failed_code": -10,
  31893. "msg": err_msg,
  31894. })
  31895. return
  31896. }
  31897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31898. result, _ := json.Marshal(respJSON)
  31899. fmt.Println("log")
  31900. fmt.Println(string(result))
  31901. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  31902. utils.ErrorLog("解析失败:%v", err)
  31903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31904. return
  31905. }
  31906. res.InfRefmsgid = ahres.InfRefmsgid
  31907. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31908. // 创建对应的Time类型
  31909. t := time.UnixMilli(timestamp)
  31910. // 格式化成指定的日期字符串
  31911. str := t.Format("2006-01-02 15:04:05")
  31912. res.Output.Setlinfo.SetlTime = str
  31913. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31914. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31915. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31916. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31917. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31918. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31919. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31920. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31921. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31922. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31923. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31924. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31925. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31926. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31927. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31928. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31929. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31930. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31931. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31932. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31933. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31934. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31935. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31936. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31937. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31938. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31939. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31940. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31941. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31942. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31943. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31944. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31945. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31946. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  31947. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31948. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  31949. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  31950. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  31951. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  31952. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31953. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  31954. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31955. //res.Output.Setldetail = ahres.Output.Setldetail
  31956. res.ErrMsg = ahres.ErrMsg
  31957. res.Cainfo = ahres.Cainfo
  31958. res.WarnMsg = ahres.WarnMsg
  31959. res.Infcode = ahres.Infcode
  31960. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31961. var result string
  31962. var request_log string
  31963. if his.IdCardType == 2 {
  31964. 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")
  31965. } else if his.IdCardType == 1 {
  31966. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31967. bas := strings.Split(psn_info.CardInfo, "|")
  31968. basNumber := bas[2]
  31969. card_sn := bas[3]
  31970. 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")
  31971. } else {
  31972. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31973. 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")
  31974. }
  31975. var dat map[string]interface{}
  31976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31977. fmt.Println(dat)
  31978. } else {
  31979. fmt.Println(err)
  31980. }
  31981. saveLog(result, request_log, "2206", "预结算")
  31982. userJSONBytes, _ := json.Marshal(dat)
  31983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31984. utils.ErrorLog("解析失败:%v", err)
  31985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31986. return
  31987. }
  31988. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31989. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31990. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31991. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31992. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31993. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31994. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31995. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31996. resp, requestErr := http.Get(api)
  31997. if requestErr != nil {
  31998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31999. return
  32000. }
  32001. body, ioErr := ioutil.ReadAll(resp.Body)
  32002. if ioErr != nil {
  32003. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32005. return
  32006. }
  32007. var respJSON map[string]interface{}
  32008. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32011. return
  32012. }
  32013. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32014. result, _ := json.Marshal(respJSON)
  32015. fmt.Println("log")
  32016. fmt.Println(string(result))
  32017. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32018. utils.ErrorLog("解析失败:%v", err)
  32019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32020. return
  32021. }
  32022. } else {
  32023. if miConfig.MdtrtareaAdmvs == "441202" {
  32024. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32025. if result3101.Infcode == 0 {
  32026. if len(result3101.Output.Result) > 0 {
  32027. c.ServeSuccessJSON(map[string]interface{}{
  32028. "failed_code": -10,
  32029. "failed_type": 100,
  32030. "msg": result3101.Output.Result,
  32031. })
  32032. return
  32033. } else {
  32034. var result string
  32035. var request_log string
  32036. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32037. allTotal = fmt.Sprintf("%.2f", total_two)
  32038. if his.IdCardType == 4 {
  32039. 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)
  32040. } else {
  32041. 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)
  32042. }
  32043. var dat map[string]interface{}
  32044. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32045. fmt.Println(dat)
  32046. } else {
  32047. fmt.Println(err)
  32048. }
  32049. saveLog(result, request_log, "2206", "预结算")
  32050. //userJSONBytes, _ := json.Marshal(dat)
  32051. //
  32052. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32053. // utils.ErrorLog("解析失败:%v", err)
  32054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32055. // return
  32056. //}
  32057. userJSONBytes, _ := json.Marshal(dat)
  32058. if miConfig.Code == "H15049901371" {
  32059. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32060. utils.ErrorLog("解析失败:%v", err)
  32061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32062. return
  32063. }
  32064. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32065. res.Output = resSeven10265.Output
  32066. res.ErrMsg = resSeven10265.ErrMsg
  32067. res.Cainfo = resSeven10265.Cainfo
  32068. res.WarnMsg = resSeven10265.WarnMsg
  32069. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32070. res.Infcode = infocode
  32071. } else {
  32072. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32073. utils.ErrorLog("解析失败:%v", err)
  32074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32075. return
  32076. }
  32077. }
  32078. }
  32079. } else {
  32080. c.ServeSuccessJSON(map[string]interface{}{
  32081. "failed_code": -10,
  32082. "msg": result3101.ErrMsg,
  32083. })
  32084. return
  32085. }
  32086. } else if miConfig.MdtrtareaAdmvs == "440205" {
  32087. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32088. if result3101.Infcode == 0 {
  32089. if len(result3101.Output.Result) > 0 {
  32090. var errMsgs []string
  32091. for _, item := range result3101.Output.Result {
  32092. errMsgs = append(errMsgs, item.VolaCont)
  32093. }
  32094. c.ServeSuccessJSON(map[string]interface{}{
  32095. "failed_code": -10,
  32096. "msg": errMsgs,
  32097. })
  32098. return
  32099. } else {
  32100. var result string
  32101. var request_log string
  32102. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32103. allTotal = fmt.Sprintf("%.2f", total_two)
  32104. if his.IdCardType == 4 {
  32105. 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)
  32106. } else {
  32107. 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)
  32108. }
  32109. var dat map[string]interface{}
  32110. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32111. fmt.Println(dat)
  32112. } else {
  32113. fmt.Println(err)
  32114. }
  32115. saveLog(result, request_log, "2206", "预结算")
  32116. //userJSONBytes, _ := json.Marshal(dat)
  32117. //
  32118. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32119. // utils.ErrorLog("解析失败:%v", err)
  32120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32121. // return
  32122. //}
  32123. userJSONBytes, _ := json.Marshal(dat)
  32124. if miConfig.Code == "H15049901371" {
  32125. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32126. utils.ErrorLog("解析失败:%v", err)
  32127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32128. return
  32129. }
  32130. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32131. res.Output = resSeven10265.Output
  32132. res.ErrMsg = resSeven10265.ErrMsg
  32133. res.Cainfo = resSeven10265.Cainfo
  32134. res.WarnMsg = resSeven10265.WarnMsg
  32135. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32136. res.Infcode = infocode
  32137. } else {
  32138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32139. utils.ErrorLog("解析失败:%v", err)
  32140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32141. return
  32142. }
  32143. }
  32144. }
  32145. } else {
  32146. c.ServeSuccessJSON(map[string]interface{}{
  32147. "failed_code": -10,
  32148. "msg": result3101.ErrMsg,
  32149. })
  32150. return
  32151. }
  32152. } else {
  32153. var result string
  32154. var request_log string
  32155. var dat map[string]interface{}
  32156. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32157. allTotal = fmt.Sprintf("%.2f", total_two)
  32158. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  32159. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32160. if result3101.Infcode == 0 {
  32161. if len(result3101.Output.Result) > 0 {
  32162. c.ServeSuccessJSON(map[string]interface{}{
  32163. "failed_code": -10,
  32164. "failed_type": 100,
  32165. "warm_type": 2,
  32166. "msg": result3101,
  32167. })
  32168. return
  32169. } else {
  32170. var result string
  32171. var request_log string
  32172. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32173. allTotal = fmt.Sprintf("%.2f", total_two)
  32174. if his.IdCardType == 4 {
  32175. 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)
  32176. } else {
  32177. if his.IdCardType == 2 {
  32178. cert_no = psn_info.Certno
  32179. psn_info.VerifyNumber = psn_info.Certno
  32180. } else {
  32181. bas := strings.Split(psn_info.CardInfo, "|")
  32182. cert_no = bas[2]
  32183. }
  32184. 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)
  32185. }
  32186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32187. fmt.Println(dat)
  32188. } else {
  32189. fmt.Println(err)
  32190. }
  32191. saveLog(result, request_log, "2206", "预结算")
  32192. }
  32193. } else {
  32194. c.ServeSuccessJSON(map[string]interface{}{
  32195. "failed_code": -10,
  32196. "msg": result3101.ErrMsg,
  32197. })
  32198. return
  32199. }
  32200. } else {
  32201. if his.IdCardType == 4 {
  32202. 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)
  32203. } else {
  32204. if his.IdCardType == 2 {
  32205. cert_no = psn_info.Certno
  32206. psn_info.VerifyNumber = psn_info.Certno
  32207. } else {
  32208. bas := strings.Split(psn_info.CardInfo, "|")
  32209. cert_no = bas[2]
  32210. }
  32211. 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)
  32212. }
  32213. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32214. fmt.Println(dat)
  32215. } else {
  32216. fmt.Println(err)
  32217. }
  32218. saveLog(result, request_log, "2206", "预结算")
  32219. }
  32220. //userJSONBytes, _ := json.Marshal(dat)
  32221. //
  32222. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32223. // utils.ErrorLog("解析失败:%v", err)
  32224. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32225. // return
  32226. //}
  32227. userJSONBytes, _ := json.Marshal(dat)
  32228. if miConfig.Code == "H15049901371" {
  32229. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32230. utils.ErrorLog("解析失败:%v", err)
  32231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32232. return
  32233. }
  32234. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32235. res.Output = resSeven10265.Output
  32236. res.ErrMsg = resSeven10265.ErrMsg
  32237. res.Cainfo = resSeven10265.Cainfo
  32238. res.WarnMsg = resSeven10265.WarnMsg
  32239. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32240. res.Infcode = infocode
  32241. } else {
  32242. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32243. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  32244. utils.ErrorLog("解析失败:%v", err)
  32245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32246. return
  32247. }
  32248. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  32249. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  32250. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  32251. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32252. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  32253. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  32254. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  32255. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32256. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  32257. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32258. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32259. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32260. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32261. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32262. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  32263. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  32264. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  32265. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  32266. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  32267. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  32268. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32269. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  32270. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  32271. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  32272. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  32273. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  32274. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  32275. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  32276. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  32277. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  32278. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  32279. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  32280. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  32281. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  32282. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32283. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  32284. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  32285. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  32286. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32287. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  32288. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  32289. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  32290. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  32291. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  32292. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  32293. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  32294. res.ErrMsg = gzresSeven10265Two.ErrMsg
  32295. res.Cainfo = gzresSeven10265Two.Cainfo
  32296. res.WarnMsg = gzresSeven10265Two.WarnMsg
  32297. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  32298. //res.Infcode = infocode
  32299. } else {
  32300. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32301. utils.ErrorLog("解析失败:%v", err)
  32302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32303. return
  32304. }
  32305. }
  32306. }
  32307. }
  32308. }
  32309. utils.ErrorLog("解析失败:%v", res.Infcode)
  32310. if res.Infcode == -1 {
  32311. errlog := &models.HisOrderError{
  32312. UserOrgId: adminUser.CurrentOrgId,
  32313. Ctime: time.Now().Unix(),
  32314. Mtime: time.Now().Unix(),
  32315. Number: chrg_bchno,
  32316. ErrMsg: res.ErrMsg,
  32317. Status: 1,
  32318. PatientId: id,
  32319. RecordTime: recordDateTime,
  32320. Stage: 20,
  32321. }
  32322. service.CreateErrMsgLog(errlog)
  32323. c.ServeSuccessJSON(map[string]interface{}{
  32324. "failed_code": -10,
  32325. "msg": res.ErrMsg,
  32326. })
  32327. return
  32328. }
  32329. if res.Infcode != 0 {
  32330. errlog := &models.HisOrderError{
  32331. UserOrgId: adminUser.CurrentOrgId,
  32332. Ctime: time.Now().Unix(),
  32333. Mtime: time.Now().Unix(),
  32334. Number: chrg_bchno,
  32335. ErrMsg: res.ErrMsg,
  32336. Status: 1,
  32337. PatientId: id,
  32338. RecordTime: recordDateTime,
  32339. Stage: 20,
  32340. }
  32341. service.CreateErrMsgLog(errlog)
  32342. c.ServeSuccessJSON(map[string]interface{}{
  32343. "failed_code": -10,
  32344. "msg": res.ErrMsg,
  32345. })
  32346. return
  32347. } else {
  32348. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32349. order.OrderStatus = 1
  32350. order.IsPre = 1
  32351. order.Status = 1
  32352. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  32353. order.SetlId = res.Output.Setlinfo.SetlID
  32354. order.PsnNo = res.Output.Setlinfo.PsnNo
  32355. order.PsnName = res.Output.Setlinfo.PsnName
  32356. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  32357. order.Certno = res.Output.Setlinfo.Certno
  32358. order.Gend = res.Output.Setlinfo.Gend
  32359. order.Naty = res.Output.Setlinfo.Naty
  32360. order.Age = res.Output.Setlinfo.Age
  32361. order.Insutype = res.Output.Setlinfo.Insutype
  32362. order.PsnType = res.Output.Setlinfo.PsnType
  32363. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  32364. order.SetlTime = res.Output.Setlinfo.SetlTime
  32365. order.AcctUsedFlag = acct_used_flag
  32366. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  32367. if res.Output.Setlinfo.MedType == "140101" {
  32368. order.MedType = "14"
  32369. } else {
  32370. if res.Output.Setlinfo.MedType == "110104" {
  32371. order.MedType = "11"
  32372. } else {
  32373. order.MedType = res.Output.Setlinfo.MedType
  32374. }
  32375. }
  32376. if res.Output.Setlinfo.MedType == "992102" {
  32377. order.MedType = "992102"
  32378. }
  32379. if res.Output.Setlinfo.MedType == "140104" {
  32380. order.MedType = "140104"
  32381. }
  32382. if res.Output.Setlinfo.MedType == "1104" {
  32383. order.MedType = "1104"
  32384. }
  32385. if res.Output.Setlinfo.MedType == "140201" {
  32386. order.MedType = "140201"
  32387. }
  32388. if res.Output.Setlinfo.MedType == "14" {
  32389. order.MedType = "14"
  32390. }
  32391. if reg_type == 1112 {
  32392. order.MedType = "1112"
  32393. }
  32394. if reg_type == 1111 {
  32395. order.MedType = "1111"
  32396. }
  32397. order.ClrType = res.Output.Setlinfo.ClrType
  32398. if adminUser.CurrentOrgId == 10480 {
  32399. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32400. order.ClrType = "11"
  32401. } else {
  32402. order.ClrType = "9903"
  32403. }
  32404. }
  32405. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  32406. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  32407. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  32408. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  32409. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  32410. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  32411. order.HifpPay = res.Output.Setlinfo.HifpPay
  32412. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  32413. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  32414. order.HifesPay = res.Output.Setlinfo.HifesPay
  32415. order.HifobPay = res.Output.Setlinfo.HifobPay
  32416. order.MafPay = res.Output.Setlinfo.MafPay
  32417. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  32418. order.OthPay = res.Output.Setlinfo.OthPay
  32419. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  32420. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  32421. order.AcctPay = res.Output.Setlinfo.AcctPay
  32422. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  32423. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  32424. order.Balc = res.Output.Setlinfo.Balc
  32425. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  32426. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  32427. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  32428. order.ClrWay = res.Output.Setlinfo.ClrWay
  32429. order.Creator = order.Creator
  32430. order.Modify = roles.AdminUserId
  32431. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32432. //detailStr := string(setlDetail)
  32433. //order.SetlDetail = detailStr
  32434. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32435. err = service.UpDateOrder(order)
  32436. if err == nil {
  32437. c.ServeSuccessJSON(map[string]interface{}{
  32438. "msg": "预结算成功",
  32439. })
  32440. } else {
  32441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32442. return
  32443. }
  32444. }
  32445. } else {
  32446. adminUser := c.GetAdminUserInfo()
  32447. errlog := &models.HisOrderError{
  32448. UserOrgId: adminUser.CurrentOrgId,
  32449. Ctime: time.Now().Unix(),
  32450. Mtime: time.Now().Unix(),
  32451. ErrMsg: res.ErrMsg,
  32452. Status: 1,
  32453. PatientId: id,
  32454. RecordTime: recordDateTime,
  32455. Stage: 4,
  32456. }
  32457. service.CreateErrMsgLog(errlog)
  32458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  32459. return
  32460. }
  32461. } else {
  32462. if miConfig.MdtrtareaAdmvs == "150499" {
  32463. order := &models.HisOrder{
  32464. UserOrgId: adminUser.CurrentOrgId,
  32465. HisPatientId: his.ID,
  32466. PatientId: his.PatientId,
  32467. SettleAccountsDate: recordDateTime,
  32468. Ctime: time.Now().Unix(),
  32469. Mtime: time.Now().Unix(),
  32470. MdtrtId: his.Number,
  32471. PsnNo: his.PsnNo,
  32472. MedType: strconv.FormatInt(reg_type, 10),
  32473. Status: 1,
  32474. Number: chrg_bchno,
  32475. Infcode: res.Infcode,
  32476. WarnMsg: res.WarnMsg,
  32477. Cainfo: res.Cainfo,
  32478. ErrMsg: res.ErrMsg,
  32479. RespondTime: res.RefmsgTime,
  32480. InfRefmsgid: res.InfRefmsgid,
  32481. OrderStatus: 1,
  32482. IsMedicineInsurance: 1,
  32483. SettleType: settle_accounts_type,
  32484. SettleStartTime: start_time,
  32485. SettleEndTime: end_time,
  32486. Creator: roles.AdminUserId,
  32487. Modify: roles.AdminUserId,
  32488. PType: 2,
  32489. Diagnosis: diagnosis_id,
  32490. }
  32491. err = service.CreateOrder(order)
  32492. if err != nil {
  32493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  32494. return
  32495. }
  32496. }
  32497. adminUser := c.GetAdminUserInfo()
  32498. errlog := &models.HisOrderError{
  32499. UserOrgId: adminUser.CurrentOrgId,
  32500. Ctime: time.Now().Unix(),
  32501. Mtime: time.Now().Unix(),
  32502. ErrMsg: res.ErrMsg,
  32503. Status: 1,
  32504. PatientId: id,
  32505. RecordTime: recordDateTime,
  32506. Stage: 4,
  32507. }
  32508. service.CreateErrMsgLog(errlog)
  32509. c.ServeSuccessJSON(map[string]interface{}{
  32510. "failed_code": -10,
  32511. "msg": res.ErrMsg,
  32512. })
  32513. return
  32514. }
  32515. }
  32516. }
  32517. }
  32518. // 退款
  32519. func (c *HisApiController) Refund() {
  32520. order_id, _ := c.GetInt64("order_id")
  32521. admin_user_id, _ := c.GetInt64("admin_user_id")
  32522. adminUser := c.GetAdminUserInfo()
  32523. var order models.HisOrder
  32524. order, _ = service.GetHisOrderByID(order_id)
  32525. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  32526. if fapiao.ID > 0 {
  32527. c.ServeSuccessJSON(map[string]interface{}{
  32528. "failed_code": -10,
  32529. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  32530. })
  32531. return
  32532. }
  32533. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32534. if order.ID == 0 {
  32535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32536. return
  32537. }
  32538. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32539. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32540. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32541. if config.IsOpen == 1 { //对接了医保,走医保流程
  32542. var res ResultSixteen
  32543. var ahres ResultSevenAH
  32544. var resSixteen10265 ResultSixteen10265
  32545. var resSixteen10265Two ResultSixteen10265Two
  32546. var gz ResultgzSixteen10265Two
  32547. var src_resquest string
  32548. var result string
  32549. if miConfig.MdtrtareaAdmvs == "421300" {
  32550. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32551. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32552. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32553. resp3, requestErr3 := http.Get(api3)
  32554. if requestErr3 != nil {
  32555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32556. return
  32557. }
  32558. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32559. if ioErr3 != nil {
  32560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32562. return
  32563. }
  32564. var respJSON3 map[string]interface{}
  32565. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32568. return
  32569. }
  32570. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32571. userJSONBytes3, _ := json.Marshal(respJSON3)
  32572. fmt.Println("log")
  32573. fmt.Println(string(userJSONBytes3))
  32574. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32575. utils.ErrorLog("解析失败:%v", err)
  32576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32577. return
  32578. }
  32579. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32580. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32581. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32582. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32583. resp3, requestErr3 := http.Get(api3)
  32584. if requestErr3 != nil {
  32585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32586. return
  32587. }
  32588. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32589. if ioErr3 != nil {
  32590. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32592. return
  32593. }
  32594. var respJSON3 map[string]interface{}
  32595. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32598. return
  32599. }
  32600. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32601. userJSONBytes3, _ := json.Marshal(respJSON3)
  32602. fmt.Println("log")
  32603. fmt.Println(string(userJSONBytes3))
  32604. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32605. utils.ErrorLog("解析失败:%v", err)
  32606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32607. return
  32608. }
  32609. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32610. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32611. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32612. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32613. resp3, requestErr3 := http.Get(api3)
  32614. if requestErr3 != nil {
  32615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32616. return
  32617. }
  32618. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32619. if ioErr3 != nil {
  32620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32622. return
  32623. }
  32624. var respJSON3 map[string]interface{}
  32625. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32628. return
  32629. }
  32630. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32631. userJSONBytes3, _ := json.Marshal(respJSON3)
  32632. fmt.Println("log")
  32633. fmt.Println(string(userJSONBytes3))
  32634. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32635. utils.ErrorLog("解析失败:%v", err)
  32636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32637. return
  32638. }
  32639. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32640. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32641. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32642. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32643. resp3, requestErr3 := http.Get(api3)
  32644. if requestErr3 != nil {
  32645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32646. return
  32647. }
  32648. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32649. if ioErr3 != nil {
  32650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32652. return
  32653. }
  32654. var respJSON3 map[string]interface{}
  32655. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32658. return
  32659. }
  32660. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32661. userJSONBytes3, _ := json.Marshal(respJSON3)
  32662. fmt.Println("log")
  32663. fmt.Println(string(userJSONBytes3))
  32664. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32665. utils.ErrorLog("解析失败:%v", err)
  32666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32667. return
  32668. }
  32669. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  32670. var api3 string
  32671. if miConfig.MdtrtareaAdmvs == "320830" {
  32672. api3 = miConfig.AppSecret + "jsyb/2208?psn_no=" + order.PsnNo +
  32673. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32674. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32675. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32676. } else if miConfig.MdtrtareaAdmvs == "320921" {
  32677. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32678. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32679. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32680. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32681. } else {
  32682. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32683. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32684. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32685. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32686. }
  32687. resp3, requestErr3 := http.Get(api3)
  32688. if requestErr3 != nil {
  32689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32690. return
  32691. }
  32692. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32693. if ioErr3 != nil {
  32694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32696. return
  32697. }
  32698. var respJSON3 map[string]interface{}
  32699. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32702. return
  32703. }
  32704. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32705. userJSONBytes3, _ := json.Marshal(respJSON3)
  32706. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  32707. utils.ErrorLog("解析失败:%v", err)
  32708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32709. return
  32710. }
  32711. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  32712. res.Output = resSixteen10265.Output
  32713. res.ErrMsg = resSixteen10265.ErrMsg
  32714. res.Cainfo = resSixteen10265.Cainfo
  32715. res.WarnMsg = resSixteen10265.WarnMsg
  32716. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  32717. res.Infcode = infocode
  32718. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32719. var api3 string
  32720. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  32721. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32722. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32723. resp3, requestErr3 := http.Get(api3)
  32724. if requestErr3 != nil {
  32725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32726. return
  32727. }
  32728. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32729. if ioErr3 != nil {
  32730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32732. return
  32733. }
  32734. var respJSON3 map[string]interface{}
  32735. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32738. return
  32739. }
  32740. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32741. userJSONBytes3, _ := json.Marshal(respJSON3)
  32742. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  32743. utils.ErrorLog("解析失败:%v", err)
  32744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32745. return
  32746. }
  32747. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  32748. res.Output = resSixteen10265.Output
  32749. res.ErrMsg = resSixteen10265.ErrMsg
  32750. res.Cainfo = resSixteen10265.Cainfo
  32751. res.WarnMsg = resSixteen10265.WarnMsg
  32752. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  32753. res.Infcode = infocode
  32754. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32755. 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)
  32756. var dat map[string]interface{}
  32757. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32758. fmt.Println(dat)
  32759. } else {
  32760. fmt.Println(err)
  32761. }
  32762. saveLog(result, src_resquest, "2208", "退费")
  32763. userJSONBytes, _ := json.Marshal(dat)
  32764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32765. utils.ErrorLog("解析失败:%v", err)
  32766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32767. return
  32768. }
  32769. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32770. 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, "")
  32771. var dat map[string]interface{}
  32772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32773. fmt.Println(dat)
  32774. } else {
  32775. fmt.Println(err)
  32776. }
  32777. saveLog(result, src_resquest, "2208", "退费")
  32778. userJSONBytes, _ := json.Marshal(dat)
  32779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32780. utils.ErrorLog("解析失败:%v", err)
  32781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32782. return
  32783. }
  32784. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32785. 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, "")
  32786. var dat map[string]interface{}
  32787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32788. fmt.Println(dat)
  32789. } else {
  32790. fmt.Println(err)
  32791. }
  32792. saveLog(result, src_resquest, "2208", "退费")
  32793. userJSONBytes, _ := json.Marshal(dat)
  32794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32795. utils.ErrorLog("解析失败:%v", err)
  32796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32797. return
  32798. }
  32799. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32800. 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, "")
  32801. var dat map[string]interface{}
  32802. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32803. fmt.Println(dat)
  32804. } else {
  32805. fmt.Println(err)
  32806. }
  32807. saveLog(result, src_resquest, "2208", "退费")
  32808. userJSONBytes, _ := json.Marshal(dat)
  32809. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32810. utils.ErrorLog("解析失败:%v", err)
  32811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32812. return
  32813. }
  32814. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32815. var api3 string
  32816. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  32817. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32818. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32819. resp3, requestErr3 := http.Get(api3)
  32820. if requestErr3 != nil {
  32821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32822. return
  32823. }
  32824. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32825. if ioErr3 != nil {
  32826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32828. return
  32829. }
  32830. var respJSON3 map[string]interface{}
  32831. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32834. return
  32835. }
  32836. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32837. if status == "0" {
  32838. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32839. c.ServeSuccessJSON(map[string]interface{}{
  32840. "failed_code": -10,
  32841. "msg": err_msg,
  32842. })
  32843. return
  32844. }
  32845. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32846. userJSONBytes3, _ := json.Marshal(respJSON3)
  32847. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32848. // utils.ErrorLog("解析失败:%v", err)
  32849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32850. // return
  32851. //}
  32852. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  32853. utils.ErrorLog("解析失败:%v", err)
  32854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32855. return
  32856. }
  32857. res.InfRefmsgid = ahres.InfRefmsgid
  32858. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32859. // 创建对应的Time类型
  32860. t := time.UnixMilli(timestamp)
  32861. // 格式化成指定的日期字符串
  32862. str := t.Format("2006-01-02 15:04:05")
  32863. res.Output.Setlinfo.SetlTime = str
  32864. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32865. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32866. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32867. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32868. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32869. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32870. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32871. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32872. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32873. //
  32874. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32875. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32876. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32877. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32878. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32879. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32880. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32881. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32882. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32883. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32884. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32885. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32886. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32887. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32888. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32889. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32890. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32891. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32892. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32893. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32894. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32895. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32896. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32897. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32898. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32899. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32900. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32901. //res.Output.Setldetail = ahres.Output.Setldetail
  32902. res.ErrMsg = ahres.ErrMsg
  32903. res.Cainfo = ahres.Cainfo
  32904. res.WarnMsg = ahres.WarnMsg
  32905. res.Infcode = ahres.Infcode
  32906. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32907. var api3 string
  32908. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  32909. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32910. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32911. resp3, requestErr3 := http.Get(api3)
  32912. if requestErr3 != nil {
  32913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32914. return
  32915. }
  32916. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32917. if ioErr3 != nil {
  32918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32920. return
  32921. }
  32922. var respJSON3 map[string]interface{}
  32923. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32926. return
  32927. }
  32928. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32929. if status == "0" {
  32930. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32931. c.ServeSuccessJSON(map[string]interface{}{
  32932. "failed_code": -10,
  32933. "msg": err_msg,
  32934. })
  32935. return
  32936. }
  32937. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32938. userJSONBytes3, _ := json.Marshal(respJSON3)
  32939. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32940. // utils.ErrorLog("解析失败:%v", err)
  32941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32942. // return
  32943. //}
  32944. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  32945. utils.ErrorLog("解析失败:%v", err)
  32946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32947. return
  32948. }
  32949. res.InfRefmsgid = ahres.InfRefmsgid
  32950. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32951. // 创建对应的Time类型
  32952. t := time.UnixMilli(timestamp)
  32953. // 格式化成指定的日期字符串
  32954. str := t.Format("2006-01-02 15:04:05")
  32955. res.Output.Setlinfo.SetlTime = str
  32956. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32957. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32958. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32959. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32960. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32961. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32962. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32963. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32964. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32965. //
  32966. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32967. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32968. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32969. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32970. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32971. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32972. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32973. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32974. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32975. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32976. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32977. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32978. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32979. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32980. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32981. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32982. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32983. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32984. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32985. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32986. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32987. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32988. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32989. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32990. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32991. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32992. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32993. //res.Output.Setldetail = ahres.Output.Setldetail
  32994. res.ErrMsg = ahres.ErrMsg
  32995. res.Cainfo = ahres.Cainfo
  32996. res.WarnMsg = ahres.WarnMsg
  32997. res.Infcode = ahres.Infcode
  32998. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32999. 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, "")
  33000. var dat map[string]interface{}
  33001. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33002. fmt.Println(dat)
  33003. } else {
  33004. fmt.Println(err)
  33005. }
  33006. saveLog(result, src_resquest, "2208", "退费")
  33007. userJSONBytes, _ := json.Marshal(dat)
  33008. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33009. utils.ErrorLog("解析失败:%v", err)
  33010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33011. return
  33012. }
  33013. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33014. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  33015. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33016. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33017. resp3, requestErr3 := http.Get(api3)
  33018. if requestErr3 != nil {
  33019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33020. return
  33021. }
  33022. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33023. if ioErr3 != nil {
  33024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33026. return
  33027. }
  33028. var respJSON3 map[string]interface{}
  33029. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33032. return
  33033. }
  33034. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33035. userJSONBytes3, _ := json.Marshal(respJSON3)
  33036. fmt.Println("log")
  33037. fmt.Println(string(userJSONBytes3))
  33038. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33039. utils.ErrorLog("解析失败:%v", err)
  33040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33041. return
  33042. }
  33043. } else {
  33044. if miConfig.Code == "H15049901371" {
  33045. 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)
  33046. var dat map[string]interface{}
  33047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33048. fmt.Println(dat)
  33049. } else {
  33050. fmt.Println(err)
  33051. }
  33052. saveLog(result, src_resquest, "2208", "退费")
  33053. if strings.Contains(result, "Post") {
  33054. res.Infcode = -1
  33055. res.ErrMsg = result
  33056. }
  33057. userJSONBytes, _ := json.Marshal(dat)
  33058. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  33059. utils.ErrorLog("解析失败:%v", err)
  33060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33061. return
  33062. }
  33063. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33064. res.Output = resSixteen10265.Output
  33065. res.ErrMsg = resSixteen10265.ErrMsg
  33066. res.Cainfo = resSixteen10265.Cainfo
  33067. res.WarnMsg = resSixteen10265.WarnMsg
  33068. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33069. res.Infcode = infocode
  33070. } else {
  33071. 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)
  33072. var dat map[string]interface{}
  33073. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33074. fmt.Println(dat)
  33075. } else {
  33076. fmt.Println(err)
  33077. }
  33078. saveLog(result, src_resquest, "2208", "退费")
  33079. userJSONBytes, _ := json.Marshal(dat)
  33080. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33081. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  33082. utils.ErrorLog("解析失败:%v", err)
  33083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33084. return
  33085. }
  33086. res.Infcode = gz.Infcode
  33087. } else {
  33088. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33089. utils.ErrorLog("解析失败:%v", err)
  33090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33091. return
  33092. }
  33093. }
  33094. if strings.Contains(result, "Post") {
  33095. res.Infcode = -1
  33096. res.ErrMsg = result
  33097. }
  33098. }
  33099. }
  33100. if res.Infcode == -1 {
  33101. c.ServeSuccessJSON(map[string]interface{}{
  33102. "failed_code": -10,
  33103. "msg": res.ErrMsg,
  33104. })
  33105. return
  33106. }
  33107. if res.Infcode != -1 {
  33108. var res2 ResultSix
  33109. var resSix10265 ResultSix10265
  33110. if miConfig.MdtrtareaAdmvs == "421300" {
  33111. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33112. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33113. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33114. resp3, requestErr3 := http.Get(api3)
  33115. if requestErr3 != nil {
  33116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33117. return
  33118. }
  33119. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33120. if ioErr3 != nil {
  33121. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33123. return
  33124. }
  33125. var respJSON3 map[string]interface{}
  33126. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33129. return
  33130. }
  33131. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33132. userJSONBytes3, _ := json.Marshal(respJSON3)
  33133. fmt.Println("log")
  33134. fmt.Println(string(userJSONBytes3))
  33135. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33136. utils.ErrorLog("解析失败:%v", err)
  33137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33138. return
  33139. }
  33140. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33141. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33142. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33143. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33144. resp3, requestErr3 := http.Get(api3)
  33145. if requestErr3 != nil {
  33146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33147. return
  33148. }
  33149. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33150. if ioErr3 != nil {
  33151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33153. return
  33154. }
  33155. var respJSON3 map[string]interface{}
  33156. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33159. return
  33160. }
  33161. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33162. userJSONBytes3, _ := json.Marshal(respJSON3)
  33163. fmt.Println("log")
  33164. fmt.Println(string(userJSONBytes3))
  33165. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33166. utils.ErrorLog("解析失败:%v", err)
  33167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33168. return
  33169. }
  33170. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33171. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33172. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33173. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  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. fmt.Println("log")
  33194. fmt.Println(string(userJSONBytes3))
  33195. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33196. utils.ErrorLog("解析失败:%v", err)
  33197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33198. return
  33199. }
  33200. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33201. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33202. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33203. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33204. resp3, requestErr3 := http.Get(api3)
  33205. if requestErr3 != nil {
  33206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33207. return
  33208. }
  33209. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33210. if ioErr3 != nil {
  33211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33213. return
  33214. }
  33215. var respJSON3 map[string]interface{}
  33216. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33219. return
  33220. }
  33221. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33222. userJSONBytes3, _ := json.Marshal(respJSON3)
  33223. fmt.Println("log")
  33224. fmt.Println(string(userJSONBytes3))
  33225. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33226. utils.ErrorLog("解析失败:%v", err)
  33227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33228. return
  33229. }
  33230. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33231. var api3 string
  33232. if miConfig.MdtrtareaAdmvs == "320830" {
  33233. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  33234. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33235. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33236. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33237. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33238. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33239. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33240. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33241. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33242. } else {
  33243. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33244. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33245. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33246. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33247. }
  33248. resp3, requestErr3 := http.Get(api3)
  33249. if requestErr3 != nil {
  33250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33251. return
  33252. }
  33253. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33254. if ioErr3 != nil {
  33255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33257. return
  33258. }
  33259. var respJSON3 map[string]interface{}
  33260. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33263. return
  33264. }
  33265. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33266. userJSONBytes3, _ := json.Marshal(respJSON3)
  33267. fmt.Println("log")
  33268. fmt.Println(string(userJSONBytes3))
  33269. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33270. utils.ErrorLog("解析失败:%v", err)
  33271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33272. return
  33273. }
  33274. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33275. res2.Output = resSix10265.Output
  33276. res2.ErrMsg = resSix10265.ErrMsg
  33277. res2.Cainfo = resSix10265.Cainfo
  33278. res2.WarnMsg = resSix10265.WarnMsg
  33279. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33280. res2.Infcode = infocode
  33281. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33282. var api3 string
  33283. new_chrg_bchno := order.Number
  33284. if adminUser.CurrentOrgId == 10265 {
  33285. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33286. new_chrg_bchno = "0000"
  33287. }
  33288. }
  33289. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33290. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33291. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33292. resp3, requestErr3 := http.Get(api3)
  33293. if requestErr3 != nil {
  33294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33295. return
  33296. }
  33297. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33298. if ioErr3 != nil {
  33299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33301. return
  33302. }
  33303. var respJSON3 map[string]interface{}
  33304. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33307. return
  33308. }
  33309. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33310. userJSONBytes3, _ := json.Marshal(respJSON3)
  33311. fmt.Println("log")
  33312. fmt.Println(string(userJSONBytes3))
  33313. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33314. utils.ErrorLog("解析失败:%v", err)
  33315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33316. return
  33317. }
  33318. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33319. res2.Output = resSix10265.Output
  33320. res2.ErrMsg = resSix10265.ErrMsg
  33321. res2.Cainfo = resSix10265.Cainfo
  33322. res2.WarnMsg = resSix10265.WarnMsg
  33323. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33324. res2.Infcode = infocode
  33325. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33326. 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)
  33327. var dat map[string]interface{}
  33328. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33329. fmt.Println(dat)
  33330. } else {
  33331. fmt.Println(err)
  33332. }
  33333. saveLog(result2, src_request, "2205", "撤销明细")
  33334. userJSONBytes, _ := json.Marshal(dat)
  33335. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33336. utils.ErrorLog("解析失败:%v", err)
  33337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33338. return
  33339. }
  33340. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33341. 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, "")
  33342. var dat map[string]interface{}
  33343. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33344. fmt.Println(dat)
  33345. } else {
  33346. fmt.Println(err)
  33347. }
  33348. saveLog(result2, src_request, "2205", "撤销明细")
  33349. userJSONBytes, _ := json.Marshal(dat)
  33350. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33351. utils.ErrorLog("解析失败:%v", err)
  33352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33353. return
  33354. }
  33355. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33356. 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, "")
  33357. var dat map[string]interface{}
  33358. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33359. fmt.Println(dat)
  33360. } else {
  33361. fmt.Println(err)
  33362. }
  33363. saveLog(result2, src_request, "2205", "撤销明细")
  33364. userJSONBytes, _ := json.Marshal(dat)
  33365. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33366. utils.ErrorLog("解析失败:%v", err)
  33367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33368. return
  33369. }
  33370. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33371. 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, "")
  33372. var dat map[string]interface{}
  33373. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33374. fmt.Println(dat)
  33375. } else {
  33376. fmt.Println(err)
  33377. }
  33378. saveLog(result2, src_request, "2205", "撤销明细")
  33379. userJSONBytes, _ := json.Marshal(dat)
  33380. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33381. utils.ErrorLog("解析失败:%v", err)
  33382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33383. return
  33384. }
  33385. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33386. var api3 string
  33387. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33388. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33389. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33390. resp3, requestErr3 := http.Get(api3)
  33391. if requestErr3 != nil {
  33392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33393. return
  33394. }
  33395. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33396. if ioErr3 != nil {
  33397. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33399. return
  33400. }
  33401. var respJSON3 map[string]interface{}
  33402. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33405. return
  33406. }
  33407. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33408. if status == "0" {
  33409. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33410. c.ServeSuccessJSON(map[string]interface{}{
  33411. "failed_code": -10,
  33412. "msg": err_msg,
  33413. })
  33414. return
  33415. }
  33416. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33417. userJSONBytes3, _ := json.Marshal(respJSON3)
  33418. fmt.Println("log")
  33419. fmt.Println(string(userJSONBytes3))
  33420. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33421. utils.ErrorLog("解析失败:%v", err)
  33422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33423. return
  33424. }
  33425. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33426. 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, "")
  33427. var dat map[string]interface{}
  33428. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33429. fmt.Println(dat)
  33430. } else {
  33431. fmt.Println(err)
  33432. }
  33433. saveLog(result2, src_request, "2205", "撤销明细")
  33434. userJSONBytes, _ := json.Marshal(dat)
  33435. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33436. utils.ErrorLog("解析失败:%v", err)
  33437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33438. return
  33439. }
  33440. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33441. 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, "")
  33442. var dat map[string]interface{}
  33443. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33444. fmt.Println(dat)
  33445. } else {
  33446. fmt.Println(err)
  33447. }
  33448. saveLog(result2, src_request, "2205", "撤销明细")
  33449. userJSONBytes, _ := json.Marshal(dat)
  33450. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33451. utils.ErrorLog("解析失败:%v", err)
  33452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33453. return
  33454. }
  33455. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33456. 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, "")
  33457. var dat map[string]interface{}
  33458. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33459. fmt.Println(dat)
  33460. } else {
  33461. fmt.Println(err)
  33462. }
  33463. saveLog(result2, src_request, "2205", "撤销明细")
  33464. userJSONBytes, _ := json.Marshal(dat)
  33465. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33466. utils.ErrorLog("解析失败:%v", err)
  33467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33468. return
  33469. }
  33470. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33471. var api3 string
  33472. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33473. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33474. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33475. resp3, requestErr3 := http.Get(api3)
  33476. if requestErr3 != nil {
  33477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33478. return
  33479. }
  33480. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33481. if ioErr3 != nil {
  33482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33484. return
  33485. }
  33486. var respJSON3 map[string]interface{}
  33487. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33490. return
  33491. }
  33492. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33493. if status == "0" {
  33494. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33495. c.ServeSuccessJSON(map[string]interface{}{
  33496. "failed_code": -10,
  33497. "msg": err_msg,
  33498. })
  33499. return
  33500. }
  33501. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33502. userJSONBytes3, _ := json.Marshal(respJSON3)
  33503. fmt.Println("log")
  33504. fmt.Println(string(userJSONBytes3))
  33505. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33506. utils.ErrorLog("解析失败:%v", err)
  33507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33508. return
  33509. }
  33510. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33511. 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, "")
  33512. var dat map[string]interface{}
  33513. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33514. fmt.Println(dat)
  33515. } else {
  33516. fmt.Println(err)
  33517. }
  33518. saveLog(result2, src_request, "2205", "撤销明细")
  33519. userJSONBytes, _ := json.Marshal(dat)
  33520. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33521. utils.ErrorLog("解析失败:%v", err)
  33522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33523. return
  33524. }
  33525. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33526. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  33527. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33528. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33529. resp3, requestErr3 := http.Get(api3)
  33530. if requestErr3 != nil {
  33531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33532. return
  33533. }
  33534. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33535. if ioErr3 != nil {
  33536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33538. return
  33539. }
  33540. var respJSON3 map[string]interface{}
  33541. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33544. return
  33545. }
  33546. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33547. userJSONBytes3, _ := json.Marshal(respJSON3)
  33548. fmt.Println("log")
  33549. fmt.Println(string(userJSONBytes3))
  33550. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33551. utils.ErrorLog("解析失败:%v", err)
  33552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33553. return
  33554. }
  33555. } else {
  33556. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33557. res2.Infcode = 0
  33558. } else {
  33559. 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)
  33560. var dat map[string]interface{}
  33561. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33562. fmt.Println(dat)
  33563. } else {
  33564. fmt.Println(err)
  33565. }
  33566. saveLog(result2, src_request, "2205", "撤销明细")
  33567. userJSONBytes, _ := json.Marshal(dat)
  33568. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33569. utils.ErrorLog("解析失败:%v", err)
  33570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33571. return
  33572. }
  33573. }
  33574. }
  33575. if res2.Infcode == -1 {
  33576. c.ServeSuccessJSON(map[string]interface{}{
  33577. "failed_code": -10,
  33578. "msg": res2.ErrMsg,
  33579. })
  33580. return
  33581. }
  33582. if res2.Infcode == 0 {
  33583. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  33584. if err == nil {
  33585. //当押金不为零时产生退费记录
  33586. if order.Decimal != 0 {
  33587. tmp := strconv.FormatInt(order.ID, 10)
  33588. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  33589. if err != nil {
  33590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33591. return
  33592. }
  33593. }
  33594. c.ServeSuccessJSON(map[string]interface{}{
  33595. "msg": "退费成功",
  33596. })
  33597. } else {
  33598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33599. return
  33600. }
  33601. } else {
  33602. c.ServeSuccessJSON(map[string]interface{}{
  33603. "failed_code": -10,
  33604. "msg": res2.ErrMsg,
  33605. })
  33606. }
  33607. } else {
  33608. c.ServeSuccessJSON(map[string]interface{}{
  33609. "failed_code": -10,
  33610. "msg": res.ErrMsg,
  33611. })
  33612. }
  33613. }
  33614. }
  33615. func (c *HisApiController) RefundNumber() {
  33616. record_time := c.GetString("record_time")
  33617. //patient_id, _ := c.GetInt64("patient_id")
  33618. admin_user_id, _ := c.GetInt64("admin_user_id")
  33619. his_patient_id, _ := c.GetInt64("id")
  33620. timeLayout := "2006-01-02"
  33621. loc, _ := time.LoadLocation("Local")
  33622. adminUser := c.GetAdminUserInfo()
  33623. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33624. fmt.Println(err)
  33625. if err != nil {
  33626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33627. return
  33628. }
  33629. recordDateTime := theTime.Unix()
  33630. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33631. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  33632. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33633. //order, _ := service.GetHisOrderByID(order_id)
  33634. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33635. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33636. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33637. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  33638. if count > 0 {
  33639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  33640. return
  33641. }
  33642. if config.IsOpen == 1 { //对接了医保,走医保流程
  33643. var res2 ResultSix
  33644. var res3 GZResultSix
  33645. var resSix10265 ResultSix10265
  33646. if miConfig.MdtrtareaAdmvs == "421300" {
  33647. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33648. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33649. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33650. resp3, requestErr3 := http.Get(api3)
  33651. if requestErr3 != nil {
  33652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33653. return
  33654. }
  33655. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33656. if ioErr3 != nil {
  33657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33659. return
  33660. }
  33661. var respJSON3 map[string]interface{}
  33662. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33665. return
  33666. }
  33667. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33668. userJSONBytes3, _ := json.Marshal(respJSON3)
  33669. fmt.Println("log")
  33670. fmt.Println(string(userJSONBytes3))
  33671. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33672. utils.ErrorLog("解析失败:%v", err)
  33673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33674. return
  33675. }
  33676. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33677. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33678. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33679. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33680. resp3, requestErr3 := http.Get(api3)
  33681. if requestErr3 != nil {
  33682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33683. return
  33684. }
  33685. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33686. if ioErr3 != nil {
  33687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33689. return
  33690. }
  33691. var respJSON3 map[string]interface{}
  33692. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33695. return
  33696. }
  33697. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33698. userJSONBytes3, _ := json.Marshal(respJSON3)
  33699. fmt.Println("log")
  33700. fmt.Println(string(userJSONBytes3))
  33701. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33702. utils.ErrorLog("解析失败:%v", err)
  33703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33704. return
  33705. }
  33706. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33707. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  33708. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33709. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33710. resp3, requestErr3 := http.Get(api3)
  33711. if requestErr3 != nil {
  33712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33713. return
  33714. }
  33715. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33716. if ioErr3 != nil {
  33717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33719. return
  33720. }
  33721. var respJSON3 map[string]interface{}
  33722. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33725. return
  33726. }
  33727. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33728. userJSONBytes3, _ := json.Marshal(respJSON3)
  33729. fmt.Println("log")
  33730. fmt.Println(string(userJSONBytes3))
  33731. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33732. utils.ErrorLog("解析失败:%v", err)
  33733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33734. return
  33735. }
  33736. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33737. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  33738. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33739. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33740. resp3, requestErr3 := http.Get(api3)
  33741. if requestErr3 != nil {
  33742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33743. return
  33744. }
  33745. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33746. if ioErr3 != nil {
  33747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33749. return
  33750. }
  33751. var respJSON3 map[string]interface{}
  33752. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33755. return
  33756. }
  33757. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33758. userJSONBytes3, _ := json.Marshal(respJSON3)
  33759. fmt.Println("log")
  33760. fmt.Println(string(userJSONBytes3))
  33761. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33762. utils.ErrorLog("解析失败:%v", err)
  33763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33764. return
  33765. }
  33766. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33767. var api3 string
  33768. if miConfig.MdtrtareaAdmvs == "320830" {
  33769. api3 = miConfig.AppSecret + "jsyb/2202?psn_no=" + his.PsnNo +
  33770. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33771. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33772. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33773. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33774. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  33775. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33776. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33777. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33778. } else {
  33779. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33780. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  33781. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33782. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33783. }
  33784. resp3, requestErr3 := http.Get(api3)
  33785. if requestErr3 != nil {
  33786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33787. return
  33788. }
  33789. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33790. if ioErr3 != nil {
  33791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33793. return
  33794. }
  33795. var respJSON3 map[string]interface{}
  33796. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33799. return
  33800. }
  33801. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33802. userJSONBytes3, _ := json.Marshal(respJSON3)
  33803. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33804. utils.ErrorLog("解析失败:%v", err)
  33805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33806. return
  33807. }
  33808. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33809. res2.Output = resSix10265.Output
  33810. res2.ErrMsg = resSix10265.ErrMsg
  33811. res2.Cainfo = resSix10265.Cainfo
  33812. res2.WarnMsg = resSix10265.WarnMsg
  33813. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33814. res2.Infcode = infocode
  33815. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33816. var api3 string
  33817. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  33818. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33819. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33820. resp3, requestErr3 := http.Get(api3)
  33821. if requestErr3 != nil {
  33822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33823. return
  33824. }
  33825. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33826. if ioErr3 != nil {
  33827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33829. return
  33830. }
  33831. var respJSON3 map[string]interface{}
  33832. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33835. return
  33836. }
  33837. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33838. userJSONBytes3, _ := json.Marshal(respJSON3)
  33839. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33840. utils.ErrorLog("解析失败:%v", err)
  33841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33842. return
  33843. }
  33844. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33845. res2.Output = resSix10265.Output
  33846. res2.ErrMsg = resSix10265.ErrMsg
  33847. res2.Cainfo = resSix10265.Cainfo
  33848. res2.WarnMsg = resSix10265.WarnMsg
  33849. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33850. res2.Infcode = infocode
  33851. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33852. 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)
  33853. var dat map[string]interface{}
  33854. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33855. fmt.Println(dat)
  33856. } else {
  33857. fmt.Println(err)
  33858. }
  33859. saveLog(result, request, "2202", "退号")
  33860. userJSONBytes, _ := json.Marshal(dat)
  33861. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33862. utils.ErrorLog("解析失败:%v", err)
  33863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33864. return
  33865. }
  33866. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33867. 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, "")
  33868. var dat map[string]interface{}
  33869. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33870. fmt.Println(dat)
  33871. } else {
  33872. fmt.Println(err)
  33873. }
  33874. saveLog(result, request, "2202", "退号")
  33875. userJSONBytes, _ := json.Marshal(dat)
  33876. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33877. utils.ErrorLog("解析失败:%v", err)
  33878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33879. return
  33880. }
  33881. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33882. 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, "")
  33883. var dat map[string]interface{}
  33884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33885. fmt.Println(dat)
  33886. } else {
  33887. fmt.Println(err)
  33888. }
  33889. saveLog(result, request, "2202", "退号")
  33890. userJSONBytes, _ := json.Marshal(dat)
  33891. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33892. utils.ErrorLog("解析失败:%v", err)
  33893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33894. return
  33895. }
  33896. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33897. 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, "")
  33898. var dat map[string]interface{}
  33899. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33900. fmt.Println(dat)
  33901. } else {
  33902. fmt.Println(err)
  33903. }
  33904. saveLog(result, request, "2202", "退号")
  33905. userJSONBytes, _ := json.Marshal(dat)
  33906. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33907. utils.ErrorLog("解析失败:%v", err)
  33908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33909. return
  33910. }
  33911. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33912. var api3 string
  33913. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  33914. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33915. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33916. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33917. resp3, requestErr3 := http.Get(api3)
  33918. if requestErr3 != nil {
  33919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33920. return
  33921. }
  33922. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33923. if ioErr3 != nil {
  33924. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33926. return
  33927. }
  33928. var respJSON3 map[string]interface{}
  33929. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33932. return
  33933. }
  33934. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33935. if status == "0" {
  33936. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33937. c.ServeSuccessJSON(map[string]interface{}{
  33938. "failed_code": -10,
  33939. "msg": err_msg,
  33940. })
  33941. return
  33942. }
  33943. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33944. userJSONBytes3, _ := json.Marshal(respJSON3)
  33945. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33946. utils.ErrorLog("解析失败:%v", err)
  33947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33948. return
  33949. }
  33950. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  33951. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33952. var api3 string
  33953. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  33954. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33955. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33956. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33957. resp3, requestErr3 := http.Get(api3)
  33958. if requestErr3 != nil {
  33959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33960. return
  33961. }
  33962. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33963. if ioErr3 != nil {
  33964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33966. return
  33967. }
  33968. var respJSON3 map[string]interface{}
  33969. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33972. return
  33973. }
  33974. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33975. if status == "0" {
  33976. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33977. c.ServeSuccessJSON(map[string]interface{}{
  33978. "failed_code": -10,
  33979. "msg": err_msg,
  33980. })
  33981. return
  33982. }
  33983. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33984. userJSONBytes3, _ := json.Marshal(respJSON3)
  33985. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33986. utils.ErrorLog("解析失败:%v", err)
  33987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33988. return
  33989. }
  33990. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  33991. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33992. 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, "")
  33993. var dat map[string]interface{}
  33994. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33995. fmt.Println(dat)
  33996. } else {
  33997. fmt.Println(err)
  33998. }
  33999. saveLog(result, request, "2202", "退号")
  34000. userJSONBytes, _ := json.Marshal(dat)
  34001. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34002. utils.ErrorLog("解析失败:%v", err)
  34003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34004. return
  34005. }
  34006. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34007. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  34008. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34009. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34010. resp3, requestErr3 := http.Get(api3)
  34011. if requestErr3 != nil {
  34012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34013. return
  34014. }
  34015. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34016. if ioErr3 != nil {
  34017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34019. return
  34020. }
  34021. var respJSON3 map[string]interface{}
  34022. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34025. return
  34026. }
  34027. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34028. userJSONBytes3, _ := json.Marshal(respJSON3)
  34029. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34030. utils.ErrorLog("解析失败:%v", err)
  34031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34032. return
  34033. }
  34034. } else {
  34035. var api3 string
  34036. if miConfig.Code == "H15049901371" {
  34037. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  34038. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34039. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34040. } else {
  34041. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  34042. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34043. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34044. }
  34045. resp3, requestErr3 := http.Get(api3)
  34046. if requestErr3 != nil {
  34047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34048. return
  34049. }
  34050. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34051. if ioErr3 != nil {
  34052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34054. return
  34055. }
  34056. var respJSON3 map[string]interface{}
  34057. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34060. return
  34061. }
  34062. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34063. userJSONBytes3, _ := json.Marshal(respJSON3)
  34064. if miConfig.Code == "H15049901371" {
  34065. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34066. utils.ErrorLog("解析失败:%v", err)
  34067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34068. return
  34069. }
  34070. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34071. res2.Output = resSix10265.Output
  34072. res2.ErrMsg = resSix10265.ErrMsg
  34073. res2.Cainfo = resSix10265.Cainfo
  34074. res2.WarnMsg = resSix10265.WarnMsg
  34075. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34076. res2.Infcode = infocode
  34077. } else {
  34078. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34079. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  34080. utils.ErrorLog("解析失败:%v", err)
  34081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34082. return
  34083. }
  34084. res2.Infcode = res3.Infcode
  34085. } else {
  34086. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34087. utils.ErrorLog("解析失败:%v", err)
  34088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34089. return
  34090. }
  34091. }
  34092. }
  34093. }
  34094. if res2.Infcode == -1 {
  34095. c.ServeSuccessJSON(map[string]interface{}{
  34096. "failed_code": -10,
  34097. "msg": res2.ErrMsg,
  34098. })
  34099. return
  34100. }
  34101. if res2.Infcode == 0 {
  34102. if err == nil {
  34103. c.ServeSuccessJSON(map[string]interface{}{
  34104. "msg": "退号成功",
  34105. })
  34106. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  34107. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  34108. } else {
  34109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34110. return
  34111. }
  34112. }
  34113. } else {
  34114. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  34115. //if err == nil {
  34116. // c.ServeSuccessJSON(map[string]interface{}{
  34117. // "msg": "退费成功",
  34118. // })
  34119. //} else {
  34120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34121. // return
  34122. //}
  34123. }
  34124. }
  34125. func (c *HisApiController) RefundDetail() {
  34126. order_id, _ := c.GetInt64("order_id")
  34127. admin_user_id, _ := c.GetInt64("admin_user_id")
  34128. //his_patient_id, _ := c.GetInt64("his_patient_id")
  34129. number := c.GetString("number")
  34130. record_time := c.GetString("record_time")
  34131. patient_id, _ := c.GetInt64("patient_id")
  34132. //med_type, _ := c.GetInt64("med_type")
  34133. timeLayout := "2006-01-02"
  34134. loc, _ := time.LoadLocation("Local")
  34135. adminUser := c.GetAdminUserInfo()
  34136. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34137. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34138. fmt.Println(err)
  34139. if err != nil {
  34140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34141. return
  34142. }
  34143. recordDateTime := theTime.Unix()
  34144. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  34145. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34146. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34147. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34148. var order models.HisOrder
  34149. order, _ = service.GetHisOrderByID(order_id)
  34150. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34151. if config.IsOpen == 1 { //对接了医保,走医保流程
  34152. var res2 ResultSix
  34153. if miConfig.MdtrtareaAdmvs == "421300" {
  34154. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34155. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34156. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34157. resp3, requestErr3 := http.Get(api3)
  34158. if requestErr3 != nil {
  34159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34160. return
  34161. }
  34162. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34163. if ioErr3 != nil {
  34164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34166. return
  34167. }
  34168. var respJSON3 map[string]interface{}
  34169. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34172. return
  34173. }
  34174. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34175. userJSONBytes3, _ := json.Marshal(respJSON3)
  34176. fmt.Println("log")
  34177. fmt.Println(string(userJSONBytes3))
  34178. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34179. utils.ErrorLog("解析失败:%v", err)
  34180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34181. return
  34182. }
  34183. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34184. if err == nil {
  34185. c.ServeSuccessJSON(map[string]interface{}{
  34186. "msg": "撤销明细成功",
  34187. })
  34188. return
  34189. } else {
  34190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34191. return
  34192. }
  34193. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34194. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34195. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34196. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34197. resp3, requestErr3 := http.Get(api3)
  34198. if requestErr3 != nil {
  34199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34200. return
  34201. }
  34202. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34203. if ioErr3 != nil {
  34204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34206. return
  34207. }
  34208. var respJSON3 map[string]interface{}
  34209. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34212. return
  34213. }
  34214. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34215. userJSONBytes3, _ := json.Marshal(respJSON3)
  34216. fmt.Println("log")
  34217. fmt.Println(string(userJSONBytes3))
  34218. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34219. utils.ErrorLog("解析失败:%v", err)
  34220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34221. return
  34222. }
  34223. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34224. if err == nil {
  34225. c.ServeSuccessJSON(map[string]interface{}{
  34226. "msg": "撤销明细成功",
  34227. })
  34228. return
  34229. } else {
  34230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34231. return
  34232. }
  34233. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34234. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34235. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34236. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34237. resp3, requestErr3 := http.Get(api3)
  34238. if requestErr3 != nil {
  34239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34240. return
  34241. }
  34242. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34243. if ioErr3 != nil {
  34244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34246. return
  34247. }
  34248. var respJSON3 map[string]interface{}
  34249. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34252. return
  34253. }
  34254. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34255. userJSONBytes3, _ := json.Marshal(respJSON3)
  34256. fmt.Println("log")
  34257. fmt.Println(string(userJSONBytes3))
  34258. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34259. utils.ErrorLog("解析失败:%v", err)
  34260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34261. return
  34262. }
  34263. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34264. if err == nil {
  34265. c.ServeSuccessJSON(map[string]interface{}{
  34266. "msg": "撤销明细成功",
  34267. })
  34268. return
  34269. } else {
  34270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34271. return
  34272. }
  34273. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34274. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34275. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34276. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34277. resp3, requestErr3 := http.Get(api3)
  34278. if requestErr3 != nil {
  34279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34280. return
  34281. }
  34282. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34283. if ioErr3 != nil {
  34284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34286. return
  34287. }
  34288. var respJSON3 map[string]interface{}
  34289. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34292. return
  34293. }
  34294. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34295. userJSONBytes3, _ := json.Marshal(respJSON3)
  34296. fmt.Println("log")
  34297. fmt.Println(string(userJSONBytes3))
  34298. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34299. utils.ErrorLog("解析失败:%v", err)
  34300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34301. return
  34302. }
  34303. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34304. if err == nil {
  34305. c.ServeSuccessJSON(map[string]interface{}{
  34306. "msg": "撤销明细成功",
  34307. })
  34308. return
  34309. } else {
  34310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34311. return
  34312. }
  34313. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34314. var resSix10265 ResultSix10265
  34315. var api3 string
  34316. if miConfig.MdtrtareaAdmvs == "320830" {
  34317. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  34318. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34319. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34320. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34321. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34322. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34323. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34324. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34325. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34326. } else {
  34327. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34328. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34329. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34330. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34331. }
  34332. resp3, requestErr3 := http.Get(api3)
  34333. utils.ErrorLog("接口: %v", requestErr3)
  34334. if requestErr3 != nil {
  34335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34336. return
  34337. }
  34338. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34339. if ioErr3 != nil {
  34340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34342. return
  34343. }
  34344. var respJSON3 map[string]interface{}
  34345. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34348. return
  34349. }
  34350. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34351. userJSONBytes3, _ := json.Marshal(respJSON3)
  34352. fmt.Println("log")
  34353. fmt.Println(string(userJSONBytes3))
  34354. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34355. utils.ErrorLog("解析失败:%v", err)
  34356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34357. return
  34358. }
  34359. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34360. res2.Output = resSix10265.Output
  34361. res2.ErrMsg = resSix10265.ErrMsg
  34362. res2.Cainfo = resSix10265.Cainfo
  34363. res2.WarnMsg = resSix10265.WarnMsg
  34364. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34365. res2.Infcode = infocode
  34366. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34367. if err == nil {
  34368. c.ServeSuccessJSON(map[string]interface{}{
  34369. "msg": "撤销明细成功",
  34370. })
  34371. return
  34372. } else {
  34373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34374. return
  34375. }
  34376. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34377. var api3 string
  34378. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34379. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34380. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34381. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34382. resp3, requestErr3 := http.Get(api3)
  34383. utils.ErrorLog("接口: %v", requestErr3)
  34384. if requestErr3 != nil {
  34385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34386. return
  34387. }
  34388. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34389. if ioErr3 != nil {
  34390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34392. return
  34393. }
  34394. var respJSON3 map[string]interface{}
  34395. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34398. return
  34399. }
  34400. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34401. if status == "0" {
  34402. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34403. c.ServeSuccessJSON(map[string]interface{}{
  34404. "failed_code": -10,
  34405. "msg": err_msg,
  34406. })
  34407. return
  34408. }
  34409. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34410. userJSONBytes3, _ := json.Marshal(respJSON3)
  34411. fmt.Println("log")
  34412. fmt.Println(string(userJSONBytes3))
  34413. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34414. utils.ErrorLog("解析失败:%v", err)
  34415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34416. return
  34417. }
  34418. fmt.Println(res2.Infcode)
  34419. if res2.Infcode == -1 {
  34420. c.ServeSuccessJSON(map[string]interface{}{
  34421. "failed_code": -10,
  34422. "msg": res2.ErrMsg,
  34423. })
  34424. return
  34425. }
  34426. if res2.Infcode == 0 {
  34427. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34428. if err == nil {
  34429. c.ServeSuccessJSON(map[string]interface{}{
  34430. "msg": "撤销明细成功",
  34431. })
  34432. return
  34433. } else {
  34434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34435. return
  34436. }
  34437. } else {
  34438. c.ServeSuccessJSON(map[string]interface{}{
  34439. "failed_code": -10,
  34440. "msg": res2.ErrMsg,
  34441. })
  34442. }
  34443. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34444. if err == nil {
  34445. c.ServeSuccessJSON(map[string]interface{}{
  34446. "msg": "撤销明细成功",
  34447. })
  34448. return
  34449. } else {
  34450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34451. return
  34452. }
  34453. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34454. var api3 string
  34455. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34456. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34457. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34458. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34459. resp3, requestErr3 := http.Get(api3)
  34460. utils.ErrorLog("接口: %v", requestErr3)
  34461. if requestErr3 != nil {
  34462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34463. return
  34464. }
  34465. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34466. if ioErr3 != nil {
  34467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34469. return
  34470. }
  34471. var respJSON3 map[string]interface{}
  34472. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34475. return
  34476. }
  34477. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34478. if status == "0" {
  34479. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34480. c.ServeSuccessJSON(map[string]interface{}{
  34481. "failed_code": -10,
  34482. "msg": err_msg,
  34483. })
  34484. return
  34485. }
  34486. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34487. userJSONBytes3, _ := json.Marshal(respJSON3)
  34488. fmt.Println("log")
  34489. fmt.Println(string(userJSONBytes3))
  34490. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34491. utils.ErrorLog("解析失败:%v", err)
  34492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34493. return
  34494. }
  34495. fmt.Println(res2.Infcode)
  34496. if res2.Infcode == -1 {
  34497. c.ServeSuccessJSON(map[string]interface{}{
  34498. "failed_code": -10,
  34499. "msg": res2.ErrMsg,
  34500. })
  34501. return
  34502. }
  34503. if res2.Infcode == 0 {
  34504. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34505. if err == nil {
  34506. c.ServeSuccessJSON(map[string]interface{}{
  34507. "msg": "撤销明细成功",
  34508. })
  34509. return
  34510. } else {
  34511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34512. return
  34513. }
  34514. } else {
  34515. c.ServeSuccessJSON(map[string]interface{}{
  34516. "failed_code": -10,
  34517. "msg": res2.ErrMsg,
  34518. })
  34519. }
  34520. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34521. if err == nil {
  34522. c.ServeSuccessJSON(map[string]interface{}{
  34523. "msg": "撤销明细成功",
  34524. })
  34525. return
  34526. } else {
  34527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34528. return
  34529. }
  34530. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34531. var resSix10265 ResultSix10265
  34532. new_chrg_bchno := order.Number
  34533. if adminUser.CurrentOrgId == 10265 {
  34534. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  34535. new_chrg_bchno = "0000"
  34536. }
  34537. }
  34538. var api3 string
  34539. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  34540. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34541. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34542. resp3, requestErr3 := http.Get(api3)
  34543. if requestErr3 != nil {
  34544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34545. return
  34546. }
  34547. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34548. if ioErr3 != nil {
  34549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34551. return
  34552. }
  34553. var respJSON3 map[string]interface{}
  34554. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34557. return
  34558. }
  34559. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34560. userJSONBytes3, _ := json.Marshal(respJSON3)
  34561. fmt.Println("log")
  34562. fmt.Println(string(userJSONBytes3))
  34563. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34564. utils.ErrorLog("解析失败:%v", err)
  34565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34566. return
  34567. }
  34568. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34569. res2.Output = resSix10265.Output
  34570. res2.ErrMsg = resSix10265.ErrMsg
  34571. res2.Cainfo = resSix10265.Cainfo
  34572. res2.WarnMsg = resSix10265.WarnMsg
  34573. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34574. res2.Infcode = infocode
  34575. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34576. if err == nil {
  34577. c.ServeSuccessJSON(map[string]interface{}{
  34578. "msg": "撤销明细成功",
  34579. })
  34580. return
  34581. } else {
  34582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34583. return
  34584. }
  34585. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34586. 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)
  34587. var dat map[string]interface{}
  34588. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34589. fmt.Println(dat)
  34590. } else {
  34591. fmt.Println(err)
  34592. }
  34593. saveLog(result2, src_request, "2205", "撤销明细")
  34594. userJSONBytes, _ := json.Marshal(dat)
  34595. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34596. utils.ErrorLog("解析失败:%v", err)
  34597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34598. return
  34599. }
  34600. if res2.Infcode == 0 {
  34601. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34602. if err == nil {
  34603. c.ServeSuccessJSON(map[string]interface{}{
  34604. "msg": "撤销明细成功",
  34605. })
  34606. return
  34607. } else {
  34608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34609. return
  34610. }
  34611. } else {
  34612. c.ServeSuccessJSON(map[string]interface{}{
  34613. "failed_code": -10,
  34614. "msg": res2.ErrMsg,
  34615. })
  34616. }
  34617. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34618. 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, "")
  34619. var dat map[string]interface{}
  34620. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34621. fmt.Println(dat)
  34622. } else {
  34623. fmt.Println(err)
  34624. }
  34625. saveLog(result2, src_request, "2205", "撤销明细")
  34626. userJSONBytes, _ := json.Marshal(dat)
  34627. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34628. utils.ErrorLog("解析失败:%v", err)
  34629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34630. return
  34631. }
  34632. if res2.Infcode == 0 {
  34633. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34634. if err == nil {
  34635. c.ServeSuccessJSON(map[string]interface{}{
  34636. "msg": "撤销明细成功",
  34637. })
  34638. return
  34639. } else {
  34640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34641. return
  34642. }
  34643. } else {
  34644. c.ServeSuccessJSON(map[string]interface{}{
  34645. "failed_code": -10,
  34646. "msg": res2.ErrMsg,
  34647. })
  34648. }
  34649. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34650. 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, "")
  34651. var dat map[string]interface{}
  34652. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34653. fmt.Println(dat)
  34654. } else {
  34655. fmt.Println(err)
  34656. }
  34657. saveLog(result2, src_request, "2205", "撤销明细")
  34658. userJSONBytes, _ := json.Marshal(dat)
  34659. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34660. utils.ErrorLog("解析失败:%v", err)
  34661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34662. return
  34663. }
  34664. if res2.Infcode == 0 {
  34665. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34666. if err == nil {
  34667. c.ServeSuccessJSON(map[string]interface{}{
  34668. "msg": "撤销明细成功",
  34669. })
  34670. return
  34671. } else {
  34672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34673. return
  34674. }
  34675. } else {
  34676. c.ServeSuccessJSON(map[string]interface{}{
  34677. "failed_code": -10,
  34678. "msg": res2.ErrMsg,
  34679. })
  34680. }
  34681. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34682. 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, "")
  34683. var dat map[string]interface{}
  34684. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34685. fmt.Println(dat)
  34686. } else {
  34687. fmt.Println(err)
  34688. }
  34689. saveLog(result2, src_request, "2205", "撤销明细")
  34690. userJSONBytes, _ := json.Marshal(dat)
  34691. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34692. utils.ErrorLog("解析失败:%v", err)
  34693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34694. return
  34695. }
  34696. if res2.Infcode == 0 {
  34697. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34698. if err == nil {
  34699. c.ServeSuccessJSON(map[string]interface{}{
  34700. "msg": "撤销明细成功",
  34701. })
  34702. return
  34703. } else {
  34704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34705. return
  34706. }
  34707. } else {
  34708. c.ServeSuccessJSON(map[string]interface{}{
  34709. "failed_code": -10,
  34710. "msg": res2.ErrMsg,
  34711. })
  34712. }
  34713. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34714. 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, "")
  34715. var dat map[string]interface{}
  34716. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34717. fmt.Println(dat)
  34718. } else {
  34719. fmt.Println(err)
  34720. }
  34721. saveLog(result2, src_request, "2205", "撤销明细")
  34722. userJSONBytes, _ := json.Marshal(dat)
  34723. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34724. utils.ErrorLog("解析失败:%v", err)
  34725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34726. return
  34727. }
  34728. if res2.Infcode == 0 {
  34729. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34730. if err == nil {
  34731. c.ServeSuccessJSON(map[string]interface{}{
  34732. "msg": "撤销明细成功",
  34733. })
  34734. return
  34735. } else {
  34736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34737. return
  34738. }
  34739. } else {
  34740. c.ServeSuccessJSON(map[string]interface{}{
  34741. "failed_code": -10,
  34742. "msg": res2.ErrMsg,
  34743. })
  34744. }
  34745. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34746. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  34747. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34748. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34749. resp2, requestErr2 := http.Get(api2)
  34750. if requestErr2 != nil {
  34751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34752. return
  34753. }
  34754. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  34755. if ioErr2 != nil {
  34756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  34757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34758. return
  34759. }
  34760. var respJSON2 map[string]interface{}
  34761. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  34762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34764. return
  34765. }
  34766. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34767. userJSONBytes3, _ := json.Marshal(respJSON2)
  34768. fmt.Println("log")
  34769. fmt.Println(string(userJSONBytes3))
  34770. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34771. utils.ErrorLog("解析失败:%v", err)
  34772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34773. return
  34774. }
  34775. if res2.Infcode == 0 {
  34776. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34777. if err == nil {
  34778. c.ServeSuccessJSON(map[string]interface{}{
  34779. "msg": "撤销明细成功",
  34780. })
  34781. return
  34782. } else {
  34783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34784. return
  34785. }
  34786. } else {
  34787. c.ServeSuccessJSON(map[string]interface{}{
  34788. "failed_code": -10,
  34789. "msg": res2.ErrMsg,
  34790. })
  34791. }
  34792. } else {
  34793. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  34794. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34795. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34796. resp2, requestErr2 := http.Get(api2)
  34797. if requestErr2 != nil {
  34798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34799. return
  34800. }
  34801. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  34802. if ioErr2 != nil {
  34803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  34804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34805. return
  34806. }
  34807. var respJSON2 map[string]interface{}
  34808. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  34809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34811. return
  34812. }
  34813. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34814. userJSONBytes3, _ := json.Marshal(respJSON2)
  34815. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34816. utils.ErrorLog("解析失败:%v", err)
  34817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34818. return
  34819. }
  34820. if res2.Infcode == -1 {
  34821. c.ServeSuccessJSON(map[string]interface{}{
  34822. "failed_code": -10,
  34823. "msg": res2.ErrMsg,
  34824. })
  34825. return
  34826. } else {
  34827. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34828. if err == nil {
  34829. c.ServeSuccessJSON(map[string]interface{}{
  34830. "msg": "撤销明细成功",
  34831. })
  34832. return
  34833. } else {
  34834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34835. return
  34836. }
  34837. }
  34838. }
  34839. } else {
  34840. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34841. if err == nil {
  34842. c.ServeSuccessJSON(map[string]interface{}{
  34843. "msg": "退费成功",
  34844. })
  34845. } else {
  34846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34847. return
  34848. }
  34849. }
  34850. }
  34851. // 对账
  34852. func (c *HisApiController) GetCheckAccount() {
  34853. start_time := c.GetString("start_time")
  34854. end_time := c.GetString("end_time")
  34855. insutype := c.GetString("insutype")
  34856. clr_type := c.GetString("clr_type")
  34857. clr_org := c.GetString("clr_optins")
  34858. admin_user_id, _ := c.GetInt64("admin_user_id")
  34859. adminUser := c.GetAdminUserInfo()
  34860. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34861. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34862. if len(clr_org) == 0 {
  34863. clr_org = miConfig.InsuplcAdmdvs
  34864. }
  34865. timeLayout := "2006-01-02"
  34866. loc, _ := time.LoadLocation("Local")
  34867. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34868. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34869. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34870. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34871. fixmedins_setl_cnt := int64(len(orders))
  34872. var medfee_sumamt float64
  34873. var acct_pay float64
  34874. var fund_pay_sumamt float64
  34875. for _, item := range orders {
  34876. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34877. acct_pay = acct_pay + item.AcctPay
  34878. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  34879. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  34880. } else {
  34881. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34882. }
  34883. }
  34884. var user_name string
  34885. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34886. if role.ID == 0 {
  34887. user_name = "xxx"
  34888. } else {
  34889. user_name = role.UserName
  34890. }
  34891. var res ResultEight
  34892. var res10188 ResultEightFor10188
  34893. if config.IsOpen == 1 {
  34894. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34895. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  34896. "insutype=" + insutype +
  34897. "&clr_type=" + clr_type +
  34898. "&setl_optins=" + clr_org +
  34899. "&stmt_begndate=" + start_time +
  34900. "&stm_enddate=" + end_time +
  34901. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34902. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34903. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34904. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34905. "&fixmedins_code=" + miConfig.Code +
  34906. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34907. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34908. "&secret_key=" + miConfig.SecretKey +
  34909. "&org_name=" + miConfig.OrgName +
  34910. "&doctor=" + user_name +
  34911. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34912. fmt.Println(api)
  34913. resp, requestErr := http.Get(api)
  34914. if requestErr != nil {
  34915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34916. return
  34917. }
  34918. body, ioErr := ioutil.ReadAll(resp.Body)
  34919. fmt.Println(body)
  34920. if ioErr != nil {
  34921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34923. return
  34924. }
  34925. var respJSON map[string]interface{}
  34926. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34929. return
  34930. }
  34931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34932. userJSONBytes, _ := json.Marshal(respJSON)
  34933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34934. utils.ErrorLog("解析失败:%v", err)
  34935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34936. return
  34937. }
  34938. res.InfRefmsgid = res10188.InfRefmsgid
  34939. res.Output = res10188.Output
  34940. res.ErrMsg = res10188.ErrMsg
  34941. res.Cainfo = res10188.Cainfo
  34942. res.WarnMsg = res10188.WarnMsg
  34943. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  34944. res.Infcode = infocode
  34945. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34946. if clr_type != "9903" {
  34947. clr_type = "99" // 就诊 ID(来自2201接口返回)
  34948. }
  34949. if clr_type == "9903" {
  34950. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  34951. }
  34952. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  34953. "insutype=" + insutype +
  34954. "&clr_type=" + clr_type +
  34955. "&setl_optins=" + clr_org +
  34956. "&stmt_begndate=" + start_time +
  34957. "&stm_enddate=" + end_time +
  34958. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34959. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34960. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34961. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34962. "&fixmedins_code=" + miConfig.Code +
  34963. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34964. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34965. "&secret_key=" + miConfig.SecretKey +
  34966. "&org_name=" + miConfig.OrgName +
  34967. "&doctor=" + user_name
  34968. resp, requestErr := http.Get(api)
  34969. if requestErr != nil {
  34970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34971. return
  34972. }
  34973. body, ioErr := ioutil.ReadAll(resp.Body)
  34974. if ioErr != nil {
  34975. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34977. return
  34978. }
  34979. var respJSON map[string]interface{}
  34980. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34983. return
  34984. }
  34985. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34986. result, _ := json.Marshal(respJSON)
  34987. fmt.Println("log")
  34988. fmt.Println(string(result))
  34989. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  34990. utils.ErrorLog("解析失败:%v", err)
  34991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34992. return
  34993. }
  34994. res.InfRefmsgid = res10188.InfRefmsgid
  34995. res.Output = res10188.Output
  34996. res.ErrMsg = res10188.ErrMsg
  34997. res.Cainfo = res10188.Cainfo
  34998. res.WarnMsg = res10188.WarnMsg
  34999. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35000. res.Infcode = infocode
  35001. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35002. var baseParams models.BaseParams
  35003. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35004. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35005. baseParams.SecretKey = miConfig.SecretKey
  35006. baseParams.OrgName = miConfig.OrgName
  35007. baseParams.FixmedinsCode = miConfig.Code
  35008. baseParams.EncKey = miConfig.EncKey
  35009. baseParams.AppSecret = miConfig.AppSecret
  35010. baseParams.SignKey = miConfig.SignKey
  35011. baseParams.AppID = miConfig.Code
  35012. baseParams.Doctor = role.UserName
  35013. baseParams.RequestUrl = miConfig.Url
  35014. businessParams := models.BusinessParams{
  35015. Insutype: insutype,
  35016. ClrType: clr_type,
  35017. SetlOptins: clr_org,
  35018. StmtBegndate: start_time,
  35019. StmtEnddate: end_time,
  35020. MedfeeSumamt: medfee_sumamt,
  35021. FundPaySumamt: fund_pay_sumamt,
  35022. AcctPay: acct_pay,
  35023. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35024. }
  35025. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35026. fmt.Println(requestLog)
  35027. fmt.Println(result)
  35028. fmt.Println(err_msg)
  35029. var dat map[string]interface{}
  35030. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35031. fmt.Println(dat)
  35032. } else {
  35033. fmt.Println(err)
  35034. }
  35035. userJSONBytes, _ := json.Marshal(dat)
  35036. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35037. utils.ErrorLog("解析失败:%v", err)
  35038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35039. return
  35040. }
  35041. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35042. var baseParams models.BaseParams
  35043. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35044. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35045. baseParams.SecretKey = miConfig.SecretKey
  35046. baseParams.OrgName = miConfig.OrgName
  35047. baseParams.FixmedinsCode = miConfig.Code
  35048. baseParams.EncKey = miConfig.EncKey
  35049. baseParams.AppSecret = miConfig.AppSecret
  35050. baseParams.SignKey = miConfig.SignKey
  35051. baseParams.AppID = miConfig.Code
  35052. baseParams.Doctor = role.UserName
  35053. baseParams.RequestUrl = miConfig.Url
  35054. baseParams.AccessKey = miConfig.AccessKey
  35055. businessParams := models.BusinessParams{
  35056. Insutype: insutype,
  35057. ClrType: clr_type,
  35058. SetlOptins: "430822",
  35059. StmtBegndate: start_time,
  35060. StmtEnddate: end_time,
  35061. MedfeeSumamt: medfee_sumamt,
  35062. FundPaySumamt: fund_pay_sumamt,
  35063. AcctPay: acct_pay,
  35064. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35065. }
  35066. 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)
  35067. fmt.Println(requestLog)
  35068. fmt.Println(result)
  35069. var dat map[string]interface{}
  35070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35071. fmt.Println(dat)
  35072. } else {
  35073. fmt.Println(err)
  35074. }
  35075. userJSONBytes, _ := json.Marshal(dat)
  35076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35077. utils.ErrorLog("解析失败:%v", err)
  35078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35079. return
  35080. }
  35081. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35082. var baseParams models.BaseParams
  35083. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35084. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35085. baseParams.SecretKey = miConfig.SecretKey
  35086. baseParams.OrgName = miConfig.OrgName
  35087. baseParams.FixmedinsCode = miConfig.Code
  35088. baseParams.EncKey = miConfig.EncKey
  35089. baseParams.AppSecret = miConfig.AppSecret
  35090. baseParams.SignKey = miConfig.SignKey
  35091. baseParams.AppID = miConfig.Code
  35092. baseParams.Doctor = role.UserName
  35093. baseParams.RequestUrl = miConfig.Url
  35094. businessParams := models.BusinessParams{
  35095. Insutype: insutype,
  35096. ClrType: clr_type,
  35097. SetlOptins: clr_org,
  35098. StmtBegndate: start_time,
  35099. StmtEnddate: end_time,
  35100. MedfeeSumamt: medfee_sumamt,
  35101. FundPaySumamt: fund_pay_sumamt,
  35102. AcctPay: acct_pay,
  35103. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35104. }
  35105. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35106. fmt.Println(requestLog)
  35107. fmt.Println(result)
  35108. fmt.Println(err_msg)
  35109. var dat map[string]interface{}
  35110. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35111. fmt.Println(dat)
  35112. } else {
  35113. fmt.Println(err)
  35114. }
  35115. userJSONBytes, _ := json.Marshal(dat)
  35116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35117. utils.ErrorLog("解析失败:%v", err)
  35118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35119. return
  35120. }
  35121. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35122. if len(clr_type) == 0 {
  35123. clr_type = "11"
  35124. }
  35125. api := miConfig.Url + "gdyb/ten?" +
  35126. "insutype=" + insutype +
  35127. "&clr_type=" + clr_type +
  35128. "&setl_optins=" + clr_org +
  35129. "&stmt_begndate=" + start_time +
  35130. "&stm_enddate=" + end_time +
  35131. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35132. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35133. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35134. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35135. "&fixmedins_code=" + miConfig.Code +
  35136. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35137. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35138. "&secret_key=" + miConfig.SecretKey +
  35139. "&org_name=" + miConfig.OrgName +
  35140. "&doctor=" + user_name
  35141. fmt.Println(api)
  35142. resp, requestErr := http.Get(api)
  35143. if requestErr != nil {
  35144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35145. return
  35146. }
  35147. body, ioErr := ioutil.ReadAll(resp.Body)
  35148. fmt.Println(body)
  35149. if ioErr != nil {
  35150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35152. return
  35153. }
  35154. var respJSON map[string]interface{}
  35155. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35158. return
  35159. }
  35160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35161. userJSONBytes, _ := json.Marshal(respJSON)
  35162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35163. utils.ErrorLog("解析失败:%v", err)
  35164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35165. return
  35166. }
  35167. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35168. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35169. //fixmedins_setl_cnt := int64(len(orders_two))
  35170. //var medfee_sumamt float64
  35171. //var acct_pay float64
  35172. //var fund_pay_sumamt float64
  35173. //for _, item := range orders_two {
  35174. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35175. // acct_pay = acct_pay + item.AcctPay
  35176. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35177. //}
  35178. var baseParams models.BaseParams
  35179. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35180. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35181. baseParams.SecretKey = miConfig.SecretKey
  35182. baseParams.OrgName = miConfig.OrgName
  35183. baseParams.FixmedinsCode = miConfig.Code
  35184. baseParams.EncKey = miConfig.EncKey
  35185. baseParams.AppSecret = miConfig.AppSecret
  35186. baseParams.SignKey = miConfig.SignKey
  35187. baseParams.AppID = miConfig.Code
  35188. baseParams.Doctor = role.UserName
  35189. baseParams.RequestUrl = miConfig.Url
  35190. if clr_type == "9903" {
  35191. clr_type = "9901"
  35192. }
  35193. businessParams := models.BusinessParams{
  35194. Insutype: insutype,
  35195. ClrType: clr_type,
  35196. SetlOptins: "360302",
  35197. StmtBegndate: start_time,
  35198. StmtEnddate: end_time,
  35199. MedfeeSumamt: 0,
  35200. FundPaySumamt: 0,
  35201. AcctPay: 0,
  35202. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35203. }
  35204. 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))
  35205. fmt.Println(requestLog)
  35206. fmt.Println(result)
  35207. var dat map[string]interface{}
  35208. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35209. fmt.Println(dat)
  35210. } else {
  35211. fmt.Println(err)
  35212. }
  35213. userJSONBytes, _ := json.Marshal(dat)
  35214. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35215. utils.ErrorLog("解析失败:%v", err)
  35216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35217. return
  35218. }
  35219. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35220. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35221. //fixmedins_setl_cnt := int64(len(orders_two))
  35222. //var medfee_sumamt float64
  35223. //var acct_pay float64
  35224. //var fund_pay_sumamt float64
  35225. //for _, item := range orders_two {
  35226. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35227. // acct_pay = acct_pay + item.AcctPay
  35228. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35229. //}
  35230. var baseParams models.BaseParams
  35231. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35232. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35233. baseParams.SecretKey = miConfig.SecretKey
  35234. baseParams.OrgName = miConfig.OrgName
  35235. baseParams.FixmedinsCode = miConfig.Code
  35236. baseParams.EncKey = miConfig.EncKey
  35237. baseParams.AppSecret = miConfig.AppSecret
  35238. baseParams.SignKey = miConfig.SignKey
  35239. baseParams.AppID = miConfig.Code
  35240. baseParams.Doctor = role.UserName
  35241. baseParams.RequestUrl = miConfig.Url
  35242. if clr_type == "9903" {
  35243. clr_type = "9994"
  35244. }
  35245. businessParams := models.BusinessParams{
  35246. Insutype: insutype,
  35247. ClrType: clr_type,
  35248. SetlOptins: "361025",
  35249. StmtBegndate: start_time,
  35250. StmtEnddate: end_time,
  35251. MedfeeSumamt: 0,
  35252. FundPaySumamt: 0,
  35253. AcctPay: 0,
  35254. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35255. }
  35256. 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))
  35257. fmt.Println(requestLog)
  35258. fmt.Println(result)
  35259. var dat map[string]interface{}
  35260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35261. fmt.Println(dat)
  35262. } else {
  35263. fmt.Println(err)
  35264. }
  35265. userJSONBytes, _ := json.Marshal(dat)
  35266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35267. utils.ErrorLog("解析失败:%v", err)
  35268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35269. return
  35270. }
  35271. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35272. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35273. //fixmedins_setl_cnt := int64(len(orders_two))
  35274. //var medfee_sumamt float64
  35275. //var acct_pay float64
  35276. //var fund_pay_sumamt float64
  35277. //for _, item := range orders_two {
  35278. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35279. // acct_pay = acct_pay + item.AcctPay
  35280. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35281. //}
  35282. var baseParams models.BaseParams
  35283. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35284. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35285. baseParams.SecretKey = miConfig.SecretKey
  35286. baseParams.OrgName = miConfig.OrgName
  35287. baseParams.FixmedinsCode = miConfig.Code
  35288. baseParams.EncKey = miConfig.EncKey
  35289. baseParams.AppSecret = miConfig.AppSecret
  35290. baseParams.SignKey = miConfig.SignKey
  35291. baseParams.AppID = miConfig.Code
  35292. baseParams.Doctor = role.UserName
  35293. baseParams.RequestUrl = miConfig.Url
  35294. if clr_type == "9903" {
  35295. clr_type = "9994"
  35296. }
  35297. businessParams := models.BusinessParams{
  35298. Insutype: insutype,
  35299. ClrType: clr_type,
  35300. SetlOptins: "360100",
  35301. StmtBegndate: start_time,
  35302. StmtEnddate: end_time,
  35303. MedfeeSumamt: 0,
  35304. FundPaySumamt: 0,
  35305. AcctPay: 0,
  35306. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35307. }
  35308. 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))
  35309. fmt.Println(requestLog)
  35310. fmt.Println(result)
  35311. var dat map[string]interface{}
  35312. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35313. fmt.Println(dat)
  35314. } else {
  35315. fmt.Println(err)
  35316. }
  35317. userJSONBytes, _ := json.Marshal(dat)
  35318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35319. utils.ErrorLog("解析失败:%v", err)
  35320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35321. return
  35322. }
  35323. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35324. var api string
  35325. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35326. "&clr_type=" + clr_type +
  35327. "&setl_optins=" + clr_org +
  35328. "&stmt_begndate=" + start_time +
  35329. "&stm_enddate=" + end_time +
  35330. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35331. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35332. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35333. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35334. "&fixmedins_code=" + miConfig.Code +
  35335. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35336. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35337. "&secret_key=" + miConfig.SecretKey +
  35338. "&org_name=" + miConfig.OrgName +
  35339. "&doctor=" + user_name + "&url=" + miConfig.Url
  35340. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35341. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35342. resp, requestErr := http.Get(api)
  35343. if requestErr != nil {
  35344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35345. return
  35346. }
  35347. body, ioErr := ioutil.ReadAll(resp.Body)
  35348. if ioErr != nil {
  35349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35351. return
  35352. }
  35353. var respJSON map[string]interface{}
  35354. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35357. return
  35358. }
  35359. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35360. if status == "0" {
  35361. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35362. c.ServeSuccessJSON(map[string]interface{}{
  35363. "failed_code": -10,
  35364. "msg": err_msg,
  35365. })
  35366. return
  35367. }
  35368. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35369. userJSONBytes, _ := json.Marshal(respJSON)
  35370. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35371. utils.ErrorLog("解析失败:%v", err)
  35372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35373. return
  35374. }
  35375. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35376. var api string
  35377. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35378. "&clr_type=" + clr_type +
  35379. "&setl_optins=" + clr_org +
  35380. "&stmt_begndate=" + start_time +
  35381. "&stm_enddate=" + end_time +
  35382. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35383. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35384. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35385. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35386. "&fixmedins_code=" + miConfig.Code +
  35387. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35388. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35389. "&secret_key=" + miConfig.SecretKey +
  35390. "&org_name=" + miConfig.OrgName +
  35391. "&doctor=" + user_name + "&url=" + miConfig.Url
  35392. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35393. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35394. resp, requestErr := http.Get(api)
  35395. if requestErr != nil {
  35396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35397. return
  35398. }
  35399. body, ioErr := ioutil.ReadAll(resp.Body)
  35400. if ioErr != nil {
  35401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35403. return
  35404. }
  35405. var respJSON map[string]interface{}
  35406. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35409. return
  35410. }
  35411. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35412. if status == "0" {
  35413. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35414. c.ServeSuccessJSON(map[string]interface{}{
  35415. "failed_code": -10,
  35416. "msg": err_msg,
  35417. })
  35418. return
  35419. }
  35420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35421. userJSONBytes, _ := json.Marshal(respJSON)
  35422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35423. utils.ErrorLog("解析失败:%v", err)
  35424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35425. return
  35426. }
  35427. } else {
  35428. if len(clr_type) == 0 {
  35429. clr_type = "11"
  35430. }
  35431. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35432. "insutype=" + insutype +
  35433. "&clr_type=" + clr_type +
  35434. "&setl_optins=" + clr_org +
  35435. "&stmt_begndate=" + start_time +
  35436. "&stm_enddate=" + end_time +
  35437. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35438. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35439. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35440. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35441. "&fixmedins_code=" + miConfig.Code +
  35442. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35443. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35444. "&secret_key=" + miConfig.SecretKey +
  35445. "&org_name=" + miConfig.OrgName +
  35446. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35447. fmt.Println(api)
  35448. resp, requestErr := http.Get(api)
  35449. if requestErr != nil {
  35450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35451. return
  35452. }
  35453. body, ioErr := ioutil.ReadAll(resp.Body)
  35454. fmt.Println(body)
  35455. if ioErr != nil {
  35456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35458. return
  35459. }
  35460. var respJSON map[string]interface{}
  35461. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35464. return
  35465. }
  35466. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35467. userJSONBytes, _ := json.Marshal(respJSON)
  35468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35469. utils.ErrorLog("解析失败:%v", err)
  35470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35471. return
  35472. }
  35473. }
  35474. if res.Infcode == 0 {
  35475. if res.Output.Stmtinfo.StmtRslt == "0" {
  35476. micc := &models.MedicalInsuranceCostCompare{
  35477. StartTime: startime.Unix(),
  35478. EndTime: endtime.Unix(),
  35479. Insutype: insutype,
  35480. CheckType: 1,
  35481. Num: fixmedins_setl_cnt,
  35482. Mtime: time.Now().Unix(),
  35483. Status: 1,
  35484. UserOrgId: adminUser.CurrentOrgId,
  35485. CostTotal: medfee_sumamt,
  35486. FuncTotal: fund_pay_sumamt,
  35487. PsnPay: acct_pay,
  35488. Creator: admin_user_id,
  35489. Ctime: time.Now().Unix(),
  35490. ClrType: clr_type,
  35491. }
  35492. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  35493. if err == nil {
  35494. c.ServeSuccessJSON(map[string]interface{}{
  35495. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35496. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35497. })
  35498. } else {
  35499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35500. }
  35501. } else {
  35502. c.ServeSuccessJSON(map[string]interface{}{
  35503. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35504. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35505. })
  35506. }
  35507. } else {
  35508. c.ServeSuccessJSON(map[string]interface{}{
  35509. "failed_code": -10,
  35510. "msg": res.ErrMsg,
  35511. })
  35512. }
  35513. }
  35514. }
  35515. func (c *HisApiController) Check310() {
  35516. adminUser := c.GetAdminUserInfo()
  35517. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35518. var user_name string
  35519. user_name = "高慧裕"
  35520. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35521. "insutype=" + "310" +
  35522. "&clr_type=" + "" +
  35523. "&setl_optins=" + "441202" +
  35524. "&stmt_begndate=" + "2022-03-01" +
  35525. "&stm_enddate=" + "2022-03-31" +
  35526. "&medfee_sumamt=" + "194930.12" +
  35527. "&fund_pay_sumamt=" + "188741.46" +
  35528. "&acct_pay=" + "0" +
  35529. "&fixmedins_setl_cnt=" + "452" +
  35530. "&fixmedins_code=" + miConfig.Code +
  35531. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35532. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35533. "&secret_key=" + miConfig.SecretKey +
  35534. "&org_name=" + miConfig.OrgName +
  35535. "&doctor=" + user_name
  35536. fmt.Println(api)
  35537. resp, requestErr := http.Get(api)
  35538. if requestErr != nil {
  35539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35540. return
  35541. }
  35542. body, ioErr := ioutil.ReadAll(resp.Body)
  35543. fmt.Println(body)
  35544. if ioErr != nil {
  35545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35547. return
  35548. }
  35549. var respJSON map[string]interface{}
  35550. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35553. return
  35554. }
  35555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35556. userJSONBytes, _ := json.Marshal(respJSON)
  35557. var res ResultEight
  35558. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35559. utils.ErrorLog("解析失败:%v", err)
  35560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35561. return
  35562. }
  35563. }
  35564. func (c *HisApiController) Check390() {
  35565. adminUser := c.GetAdminUserInfo()
  35566. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35567. var user_name string
  35568. user_name = "高慧裕"
  35569. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35570. "insutype=" + "390" +
  35571. "&clr_type=" + "" +
  35572. "&setl_optins=" + "441202" +
  35573. "&stmt_begndate=" + "2022-03-01" +
  35574. "&stm_enddate=" + "2022-03-31" +
  35575. "&medfee_sumamt=" + "1068448.89" +
  35576. "&fund_pay_sumamt=" + "1014677.62" +
  35577. "&acct_pay=" + "0" +
  35578. "&fixmedins_setl_cnt=" + "1950" +
  35579. "&fixmedins_code=" + miConfig.Code +
  35580. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35581. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35582. "&secret_key=" + miConfig.SecretKey +
  35583. "&org_name=" + miConfig.OrgName +
  35584. "&doctor=" + user_name
  35585. fmt.Println(api)
  35586. resp, requestErr := http.Get(api)
  35587. if requestErr != nil {
  35588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35589. return
  35590. }
  35591. body, ioErr := ioutil.ReadAll(resp.Body)
  35592. fmt.Println(body)
  35593. if ioErr != nil {
  35594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35596. return
  35597. }
  35598. var respJSON map[string]interface{}
  35599. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35602. return
  35603. }
  35604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35605. userJSONBytes, _ := json.Marshal(respJSON)
  35606. var res ResultEight
  35607. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35608. utils.ErrorLog("解析失败:%v", err)
  35609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35610. return
  35611. }
  35612. }
  35613. // 对账明细
  35614. func (c *HisApiController) GetCheckDetailAccount() {
  35615. start_time := c.GetString("start_time")
  35616. end_time := c.GetString("end_time")
  35617. admin_user_id, _ := c.GetInt64("admin_user_id")
  35618. adminUser := c.GetAdminUserInfo()
  35619. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35620. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35621. timeLayout := "2006-01-02"
  35622. loc, _ := time.LoadLocation("Local")
  35623. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35624. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35625. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35626. rand.Seed(time.Now().UnixNano())
  35627. num := rand.Intn(30000)
  35628. Mkdir(miConfig.OrgName)
  35629. file := strconv.FormatInt(int64(num), 10)
  35630. file_name := file + ".txt"
  35631. zip_name := file + ".zip"
  35632. zip_path := miConfig.OrgName + "/" + zip_name
  35633. file_path := miConfig.OrgName + "/" + file_name
  35634. decimal.DivisionPrecision = 2
  35635. var medfee_sumamt float64
  35636. var psn_cash_pay float64
  35637. var fund_pay_sumamt float64
  35638. fixmedins_setl_cnt := int64(len(orders))
  35639. for _, item := range orders {
  35640. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35641. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  35642. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35643. }
  35644. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  35645. defer f.Close()
  35646. if err != nil {
  35647. fmt.Println(err.Error())
  35648. } else {
  35649. for _, item := range orders {
  35650. var refd_setl_flag string
  35651. if item.OrderStatus == 2 {
  35652. refd_setl_flag = "0"
  35653. var str string
  35654. str = item.SetlId + " " +
  35655. item.MdtrtId + " " +
  35656. item.PsnNo + " " +
  35657. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35658. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35659. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  35660. _, err = f.Write([]byte(str))
  35661. }
  35662. if item.OrderStatus == 3 {
  35663. var str string
  35664. str = item.SetlId + " " +
  35665. item.MdtrtId + " " +
  35666. item.PsnNo + " " +
  35667. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35668. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35669. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  35670. _, err = f.Write([]byte(str))
  35671. var str2 string
  35672. str2 = item.SetlId + " " +
  35673. item.MdtrtId + " " +
  35674. item.PsnNo + " " +
  35675. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  35676. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  35677. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  35678. _, err = f.Write([]byte(str2))
  35679. }
  35680. }
  35681. }
  35682. Zip(file_path, zip_path)
  35683. fmt.Println(ReadFile(zip_path))
  35684. fmt.Println(string(ReadFile(zip_path)))
  35685. if config.IsOpen == 1 {
  35686. var user_name string
  35687. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35688. if role.ID == 0 {
  35689. user_name = "管理员"
  35690. } else {
  35691. user_name = role.UserName
  35692. }
  35693. baseParams := models.BaseParams{
  35694. SecretKey: miConfig.SecretKey,
  35695. FixmedinsCode: miConfig.Code,
  35696. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35697. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35698. OrgName: miConfig.OrgName,
  35699. Doctor: user_name,
  35700. }
  35701. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  35702. var dat map[string]interface{}
  35703. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35704. fmt.Println(dat)
  35705. } else {
  35706. fmt.Println(err)
  35707. }
  35708. userJSONBytes, _ := json.Marshal(dat)
  35709. var res ResultNine
  35710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35711. utils.ErrorLog("解析失败:%v", err)
  35712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35713. return
  35714. }
  35715. if res.Infcode == 0 {
  35716. fileNo := res.Output.FileQuryNo
  35717. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  35718. "file_qury_no=" + fileNo +
  35719. "&setl_optins=" + "定点医保中心" +
  35720. "&stmt_begndate=" + start_time +
  35721. "&stm_enddate=" + end_time +
  35722. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35723. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35724. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  35725. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35726. "&fixmedins_code=" + miConfig.Code +
  35727. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35728. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35729. "&secret_key=" + miConfig.SecretKey +
  35730. "&org_name=" + miConfig.OrgName +
  35731. "&doctor=" + user_name
  35732. resp, requestErr := http.Get(api)
  35733. if requestErr != nil {
  35734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35735. return
  35736. }
  35737. body, ioErr := ioutil.ReadAll(resp.Body)
  35738. if ioErr != nil {
  35739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35741. return
  35742. }
  35743. var respJSON map[string]interface{}
  35744. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35747. return
  35748. }
  35749. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35750. userJSONBytes, _ := json.Marshal(respJSON)
  35751. var res ResultTen
  35752. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35753. utils.ErrorLog("解析失败:%v", err)
  35754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35755. return
  35756. }
  35757. if res.Infcode == 0 {
  35758. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  35759. micc := &models.MedicalInsuranceCostCompare{
  35760. StartTime: startime.Unix(),
  35761. EndTime: endtime.Unix(),
  35762. Insutype: "0",
  35763. CheckType: 2,
  35764. Num: fixmedins_setl_cnt,
  35765. Mtime: time.Now().Unix(),
  35766. Status: 1,
  35767. UserOrgId: adminUser.CurrentOrgId,
  35768. CostTotal: medfee_sumamt,
  35769. FuncTotal: fund_pay_sumamt,
  35770. PsnPay: psn_cash_pay,
  35771. Creator: admin_user_id,
  35772. Ctime: time.Now().Unix(),
  35773. }
  35774. service.CreateMedicalInsuranceCostCompareRecord(micc)
  35775. c.ServeSuccessJSON(map[string]interface{}{
  35776. "msg": "明细对账成功",
  35777. })
  35778. }
  35779. } else {
  35780. }
  35781. }
  35782. }
  35783. type CustomOrderInfo struct {
  35784. Name string
  35785. Spec string
  35786. Unit string
  35787. Count float64
  35788. Price float64
  35789. Total float64
  35790. }
  35791. func (c *HisApiController) GetBatchSettleAccounts() {
  35792. admin_user_id, _ := c.GetInt64("admin_user_id")
  35793. order_ids := c.GetString("order_ids")
  35794. order_ids_arr := strings.Split(order_ids, ",")
  35795. data3 := []map[string]interface{}{}
  35796. for _, item := range order_ids_arr {
  35797. id, _ := strconv.ParseInt(item, 10, 64)
  35798. order_id := id
  35799. adminUser := c.GetAdminUserInfo()
  35800. order, _ := service.GetHisOrderByID(order_id)
  35801. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35802. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  35803. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  35804. orderInfos = append(orderInfos, orderInfos_two...)
  35805. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  35806. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  35807. var diagnosis_ids []string
  35808. if his.ID > 0 {
  35809. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  35810. } else {
  35811. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  35812. }
  35813. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  35814. var dia_config []*models.HisXtDiagnoseConfig
  35815. var name string
  35816. for _, item := range diagnosis_ids {
  35817. id, _ := strconv.ParseInt(item, 10, 64)
  35818. diagnosisConfig, _ := service.FindDiagnoseById(id)
  35819. dia_config = append(dia_config, &diagnosisConfig)
  35820. if len(name) == 0 {
  35821. name = diagnosisConfig.ClassName
  35822. }
  35823. //} else {
  35824. // name = name + "," + diagnosisConfig.ClassName
  35825. //}
  35826. }
  35827. var bedCostTotal float64 = 0 //床位总费
  35828. var bedCostSelfTotal float64 = 0 //床位自费
  35829. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  35830. var bedSelfTotal float64 = 0 //床位部分项目自费
  35831. var bedInscpTotal float64 = 0 //床位部分项目自费
  35832. var operationCostTotal float64 = 0 //手术费
  35833. var operationCostSelfTotal float64 = 0 //手术费
  35834. var operationCostPartSelfTotal float64 = 0 //手术费
  35835. var operationSelfTotal float64 = 0 //床位部分项目自费
  35836. var operationInscpTotal float64 = 0 //床位部分项目自费
  35837. var otherCostTotal float64 = 0 //其他费用
  35838. var otherCostSelfTotal float64 = 0 //其他费用
  35839. var otherCostPartSelfTotal float64 = 0 //其他费用
  35840. var otherSelfTotal float64 = 0 //床位部分项目自费
  35841. var otherInscpTotal float64 = 0 //床位部分项目自费
  35842. var materialCostTotal float64 = 0 //材料费
  35843. var materialCostSelfTotal float64 = 0 //材料费
  35844. var materialCostPartSelfTotal float64 = 0 //材料费
  35845. var materialSelfTotal float64 = 0 //床位部分项目自费
  35846. var materialInscpTotal float64 = 0 //床位部分项目自费
  35847. var westernMedicineCostTotal float64 = 0 //西药费
  35848. var westernMedicineCostSelfTotal float64 = 0 //西药费
  35849. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  35850. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  35851. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  35852. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  35853. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  35854. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  35855. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  35856. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  35857. var checkCostTotal float64 = 0 //检查费
  35858. var checkCostSelfTotal float64 = 0 //检查费
  35859. var checkCostPartSelfTotal float64 = 0 //检查费
  35860. var checkSelfTotal float64 = 0 //床位部分项目自费
  35861. var checkInscpTotal float64 = 0 //床位部分项目自费
  35862. var laboratoryCostTotal float64 = 0 //化验费
  35863. var laboratoryCostSelfTotal float64 = 0 //化验费
  35864. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  35865. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  35866. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  35867. var treatCostTotal float64 = 0 //治疗费用
  35868. var treatCostSelfTotal float64 = 0 //治疗费用
  35869. var treatCostPartSelfTotal float64 = 0 //治疗费用
  35870. var treatSelfTotal float64 = 0 //床位部分项目自费
  35871. var treatInscpTotal float64 = 0 //床位部分项目自费
  35872. decimal.DivisionPrecision = 2
  35873. for _, item := range orderInfos {
  35874. if item.MedChrgitmType == "01" { //床位费
  35875. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35876. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35877. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35878. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35879. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35880. }
  35881. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  35882. if item.MedChrgitmType == "03" { //检查费
  35883. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35884. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35885. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35886. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35887. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35888. }
  35889. } else {
  35890. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  35891. fmt.Println("------------")
  35892. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35893. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35894. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35895. }
  35896. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  35897. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35898. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35899. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35900. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35901. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35902. }
  35903. }
  35904. if item.MedChrgitmType == "04" { //化验费
  35905. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35906. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35907. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35908. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35909. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35910. }
  35911. if item.MedChrgitmType == "05" { //治疗费
  35912. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35913. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35914. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35915. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35916. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35917. }
  35918. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  35919. fmt.Println("------------")
  35920. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35921. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35922. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35923. }
  35924. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  35925. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35926. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35927. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35928. }
  35929. //if item.MedChrgitmType == "06" { //手术费
  35930. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35931. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35932. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35933. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35934. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35935. //
  35936. //}
  35937. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  35938. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35939. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35940. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35941. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35942. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35943. }
  35944. if item.MedChrgitmType == "09" { //西药费
  35945. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35946. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35947. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35948. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35949. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35950. }
  35951. if item.MedChrgitmType == "11" { //中成费
  35952. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35953. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35954. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35955. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35956. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35957. }
  35958. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  35959. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35960. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35961. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35962. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35963. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35964. }
  35965. }
  35966. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35967. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35968. var user_name string
  35969. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35970. if role.ID == 0 {
  35971. user_name = "管理员"
  35972. } else {
  35973. user_name = role.UserName
  35974. }
  35975. baseParams := models.BaseParams{
  35976. SecretKey: miConfig.SecretKey,
  35977. FixmedinsCode: miConfig.Code,
  35978. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35979. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35980. OrgName: miConfig.OrgName,
  35981. Doctor: user_name,
  35982. RequestUrl: miConfig.Url,
  35983. AccessKey: miConfig.AccessKey,
  35984. }
  35985. businessParams := models.BusinessParams{
  35986. PsnNo: order.PsnNo,
  35987. MdtrtId: order.MdtrtId,
  35988. SetlId: order.SetlId,
  35989. }
  35990. var res ResultEleven
  35991. var resEleven10265 ResultEleven10265
  35992. if config.IsOpen == 1 {
  35993. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35994. result := service.Gdyb5203(baseParams, businessParams)
  35995. service.Gdyb5204(baseParams, businessParams)
  35996. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35997. var dat map[string]interface{}
  35998. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35999. fmt.Println(dat)
  36000. } else {
  36001. fmt.Println(err)
  36002. }
  36003. userJSONBytes, _ := json.Marshal(dat)
  36004. if miConfig.Code == "H15049901371" {
  36005. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36006. utils.ErrorLog("解析失败:%v", err)
  36007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36008. return
  36009. }
  36010. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36011. res.Output = resEleven10265.Output
  36012. res.ErrMsg = resEleven10265.ErrMsg
  36013. res.Cainfo = resEleven10265.Cainfo
  36014. res.WarnMsg = resEleven10265.WarnMsg
  36015. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36016. res.Infcode = infocode
  36017. } else {
  36018. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36019. utils.ErrorLog("解析失败:%v", err)
  36020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36021. return
  36022. }
  36023. }
  36024. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36025. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36026. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36027. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36028. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36029. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36030. var doctor_name string
  36031. if roles.ID == 0 {
  36032. doctor_name = "管理员"
  36033. } else {
  36034. doctor_name = roles.UserName
  36035. }
  36036. yiliao_leibie := ""
  36037. switch order.MedType {
  36038. case "11":
  36039. yiliao_leibie = "普通门诊"
  36040. break
  36041. case "12":
  36042. yiliao_leibie = "门诊挂号"
  36043. break
  36044. case "13":
  36045. yiliao_leibie = "急诊"
  36046. break
  36047. case "14":
  36048. yiliao_leibie = "门诊特殊病"
  36049. break
  36050. case "15":
  36051. yiliao_leibie = "门诊统筹"
  36052. break
  36053. case "16":
  36054. yiliao_leibie = "门诊慢性病"
  36055. break
  36056. case "21":
  36057. yiliao_leibie = "普通住院"
  36058. break
  36059. }
  36060. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36061. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  36062. if res.Infcode == 0 {
  36063. data2 := map[string]interface{}{
  36064. "diagnosis": name,
  36065. "order_infos": orderInfos,
  36066. "number": order.MdtrtId,
  36067. "date": order.SettleAccountsDate,
  36068. "charge_admin": charge_admin,
  36069. "printor_admin": printor_admin,
  36070. "info": res.Output.Setlinfo,
  36071. "order": order,
  36072. "bedCostTotal": bedCostTotal,
  36073. "bedCostSelfTotal": bedCostSelfTotal,
  36074. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36075. "bedSelfTotal": bedSelfTotal,
  36076. "bedInscpTotal": bedInscpTotal,
  36077. "operationCostTotal": operationCostTotal,
  36078. "operationCostSelfTotal": operationCostSelfTotal,
  36079. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36080. "operationSelfTotal": operationSelfTotal,
  36081. "operationInscpTotal": operationInscpTotal,
  36082. "otherCostTotal": otherCostTotal,
  36083. "otherCostSelfTotal": otherCostSelfTotal,
  36084. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36085. "otherSelfTotal": otherSelfTotal,
  36086. "otherInscpTotal": otherInscpTotal,
  36087. "materialCostTotal": materialCostTotal,
  36088. "materialCostSelfTotal": materialCostSelfTotal,
  36089. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36090. "materialSelfTotal": materialSelfTotal,
  36091. "materialInscpTotal": materialInscpTotal,
  36092. "westernMedicineCostTotal": westernMedicineCostTotal,
  36093. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36094. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36095. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36096. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36097. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36098. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36099. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36100. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36101. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36102. "checkCostTotal": checkCostTotal,
  36103. "checkCostSelfTotal": checkCostSelfTotal,
  36104. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36105. "checkSelfTotal": checkSelfTotal,
  36106. "checkInscpTotal": checkInscpTotal,
  36107. "laboratoryCostTotal": laboratoryCostTotal,
  36108. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36109. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36110. "laboratorySelfTotal": laboratorySelfTotal,
  36111. "laboratoryInscpTotal": laboratoryInscpTotal,
  36112. "treatCostTotal": treatCostTotal,
  36113. "treatCostSelfTotal": treatCostSelfTotal,
  36114. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36115. "treatSelfTotal": treatSelfTotal,
  36116. "treatInscpTotal": treatInscpTotal,
  36117. "doctor_info": doctor_info,
  36118. "doctor_code": adminRole_two.DoctorCode,
  36119. "doctor_name": doctor_name,
  36120. "health_card_no": order.PsnNo,
  36121. "department": departments.Name,
  36122. "yiliao_leibie": yiliao_leibie,
  36123. "after_money": order.AccountPrice,
  36124. "patient": patient,
  36125. "org_name": miConfig.OrgName,
  36126. "org_code": miConfig.Code,
  36127. "order_number": order.Number,
  36128. "his_hospital": his_hospital,
  36129. "his": his,
  36130. "dia_config": dia_config,
  36131. "psn_cash_pay": order.PsnCashPay,
  36132. //"check_order_info": cus_slice,
  36133. }
  36134. data3 = append(data3, data2)
  36135. }
  36136. }
  36137. }
  36138. c.ServeSuccessJSON(map[string]interface{}{
  36139. "infos": data3,
  36140. })
  36141. }
  36142. func (c *HisApiController) GetSettleAccounts() {
  36143. //id, _ := c.GetInt64("id")
  36144. //record_time := c.GetString("record_time")
  36145. order_id, _ := c.GetInt64("order_id")
  36146. admin_user_id, _ := c.GetInt64("admin_user_id")
  36147. //timeLayout := "2006-01-02"
  36148. //loc, _ := time.LoadLocation("Local")
  36149. //
  36150. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36151. //if err != nil {
  36152. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36153. // return
  36154. //}Hbyb5203
  36155. //recordDateTime := theTime.Unix()
  36156. adminUser := c.GetAdminUserInfo()
  36157. order, _ := service.GetHisOrderByID(order_id)
  36158. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36159. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36160. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36161. orderInfos = append(orderInfos, orderInfos_two...)
  36162. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36163. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36164. var diagnosis_ids []string
  36165. if his.ID > 0 {
  36166. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36167. } else {
  36168. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36169. }
  36170. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36171. var dia_config []*models.HisXtDiagnoseConfig
  36172. var name string
  36173. for _, item := range diagnosis_ids {
  36174. id, _ := strconv.ParseInt(item, 10, 64)
  36175. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36176. dia_config = append(dia_config, &diagnosisConfig)
  36177. if len(name) == 0 {
  36178. name = diagnosisConfig.ClassName
  36179. } else {
  36180. name = name + "," + diagnosisConfig.ClassName
  36181. }
  36182. }
  36183. if patient.UserOrgId == 10215 {
  36184. name = "慢性肾功能不全(血透治疗)"
  36185. }
  36186. var bedCostTotal float64 = 0 //床位总费
  36187. var bedCostSelfTotal float64 = 0 //床位自费
  36188. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36189. var bedSelfTotal float64 = 0 //床位部分项目自费
  36190. var bedInscpTotal float64 = 0 //床位部分项目自费
  36191. var operationCostTotal float64 = 0 //手术费
  36192. var operationCostSelfTotal float64 = 0 //手术费
  36193. var operationCostPartSelfTotal float64 = 0 //手术费
  36194. var operationSelfTotal float64 = 0 //床位部分项目自费
  36195. var operationInscpTotal float64 = 0 //床位部分项目自费
  36196. var otherCostTotal float64 = 0 //其他费用
  36197. var otherCostSelfTotal float64 = 0 //其他费用
  36198. var otherCostPartSelfTotal float64 = 0 //其他费用
  36199. var otherSelfTotal float64 = 0 //床位部分项目自费
  36200. var otherInscpTotal float64 = 0 //床位部分项目自费
  36201. var materialCostTotal float64 = 0 //材料费
  36202. var materialCostSelfTotal float64 = 0 //材料费
  36203. var materialCostPartSelfTotal float64 = 0 //材料费
  36204. var materialSelfTotal float64 = 0 //床位部分项目自费
  36205. var materialInscpTotal float64 = 0 //床位部分项目自费
  36206. var westernMedicineCostTotal float64 = 0 //西药费
  36207. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36208. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36209. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36210. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36211. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36212. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36213. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36214. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36215. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36216. var checkCostTotal float64 = 0 //检查费
  36217. var checkCostSelfTotal float64 = 0 //检查费
  36218. var checkCostPartSelfTotal float64 = 0 //检查费
  36219. var checkSelfTotal float64 = 0 //床位部分项目自费
  36220. var checkInscpTotal float64 = 0 //床位部分项目自费
  36221. var laboratoryCostTotal float64 = 0 //化验费
  36222. var laboratoryCostSelfTotal float64 = 0 //化验费
  36223. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36224. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36225. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36226. var treatCostTotal float64 = 0 //治疗费用
  36227. var treatCostSelfTotal float64 = 0 //治疗费用
  36228. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36229. var treatSelfTotal float64 = 0 //床位部分项目自费
  36230. var treatInscpTotal float64 = 0 //床位部分项目自费
  36231. var zcCostTotal float64 = 0 //治疗费用
  36232. var zcCostSelfTotal float64 = 0 //治疗费用
  36233. var zcCostPartSelfTotal float64 = 0 //治疗费用
  36234. var zcSelfTotal float64 = 0 //床位部分项目自费
  36235. var zcInscpTotal float64 = 0 //床位部分项目自费
  36236. var huliCostTotal float64 = 0 //治疗费用
  36237. var huliCostSelfTotal float64 = 0 //治疗费用
  36238. var huliCostPartSelfTotal float64 = 0 //治疗费用
  36239. var huliSelfTotal float64 = 0 //床位部分项目自费
  36240. var huliInscpTotal float64 = 0 //床位部分项目自费
  36241. decimal.DivisionPrecision = 2
  36242. for _, item := range orderInfos {
  36243. if item.MedChrgitmType == "01" { //床位费
  36244. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36245. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36246. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36247. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36248. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36249. }
  36250. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36251. if item.MedChrgitmType == "03" { //检查费
  36252. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36253. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36254. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36255. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36256. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36257. }
  36258. } else {
  36259. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36260. fmt.Println("------------")
  36261. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36262. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36263. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36264. }
  36265. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36266. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36267. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36268. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36269. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36270. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36271. }
  36272. }
  36273. if item.MedChrgitmType == "04" { //化验费
  36274. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36275. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36276. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36277. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36278. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36279. }
  36280. if item.MedChrgitmType == "05" { //治疗费
  36281. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36282. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36283. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36284. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36285. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36286. }
  36287. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36288. fmt.Println("------------")
  36289. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36290. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36291. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36292. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36293. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36294. }
  36295. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36296. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36297. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36298. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36299. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36300. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36301. }
  36302. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36303. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36304. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36305. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36306. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36307. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36308. }
  36309. if item.MedChrgitmType == "09" { //西药费
  36310. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36311. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36312. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36313. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36314. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36315. }
  36316. if item.MedChrgitmType == "11" { //中成费
  36317. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36318. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36319. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36320. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36321. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36322. }
  36323. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  36324. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36325. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36326. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36327. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36328. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36329. }
  36330. if item.MedChrgitmType == "02" { //其他费
  36331. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36332. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36333. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36334. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36335. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36336. }
  36337. if item.MedChrgitmType == "07" { //其他费
  36338. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36339. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36340. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36341. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36342. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36343. }
  36344. }
  36345. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36346. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36347. var user_name string
  36348. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36349. if role.ID == 0 {
  36350. user_name = "管理员"
  36351. } else {
  36352. user_name = role.UserName
  36353. }
  36354. baseParams := models.BaseParams{
  36355. SecretKey: miConfig.SecretKey,
  36356. FixmedinsCode: miConfig.Code,
  36357. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36358. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36359. OrgName: miConfig.OrgName,
  36360. Doctor: user_name,
  36361. RequestUrl: miConfig.Url,
  36362. AccessKey: miConfig.AccessKey,
  36363. }
  36364. businessParams := models.BusinessParams{
  36365. PsnNo: order.PsnNo,
  36366. MdtrtId: order.MdtrtId,
  36367. SetlId: order.SetlId,
  36368. }
  36369. var res ResultEleven
  36370. var resah ResultElevenah
  36371. var resEleven10265 ResultEleven10265
  36372. if config.IsOpen == 1 {
  36373. if miConfig.MdtrtareaAdmvs == "421300" {
  36374. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36375. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36376. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36377. resp, requestErr := http.Get(api)
  36378. if requestErr != nil {
  36379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36380. return
  36381. }
  36382. body, ioErr := ioutil.ReadAll(resp.Body)
  36383. if ioErr != nil {
  36384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36386. return
  36387. }
  36388. var respJSON map[string]interface{}
  36389. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36392. return
  36393. }
  36394. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36395. result, _ := json.Marshal(respJSON)
  36396. fmt.Println("log")
  36397. fmt.Println(string(result))
  36398. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36399. utils.ErrorLog("解析失败:%v", err)
  36400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36401. return
  36402. }
  36403. } else if miConfig.MdtrtareaAdmvs == "420200" {
  36404. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36405. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36406. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36407. resp, requestErr := http.Get(api)
  36408. if requestErr != nil {
  36409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36410. return
  36411. }
  36412. body, ioErr := ioutil.ReadAll(resp.Body)
  36413. if ioErr != nil {
  36414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36416. return
  36417. }
  36418. var respJSON map[string]interface{}
  36419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36422. return
  36423. }
  36424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36425. result, _ := json.Marshal(respJSON)
  36426. fmt.Println("log")
  36427. fmt.Println(string(result))
  36428. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36429. utils.ErrorLog("解析失败:%v", err)
  36430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36431. return
  36432. }
  36433. } else if miConfig.MdtrtareaAdmvs == "420902" {
  36434. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36435. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36436. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36437. resp, requestErr := http.Get(api)
  36438. if requestErr != nil {
  36439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36440. return
  36441. }
  36442. body, ioErr := ioutil.ReadAll(resp.Body)
  36443. if ioErr != nil {
  36444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36446. return
  36447. }
  36448. var respJSON map[string]interface{}
  36449. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36452. return
  36453. }
  36454. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36455. result, _ := json.Marshal(respJSON)
  36456. fmt.Println("log")
  36457. fmt.Println(string(result))
  36458. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36459. utils.ErrorLog("解析失败:%v", err)
  36460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36461. return
  36462. }
  36463. } else if miConfig.MdtrtareaAdmvs == "421182" {
  36464. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36465. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36466. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  36467. resp, requestErr := http.Get(api)
  36468. if requestErr != nil {
  36469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36470. return
  36471. }
  36472. body, ioErr := ioutil.ReadAll(resp.Body)
  36473. if ioErr != nil {
  36474. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36476. return
  36477. }
  36478. var respJSON map[string]interface{}
  36479. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36482. return
  36483. }
  36484. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36485. result, _ := json.Marshal(respJSON)
  36486. fmt.Println("log")
  36487. fmt.Println(string(result))
  36488. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36489. utils.ErrorLog("解析失败:%v", err)
  36490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36491. return
  36492. }
  36493. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  36494. var api string
  36495. if miConfig.MdtrtareaAdmvs == "320830" {
  36496. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36497. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36498. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36499. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36500. } else if miConfig.MdtrtareaAdmvs == "320921" {
  36501. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36502. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36503. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36504. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36505. } else {
  36506. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36507. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36508. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36509. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36510. }
  36511. resp, requestErr := http.Get(api)
  36512. if requestErr != nil {
  36513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36514. return
  36515. }
  36516. body, ioErr := ioutil.ReadAll(resp.Body)
  36517. if ioErr != nil {
  36518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36520. return
  36521. }
  36522. var respJSON map[string]interface{}
  36523. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36526. return
  36527. }
  36528. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36529. result, _ := json.Marshal(respJSON)
  36530. fmt.Println("log")
  36531. fmt.Println(string(result))
  36532. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  36533. utils.ErrorLog("解析失败:%v", err)
  36534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36535. return
  36536. }
  36537. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36538. res.Output = resEleven10265.Output
  36539. res.ErrMsg = resEleven10265.ErrMsg
  36540. res.Cainfo = resEleven10265.Cainfo
  36541. res.WarnMsg = resEleven10265.WarnMsg
  36542. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36543. res.Infcode = infocode
  36544. } else if miConfig.MdtrtareaAdmvs == "350500" {
  36545. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  36546. saveLog(result, requestLog, "5203", "结算单")
  36547. var dat map[string]interface{}
  36548. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36549. fmt.Println(dat)
  36550. } else {
  36551. fmt.Println(err)
  36552. }
  36553. userJSONBytes, _ := json.Marshal(dat)
  36554. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36555. utils.ErrorLog("解析失败:%v", err)
  36556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36557. return
  36558. }
  36559. } else if miConfig.MdtrtareaAdmvs == "360302" {
  36560. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36561. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36562. saveLog(result, requestLog, "5203", "结算单")
  36563. var dat map[string]interface{}
  36564. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36565. fmt.Println(dat)
  36566. } else {
  36567. fmt.Println(err)
  36568. }
  36569. userJSONBytes, _ := json.Marshal(dat)
  36570. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36571. utils.ErrorLog("解析失败:%v", err)
  36572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36573. return
  36574. }
  36575. } else if miConfig.MdtrtareaAdmvs == "361025" {
  36576. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36577. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36578. saveLog(result, requestLog, "5203", "结算单")
  36579. var dat map[string]interface{}
  36580. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36581. fmt.Println(dat)
  36582. } else {
  36583. fmt.Println(err)
  36584. }
  36585. userJSONBytes, _ := json.Marshal(dat)
  36586. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36587. utils.ErrorLog("解析失败:%v", err)
  36588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36589. return
  36590. }
  36591. } else if miConfig.MdtrtareaAdmvs == "360100" {
  36592. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36593. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36594. saveLog(result, requestLog, "5203", "结算单")
  36595. var dat map[string]interface{}
  36596. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36597. fmt.Println(dat)
  36598. } else {
  36599. fmt.Println(err)
  36600. }
  36601. userJSONBytes, _ := json.Marshal(dat)
  36602. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36603. utils.ErrorLog("解析失败:%v", err)
  36604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36605. return
  36606. }
  36607. } else if miConfig.MdtrtareaAdmvs == "341203" {
  36608. var api string
  36609. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36610. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36611. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36612. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36613. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36614. resp, requestErr := http.Get(api)
  36615. if requestErr != nil {
  36616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36617. return
  36618. }
  36619. body, ioErr := ioutil.ReadAll(resp.Body)
  36620. if ioErr != nil {
  36621. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36623. return
  36624. }
  36625. var respJSON map[string]interface{}
  36626. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36629. return
  36630. }
  36631. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36632. if status == "0" {
  36633. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36634. c.ServeSuccessJSON(map[string]interface{}{
  36635. "failed_code": -10,
  36636. "msg": err_msg,
  36637. })
  36638. return
  36639. }
  36640. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36641. result, _ := json.Marshal(respJSON)
  36642. fmt.Println("log")
  36643. fmt.Println(string(result))
  36644. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  36645. utils.ErrorLog("解析失败:%v", err)
  36646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36647. return
  36648. }
  36649. res.InfRefmsgid = resah.InfRefmsgid
  36650. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36651. // 创建对应的Time类型
  36652. t := time.UnixMilli(timestamp)
  36653. // 格式化成指定的日期字符串
  36654. str := t.Format("2006-01-02 15:04:05")
  36655. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36656. // 创建对应的Time类型
  36657. t3 := time.UnixMilli(timestamp2)
  36658. // 格式化成指定的日期字符串
  36659. str2 := t3.Format("2006-01-02 15:04:05")
  36660. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  36661. // 创建对应的Time类型
  36662. t4 := time.UnixMilli(timestamp3)
  36663. // 格式化成指定的日期字符串
  36664. str3 := t4.Format("2006-01-02 15:04:05")
  36665. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  36666. // 创建对应的Time类型
  36667. t5 := time.UnixMilli(timestamp4)
  36668. // 格式化成指定的日期字符串
  36669. str5 := t5.Format("2006-01-02 15:04:05")
  36670. res.Output.Setlinfo.Brdy = str2
  36671. res.Output.Setlinfo.SetlTime = str
  36672. res.Output.Setlinfo.Begndate = str3
  36673. res.Output.Setlinfo.Enddate = str5
  36674. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  36675. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  36676. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  36677. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  36678. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36679. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36680. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  36681. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  36682. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36683. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  36684. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  36685. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  36686. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  36687. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  36688. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  36689. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  36690. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  36691. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  36692. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36693. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  36694. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  36695. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36696. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  36697. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  36698. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  36699. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  36700. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  36701. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  36702. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  36703. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  36704. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  36705. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  36706. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36707. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  36708. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  36709. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  36710. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  36711. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  36712. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  36713. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  36714. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  36715. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  36716. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  36717. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  36718. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  36719. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  36720. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  36721. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  36722. //res.Output.Setldetail = resah.Output.Setldetail
  36723. res.ErrMsg = resah.ErrMsg
  36724. res.Cainfo = resah.Cainfo
  36725. res.WarnMsg = resah.WarnMsg
  36726. } else if miConfig.MdtrtareaAdmvs == "340699" {
  36727. var api string
  36728. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36729. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36730. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36731. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36732. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36733. resp, requestErr := http.Get(api)
  36734. if requestErr != nil {
  36735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36736. return
  36737. }
  36738. body, ioErr := ioutil.ReadAll(resp.Body)
  36739. if ioErr != nil {
  36740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36742. return
  36743. }
  36744. var respJSON map[string]interface{}
  36745. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36748. return
  36749. }
  36750. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36751. if status == "0" {
  36752. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36753. c.ServeSuccessJSON(map[string]interface{}{
  36754. "failed_code": -10,
  36755. "msg": err_msg,
  36756. })
  36757. return
  36758. }
  36759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36760. result, _ := json.Marshal(respJSON)
  36761. fmt.Println("log")
  36762. fmt.Println(string(result))
  36763. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  36764. utils.ErrorLog("解析失败:%v", err)
  36765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36766. return
  36767. }
  36768. res.InfRefmsgid = resah.InfRefmsgid
  36769. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36770. // 创建对应的Time类型
  36771. t := time.UnixMilli(timestamp)
  36772. // 格式化成指定的日期字符串
  36773. str := t.Format("2006-01-02 15:04:05")
  36774. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36775. // 创建对应的Time类型
  36776. t3 := time.UnixMilli(timestamp2)
  36777. // 格式化成指定的日期字符串
  36778. str2 := t3.Format("2006-01-02 15:04:05")
  36779. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  36780. // 创建对应的Time类型
  36781. t4 := time.UnixMilli(timestamp3)
  36782. // 格式化成指定的日期字符串
  36783. str3 := t4.Format("2006-01-02 15:04:05")
  36784. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  36785. // 创建对应的Time类型
  36786. t5 := time.UnixMilli(timestamp4)
  36787. // 格式化成指定的日期字符串
  36788. str5 := t5.Format("2006-01-02 15:04:05")
  36789. res.Output.Setlinfo.Brdy = str2
  36790. res.Output.Setlinfo.SetlTime = str
  36791. res.Output.Setlinfo.Begndate = str3
  36792. res.Output.Setlinfo.Enddate = str5
  36793. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  36794. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  36795. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  36796. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  36797. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36798. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36799. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  36800. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  36801. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36802. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  36803. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  36804. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  36805. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  36806. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  36807. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  36808. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  36809. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  36810. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  36811. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36812. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  36813. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  36814. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36815. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  36816. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  36817. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  36818. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  36819. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  36820. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  36821. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  36822. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  36823. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  36824. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  36825. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36826. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  36827. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  36828. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  36829. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  36830. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  36831. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  36832. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  36833. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  36834. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  36835. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  36836. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  36837. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  36838. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  36839. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  36840. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  36841. //res.Output.Setldetail = resah.Output.Setldetail
  36842. res.ErrMsg = resah.ErrMsg
  36843. res.Cainfo = resah.Cainfo
  36844. res.WarnMsg = resah.WarnMsg
  36845. } else if miConfig.MdtrtareaAdmvs == "430800" {
  36846. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  36847. saveLog(result, requestLog, "5203", "结算单")
  36848. var dat map[string]interface{}
  36849. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36850. fmt.Println(dat)
  36851. } else {
  36852. fmt.Println(err)
  36853. }
  36854. userJSONBytes, _ := json.Marshal(dat)
  36855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36856. utils.ErrorLog("解析失败:%v", err)
  36857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36858. return
  36859. }
  36860. } else if miConfig.MdtrtareaAdmvs == "150499" {
  36861. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36862. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36863. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36864. resp, requestErr := http.Get(api)
  36865. if requestErr != nil {
  36866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36867. return
  36868. }
  36869. body, ioErr := ioutil.ReadAll(resp.Body)
  36870. if ioErr != nil {
  36871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36873. return
  36874. }
  36875. var respJSON map[string]interface{}
  36876. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36879. return
  36880. }
  36881. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36882. result, _ := json.Marshal(respJSON)
  36883. fmt.Println("log")
  36884. fmt.Println(string(result))
  36885. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  36886. utils.ErrorLog("解析失败:%v", err)
  36887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36888. return
  36889. }
  36890. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36891. res.Output = resEleven10265.Output
  36892. res.ErrMsg = resEleven10265.ErrMsg
  36893. res.Cainfo = resEleven10265.Cainfo
  36894. res.WarnMsg = resEleven10265.WarnMsg
  36895. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36896. res.Infcode = infocode
  36897. } else if miConfig.MdtrtareaAdmvs == "441799" {
  36898. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36899. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36900. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36901. resp, requestErr := http.Get(api)
  36902. if requestErr != nil {
  36903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36904. return
  36905. }
  36906. body, ioErr := ioutil.ReadAll(resp.Body)
  36907. if ioErr != nil {
  36908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36910. return
  36911. }
  36912. var respJSON map[string]interface{}
  36913. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36916. return
  36917. }
  36918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36919. result, _ := json.Marshal(respJSON)
  36920. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36921. utils.ErrorLog("解析失败:%v", err)
  36922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36923. return
  36924. }
  36925. } else if miConfig.MdtrtareaAdmvs == "450721" {
  36926. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  36927. //return
  36928. } else {
  36929. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36930. if len(his.InsuplcAdmdvs) == 0 {
  36931. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  36932. } else {
  36933. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36934. }
  36935. result := service.Gdyb5203(baseParams, businessParams)
  36936. //service.Gdyb5204(baseParams, businessParams)
  36937. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36938. var dat map[string]interface{}
  36939. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36940. fmt.Println(dat)
  36941. } else {
  36942. fmt.Println(err)
  36943. }
  36944. userJSONBytes, _ := json.Marshal(dat)
  36945. if miConfig.Code == "H15049901371" {
  36946. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36947. utils.ErrorLog("解析失败:%v", err)
  36948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36949. return
  36950. }
  36951. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36952. res.Output = resEleven10265.Output
  36953. res.ErrMsg = resEleven10265.ErrMsg
  36954. res.Cainfo = resEleven10265.Cainfo
  36955. res.WarnMsg = resEleven10265.WarnMsg
  36956. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36957. res.Infcode = infocode
  36958. } else {
  36959. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36960. utils.ErrorLog("解析失败:%v", err)
  36961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36962. return
  36963. }
  36964. }
  36965. }
  36966. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36967. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36968. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36969. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36970. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36971. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36972. var doctor_name string
  36973. if roles.ID == 0 {
  36974. doctor_name = "管理员"
  36975. } else {
  36976. doctor_name = roles.UserName
  36977. }
  36978. yiliao_leibie := ""
  36979. switch order.MedType {
  36980. case "11":
  36981. yiliao_leibie = "普通门诊"
  36982. break
  36983. case "12":
  36984. yiliao_leibie = "门诊挂号"
  36985. break
  36986. case "13":
  36987. yiliao_leibie = "急诊"
  36988. break
  36989. case "14":
  36990. yiliao_leibie = "门诊特殊病"
  36991. break
  36992. case "15":
  36993. yiliao_leibie = "门诊统筹"
  36994. break
  36995. case "16":
  36996. yiliao_leibie = "门诊慢性病"
  36997. break
  36998. case "21":
  36999. yiliao_leibie = "普通住院"
  37000. break
  37001. }
  37002. //var rf []CustomFundPay
  37003. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  37004. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37005. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  37006. if res.Infcode == 0 {
  37007. 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 {
  37008. c.ServeSuccessJSON(map[string]interface{}{
  37009. "diagnosis": name,
  37010. "order_infos": orderInfos,
  37011. "number": order.MdtrtId,
  37012. "date": order.SettleAccountsDate,
  37013. "charge_admin": charge_admin,
  37014. "printor_admin": printor_admin,
  37015. "info": res.Output.Setlinfo,
  37016. "order": order,
  37017. "bedCostTotal": bedCostTotal,
  37018. "bedCostSelfTotal": bedCostSelfTotal,
  37019. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37020. "bedSelfTotal": bedSelfTotal,
  37021. "bedInscpTotal": bedInscpTotal,
  37022. "operationCostTotal": operationCostTotal,
  37023. "operationCostSelfTotal": operationCostSelfTotal,
  37024. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37025. "operationSelfTotal": operationSelfTotal,
  37026. "operationInscpTotal": operationInscpTotal,
  37027. "otherCostTotal": otherCostTotal,
  37028. "otherCostSelfTotal": otherCostSelfTotal,
  37029. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37030. "otherSelfTotal": otherSelfTotal,
  37031. "otherInscpTotal": otherInscpTotal,
  37032. "materialCostTotal": materialCostTotal,
  37033. "materialCostSelfTotal": materialCostSelfTotal,
  37034. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37035. "materialSelfTotal": materialSelfTotal,
  37036. "materialInscpTotal": materialInscpTotal,
  37037. "westernMedicineCostTotal": westernMedicineCostTotal,
  37038. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37039. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37040. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37041. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37042. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37043. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37044. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37045. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37046. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37047. "checkCostTotal": checkCostTotal,
  37048. "checkCostSelfTotal": checkCostSelfTotal,
  37049. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37050. "checkSelfTotal": checkSelfTotal,
  37051. "checkInscpTotal": checkInscpTotal,
  37052. "laboratoryCostTotal": laboratoryCostTotal,
  37053. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37054. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37055. "laboratorySelfTotal": laboratorySelfTotal,
  37056. "laboratoryInscpTotal": laboratoryInscpTotal,
  37057. "treatCostTotal": treatCostTotal,
  37058. "treatCostSelfTotal": treatCostSelfTotal,
  37059. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37060. "treatSelfTotal": treatSelfTotal,
  37061. "treatInscpTotal": treatInscpTotal,
  37062. "doctor_info": doctor_info,
  37063. "doctor_code": adminRole_two.DoctorCode,
  37064. "doctor_name": doctor_name,
  37065. "health_card_no": order.PsnNo,
  37066. "department": departments.Name,
  37067. "yiliao_leibie": yiliao_leibie,
  37068. "after_money": order.AccountPrice,
  37069. "patient": patient,
  37070. "org_name": miConfig.OrgName,
  37071. "org_code": miConfig.Code,
  37072. "order_number": order.Number,
  37073. "his_hospital": his_hospital,
  37074. "his": his,
  37075. "dia_config": dia_config,
  37076. "psn_cash_pay": order.PsnCashPay,
  37077. "zcCostTotal": zcCostTotal,
  37078. "zcCostSelfTotal": zcCostSelfTotal,
  37079. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37080. "zcSelfTotal": zcSelfTotal,
  37081. "zcInscpTotal": zcInscpTotal,
  37082. "huliCostTotal": huliCostTotal,
  37083. "huliCostSelfTotal": huliCostSelfTotal,
  37084. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37085. "huliSelfTotal": huliSelfTotal,
  37086. "huliInscpTotal": huliInscpTotal,
  37087. //"funds": rf,
  37088. //"check_order_info": cus_slice,
  37089. })
  37090. } else {
  37091. c.ServeSuccessJSON(map[string]interface{}{
  37092. "diagnosis": name,
  37093. "order_infos": orderInfos,
  37094. "number": order.MdtrtId,
  37095. "date": order.SettleAccountsDate,
  37096. "charge_admin": charge_admin,
  37097. "printor_admin": printor_admin,
  37098. "info": order,
  37099. "order": order,
  37100. "bedCostTotal": bedCostTotal,
  37101. "bedCostSelfTotal": bedCostSelfTotal,
  37102. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37103. "bedSelfTotal": bedSelfTotal,
  37104. "bedInscpTotal": bedInscpTotal,
  37105. "operationCostTotal": operationCostTotal,
  37106. "operationCostSelfTotal": operationCostSelfTotal,
  37107. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37108. "operationSelfTotal": operationSelfTotal,
  37109. "operationInscpTotal": operationInscpTotal,
  37110. "otherCostTotal": otherCostTotal,
  37111. "otherCostSelfTotal": otherCostSelfTotal,
  37112. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37113. "otherSelfTotal": otherSelfTotal,
  37114. "otherInscpTotal": otherInscpTotal,
  37115. "materialCostTotal": materialCostTotal,
  37116. "materialCostSelfTotal": materialCostSelfTotal,
  37117. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37118. "materialSelfTotal": materialSelfTotal,
  37119. "materialInscpTotal": materialInscpTotal,
  37120. "westernMedicineCostTotal": westernMedicineCostTotal,
  37121. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37122. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37123. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37124. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37125. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37126. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37127. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37128. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37129. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37130. "checkCostTotal": checkCostTotal,
  37131. "checkCostSelfTotal": checkCostSelfTotal,
  37132. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37133. "checkSelfTotal": checkSelfTotal,
  37134. "checkInscpTotal": checkInscpTotal,
  37135. "laboratoryCostTotal": laboratoryCostTotal,
  37136. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37137. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37138. "laboratorySelfTotal": laboratorySelfTotal,
  37139. "laboratoryInscpTotal": laboratoryInscpTotal,
  37140. "treatCostTotal": treatCostTotal,
  37141. "treatCostSelfTotal": treatCostSelfTotal,
  37142. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37143. "treatSelfTotal": treatSelfTotal,
  37144. "treatInscpTotal": treatInscpTotal,
  37145. "doctor_info": doctor_info,
  37146. "doctor_code": adminRole_two.DoctorCode,
  37147. "doctor_name": doctor_name,
  37148. "health_card_no": order.PsnNo,
  37149. "department": departments.Name,
  37150. "yiliao_leibie": yiliao_leibie,
  37151. "after_money": order.AccountPrice,
  37152. "patient": patient,
  37153. "org_name": miConfig.OrgName,
  37154. "org_code": miConfig.Code,
  37155. "order_number": order.Number,
  37156. "his_hospital": his_hospital,
  37157. "his": his,
  37158. "dia_config": dia_config,
  37159. "psn_cash_pay": order.PsnCashPay,
  37160. "zcCostTotal": zcCostTotal,
  37161. "zcCostSelfTotal": zcCostSelfTotal,
  37162. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37163. "zcSelfTotal": zcSelfTotal,
  37164. "zcInscpTotal": zcInscpTotal,
  37165. "huliCostTotal": huliCostTotal,
  37166. "huliCostSelfTotal": huliCostSelfTotal,
  37167. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37168. "huliSelfTotal": huliSelfTotal,
  37169. "huliInscpTotal": huliInscpTotal,
  37170. //"funds": rf,
  37171. //"check_order_info": cus_slice,
  37172. })
  37173. }
  37174. }
  37175. }
  37176. }
  37177. //func (c *HisApiController) CheckTreatment() {
  37178. // patient_id, _ := c.GetInt64("patient_id")
  37179. // id_card_no := c.GetString("id_card_no")
  37180. // insutype := c.GetString("insutype")
  37181. // med_type := c.GetString("med_type")
  37182. // admin_user_id, _ := c.GetInt64("admin_user_id")
  37183. //
  37184. // adminUser := c.GetAdminUserInfo()
  37185. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37186. //
  37187. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37188. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37189. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37190. //
  37191. // if miConfig.MdtrtareaAdmvs == "421300" {
  37192. // var res ResultTwo
  37193. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  37194. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37195. // "&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)
  37196. // resp, requestErr := http.Get(api)
  37197. // if requestErr != nil {
  37198. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37199. // return
  37200. // }
  37201. //
  37202. // body, ioErr := ioutil.ReadAll(resp.Body)
  37203. // if ioErr != nil {
  37204. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37206. // return
  37207. // }
  37208. // var respJSON map[string]interface{}
  37209. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37210. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37211. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37212. // return
  37213. // }
  37214. //
  37215. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37216. // result, _ := json.Marshal(respJSON)
  37217. //
  37218. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37219. // utils.ErrorLog("解析失败:%v", err)
  37220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37221. // return
  37222. // }
  37223. //
  37224. // if res.Infcode == 0 {
  37225. //
  37226. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  37227. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37228. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  37229. // resp, requestErr := http.Get(api)
  37230. // if requestErr != nil {
  37231. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37232. // return
  37233. // }
  37234. //
  37235. // body, ioErr := ioutil.ReadAll(resp.Body)
  37236. // if ioErr != nil {
  37237. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37239. // return
  37240. // }
  37241. // var respJSON map[string]interface{}
  37242. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37243. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37245. // return
  37246. // }
  37247. // var res Result2001
  37248. //
  37249. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37250. // result2, _ := json.Marshal(respJSON)
  37251. //
  37252. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  37253. // utils.ErrorLog("解析失败:%v", err)
  37254. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37255. // return
  37256. // }
  37257. //
  37258. // if res.Infcode == 0 {
  37259. // c.ServeSuccessJSON(map[string]interface{}{
  37260. // "msg": res.Output.Trtinfo,
  37261. // })
  37262. // }
  37263. //
  37264. // } else {
  37265. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37266. // return
  37267. // }
  37268. //
  37269. // } else {
  37270. //
  37271. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37272. // var dat map[string]interface{}
  37273. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37274. // fmt.Println(dat)
  37275. // } else {
  37276. // fmt.Println(err)
  37277. // }
  37278. // userJSONBytes, _ := json.Marshal(dat)
  37279. // var res ResultTwo
  37280. // var res10265 ResultTwo10265
  37281. // if miConfig.Code == "H15049901371" {
  37282. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37283. // utils.ErrorLog("解析失败:%v", err)
  37284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37285. // return
  37286. // }
  37287. // res.ErrMsg = res10265.ErrMsg
  37288. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37289. // res.Infcode = infocode
  37290. // res.Output = res10265.Output
  37291. // res.InfRefmsgid = res10265.InfRefmsgid
  37292. // } else {
  37293. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37294. // utils.ErrorLog("解析失败:%v", err)
  37295. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37296. // return
  37297. // }
  37298. // }
  37299. //
  37300. // var user_name string
  37301. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  37302. // if role.ID == 0 {
  37303. // user_name = "xxx"
  37304. // } else {
  37305. // user_name = role.UserName
  37306. // }
  37307. //
  37308. // baseParams := models.BaseParams{
  37309. // SecretKey: miConfig.SecretKey,
  37310. // FixmedinsCode: miConfig.Code,
  37311. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37312. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37313. // OrgName: miConfig.OrgName,
  37314. // Doctor: user_name,
  37315. // }
  37316. //
  37317. // if config.IsOpen == 1 {
  37318. // if miConfig.Code == "H15049901371" {
  37319. // if med_type == "14" {
  37320. // if insutype == "390" {
  37321. // med_type = "9933"
  37322. // } else if insutype == "310" {
  37323. // med_type = "990502"
  37324. // }
  37325. // } else if med_type == "11" {
  37326. // med_type = "11"
  37327. // }
  37328. // }
  37329. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  37330. // var dat map[string]interface{}
  37331. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37332. // fmt.Println(dat)
  37333. // } else {
  37334. // fmt.Println(err)
  37335. // }
  37336. // var res Result2001
  37337. // var res10265 Result2001Org10265
  37338. // if miConfig.Code == "H15049901371" {
  37339. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37340. // utils.ErrorLog("解析失败:%v", err)
  37341. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37342. // return
  37343. // }
  37344. // res.ErrMsg = res10265.ErrMsg
  37345. // res.Output = res10265.Output
  37346. // res.InfRefmsgid = res10265.InfRefmsgid
  37347. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37348. // res.Infcode = infocode
  37349. // } else {
  37350. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37351. // utils.ErrorLog("解析失败:%v", err)
  37352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37353. // return
  37354. // }
  37355. // }
  37356. // if res.Infcode == 0 {
  37357. // c.ServeSuccessJSON(map[string]interface{}{
  37358. // "msg": res.Output.Trtinfo,
  37359. // })
  37360. // }
  37361. // }
  37362. // }
  37363. //}
  37364. //func (c *HisApiController) PutRecord() {
  37365. // id, _ := c.GetInt64("id")
  37366. // record_time := c.GetString("record_time")
  37367. // timeLayout := "2006-01-02"
  37368. // loc, _ := time.LoadLocation("Local")
  37369. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37370. // if err != nil {
  37371. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37372. // return
  37373. // }
  37374. // recordDateTime := theTime.Unix()
  37375. //
  37376. // adminInfo := c.GetAdminUserInfo()
  37377. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  37378. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37379. //
  37380. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37381. //
  37382. // fmt.Println(miConfig.SecretKey)
  37383. //
  37384. // if patient == nil {
  37385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37386. // return
  37387. // }
  37388. // if len(patient.IdCardNo) == 0 {
  37389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  37390. // return
  37391. // }
  37392. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  37393. // if config.IsOpen == 1 {
  37394. // 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
  37395. // resp, requestErr := http.Get(api)
  37396. // if requestErr != nil {
  37397. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37398. // return
  37399. // }
  37400. // defer resp.Body.Close()
  37401. // body, ioErr := ioutil.ReadAll(resp.Body)
  37402. // if ioErr != nil {
  37403. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37404. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37405. // return
  37406. // }
  37407. // var respJSON map[string]interface{}
  37408. //
  37409. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37410. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37411. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37412. // return
  37413. // }
  37414. //
  37415. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37416. // userJSONBytes, _ := json.Marshal(userJSON)
  37417. // var res ResultTwo
  37418. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37419. // utils.ErrorLog("解析失败:%v", err)
  37420. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37421. // return
  37422. // }
  37423. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37424. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37425. // infoStr := string(Iinfos)
  37426. // idetinfoStr := string(Idetinfos)
  37427. //
  37428. // if res.Infcode == 0 {
  37429. // his := models.VMHisPatient{
  37430. // Status: 1,
  37431. // Ctime: time.Now().Unix(),
  37432. // Mtime: time.Now().Unix(),
  37433. // PsnNo: res.Output.Baseinfo.PsnNo,
  37434. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  37435. // Certno: res.Output.Baseinfo.Certno,
  37436. // PsnName: res.Output.Baseinfo.PsnName,
  37437. // Gend: res.Output.Baseinfo.Gend,
  37438. // Naty: res.Output.Baseinfo.Naty,
  37439. // Brdy: res.Output.Baseinfo.Brdy,
  37440. // Age: res.Output.Baseinfo.Age,
  37441. // Iinfo: infoStr,
  37442. // Idetinfo: idetinfoStr,
  37443. // PatientId: patient.ID,
  37444. // RecordDate: theTime.Unix(),
  37445. // UserOrgId: adminInfo.CurrentOrgId,
  37446. // AdminUserId: adminInfo.AdminUser.Id,
  37447. // IsReturn: 1,
  37448. // }
  37449. //
  37450. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  37451. // //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")
  37452. // //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")
  37453. //
  37454. // //var dat map[string]interface{}
  37455. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37456. // // fmt.Println(dat)
  37457. // //} else {
  37458. // // fmt.Println(err)
  37459. // //}
  37460. //
  37461. // var dat2 map[string]interface{}
  37462. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37463. // fmt.Println(dat2)
  37464. // } else {
  37465. // fmt.Println(err)
  37466. // }
  37467. //
  37468. // } else {
  37469. // adminUser := c.GetAdminUserInfo()
  37470. // errlog := &models.HisOrderError{
  37471. // UserOrgId: adminUser.CurrentOrgId,
  37472. // Ctime: time.Now().Unix(),
  37473. // Mtime: time.Now().Unix(),
  37474. // ErrMsg: res.ErrMsg,
  37475. // Status: 1,
  37476. // PatientId: id,
  37477. // RecordTime: recordDateTime,
  37478. // Stage: 1,
  37479. // }
  37480. // service.CreateErrMsgLog(errlog)
  37481. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  37482. // return
  37483. // }
  37484. // }
  37485. //
  37486. //}
  37487. //func (c *HisApiController) GetUploadDiag() {
  37488. // id, _ := c.GetInt64("id")
  37489. // record_time := c.GetString("record_time")
  37490. //
  37491. // diagnosis_id, _ := c.GetInt64("diagnosis")
  37492. // sick_type, _ := c.GetInt64("sick_type")
  37493. // reg_type, _ := c.GetInt64("reg_type")
  37494. //
  37495. // timeLayout := "2006-01-02"
  37496. // loc, _ := time.LoadLocation("Local")
  37497. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37498. // if err != nil {
  37499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37500. // return
  37501. // }
  37502. //
  37503. // var patientPrescription models.HisPrescriptionInfo
  37504. // recordDateTime := theTime.Unix()
  37505. // adminInfo := c.GetAdminUserInfo()
  37506. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37507. //
  37508. // if patientPrescription.ID == 0 {
  37509. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37510. // }
  37511. //
  37512. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37513. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  37514. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37515. // sickConfig, _ := service.FindSickById(sick_type)
  37516. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37517. //
  37518. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  37519. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  37520. // "&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 +
  37521. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  37522. // resp2, requestErr2 := http.Get(api2)
  37523. // if requestErr2 != nil {
  37524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37525. // return
  37526. // }
  37527. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  37528. // if ioErr2 != nil {
  37529. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  37530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37531. // return
  37532. // }
  37533. // var respJSON2 map[string]interface{}
  37534. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  37535. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37537. // return
  37538. // }
  37539. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37540. // userJSONBytes2, _ := json.Marshal(respJSON2)
  37541. //
  37542. // var res2 ResultSix
  37543. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37544. // utils.ErrorLog("解析失败:%v", err)
  37545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37546. // return
  37547. // }
  37548. // if res2.Infcode != 0 {
  37549. // adminUser := c.GetAdminUserInfo()
  37550. // errlog := &models.HisOrderError{
  37551. // UserOrgId: adminUser.CurrentOrgId,
  37552. // Ctime: time.Now().Unix(),
  37553. // Mtime: time.Now().Unix(),
  37554. // ErrMsg: res2.ErrMsg,
  37555. // Status: 1,
  37556. // PatientId: id,
  37557. // RecordTime: recordDateTime,
  37558. // Stage: 3,
  37559. // }
  37560. // service.CreateErrMsgLog(errlog)
  37561. //
  37562. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  37563. // return
  37564. // }
  37565. //
  37566. // c.ServeSuccessJSON(map[string]interface{}{
  37567. // "msg": "上传成功",
  37568. // })
  37569. //
  37570. //}
  37571. type QueryResult struct {
  37572. ID int64
  37573. Name string
  37574. Code string
  37575. List_type_code string
  37576. }
  37577. func (c *HisApiController) GetCheckCode() {
  37578. ids_str := c.GetString("ids")
  37579. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  37580. ids_arr := strings.Split(ids_str, ",")
  37581. var queryResult []QueryResult
  37582. ids := make([]int64, 0)
  37583. for _, item := range ids_arr {
  37584. id, _ := strconv.ParseInt(item, 10, 64)
  37585. ids = append(ids, id)
  37586. }
  37587. if record_type == 1 {
  37588. drugs, _ := service.GetBatchDrugList(ids)
  37589. for _, item := range drugs {
  37590. result := QueryResult{
  37591. ID: item.ID,
  37592. Name: item.DrugName,
  37593. Code: item.MedicalInsuranceNumber,
  37594. List_type_code: "101",
  37595. }
  37596. queryResult = append(queryResult, result)
  37597. }
  37598. } else if record_type == 2 {
  37599. goods, _ := service.GetBatchGoodInformationList(ids)
  37600. fmt.Println(goods)
  37601. for _, item := range goods {
  37602. result := QueryResult{
  37603. ID: item.ID,
  37604. Name: item.GoodName,
  37605. Code: item.SocialSecurityDirectoryCode,
  37606. List_type_code: "301",
  37607. }
  37608. queryResult = append(queryResult, result)
  37609. }
  37610. } else if record_type == 3 {
  37611. projects, _ := service.GetBathchMyPorjecgList(ids)
  37612. for _, item := range projects {
  37613. result := QueryResult{
  37614. ID: item.ID,
  37615. Name: item.ProjectName,
  37616. Code: item.MedicalCode,
  37617. List_type_code: "201",
  37618. }
  37619. queryResult = append(queryResult, result)
  37620. }
  37621. }
  37622. admin_user_id, _ := c.GetInt64("admin_user_id")
  37623. adminUser := c.GetAdminUserInfo()
  37624. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37625. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37626. var user_name string
  37627. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37628. if role.ID == 0 {
  37629. user_name = "管理员"
  37630. } else {
  37631. user_name = role.UserName
  37632. }
  37633. baseParams := models.BaseParams{
  37634. SecretKey: miConfig.SecretKey,
  37635. FixmedinsCode: miConfig.Code,
  37636. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37637. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37638. OrgName: miConfig.OrgName,
  37639. Doctor: user_name,
  37640. }
  37641. var result string
  37642. if miConfig.MdtrtareaAdmvs == "430800" {
  37643. for _, item := range queryResult {
  37644. if record_type == 1 {
  37645. 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)
  37646. } else if record_type == 2 {
  37647. fmt.Println(item.Code)
  37648. 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)
  37649. } else if record_type == 3 {
  37650. 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)
  37651. }
  37652. var dat map[string]interface{}
  37653. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37654. fmt.Println(dat)
  37655. } else {
  37656. fmt.Println(err)
  37657. }
  37658. userJSONBytes, _ := json.Marshal(dat)
  37659. var res ResultSix
  37660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37661. utils.ErrorLog("解析失败:%v", err)
  37662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37663. return
  37664. }
  37665. if res.Infcode == 0 {
  37666. if record_type == 1 {
  37667. service.UpdateBaseDrugById(item.ID)
  37668. } else if record_type == 2 {
  37669. service.UpdateGoodInformaitonByDetail(item.ID)
  37670. } else if record_type == 3 {
  37671. service.UpdateProjectById(item.ID)
  37672. }
  37673. c.ServeSuccessJSON(map[string]interface{}{
  37674. "failed_code": 0,
  37675. "msg": "目录对照成功",
  37676. })
  37677. } else {
  37678. c.ServeSuccessJSON(map[string]interface{}{
  37679. "failed_code": -10,
  37680. "msg": res.ErrMsg,
  37681. })
  37682. }
  37683. }
  37684. } else {
  37685. for _, item := range queryResult {
  37686. var result string
  37687. if record_type == 1 {
  37688. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37689. } else if record_type == 2 {
  37690. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37691. } else if record_type == 3 {
  37692. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37693. }
  37694. var dat map[string]interface{}
  37695. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37696. fmt.Println(dat)
  37697. } else {
  37698. fmt.Println(err)
  37699. }
  37700. userJSONBytes, _ := json.Marshal(dat)
  37701. var res ResultSix
  37702. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37703. utils.ErrorLog("解析失败:%v", err)
  37704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37705. return
  37706. }
  37707. if res.Infcode == 0 {
  37708. if record_type == 1 {
  37709. service.UpdateBaseDrugById(item.ID)
  37710. } else if record_type == 2 {
  37711. service.UpdateGoodInformaitonByDetail(item.ID)
  37712. } else if record_type == 3 {
  37713. service.UpdateProjectById(item.ID)
  37714. }
  37715. c.ServeSuccessJSON(map[string]interface{}{
  37716. "failed_code": 0,
  37717. "msg": "目录对照成功",
  37718. })
  37719. } else {
  37720. c.ServeSuccessJSON(map[string]interface{}{
  37721. "failed_code": -10,
  37722. "msg": res.ErrMsg,
  37723. })
  37724. }
  37725. }
  37726. }
  37727. }
  37728. func (c *HisApiController) UnCheckCode() {
  37729. ids_str := c.GetString("ids")
  37730. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  37731. admin_user_id, _ := c.GetInt64("admin_user_id")
  37732. ids_arr := strings.Split(ids_str, ",")
  37733. var queryResult []QueryResult
  37734. ids := make([]int64, 0)
  37735. for _, item := range ids_arr {
  37736. id, _ := strconv.ParseInt(item, 10, 64)
  37737. ids = append(ids, id)
  37738. }
  37739. if record_type == 1 {
  37740. drugs, _ := service.GetBatchDrugList(ids)
  37741. for _, item := range drugs {
  37742. result := QueryResult{
  37743. ID: item.ID,
  37744. Name: item.DrugName,
  37745. Code: item.MedicalInsuranceNumber,
  37746. List_type_code: "101",
  37747. }
  37748. queryResult = append(queryResult, result)
  37749. }
  37750. } else if record_type == 2 {
  37751. goods, _ := service.GetBatchGoodInformationList(ids)
  37752. for _, item := range goods {
  37753. result := QueryResult{
  37754. ID: item.ID,
  37755. Name: item.GoodName,
  37756. Code: item.SocialSecurityDirectoryCode,
  37757. List_type_code: "301",
  37758. }
  37759. queryResult = append(queryResult, result)
  37760. }
  37761. } else if record_type == 3 {
  37762. projects, _ := service.GetBathchMyPorjecgList(ids)
  37763. for _, item := range projects {
  37764. result := QueryResult{
  37765. ID: item.ID,
  37766. Name: item.ProjectName,
  37767. Code: item.MedicalCode,
  37768. List_type_code: "201",
  37769. }
  37770. queryResult = append(queryResult, result)
  37771. }
  37772. }
  37773. adminUser := c.GetAdminUserInfo()
  37774. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37775. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37776. var user_name string
  37777. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37778. if role.ID == 0 {
  37779. user_name = "xxx"
  37780. } else {
  37781. user_name = role.UserName
  37782. }
  37783. baseParams := &models.BaseParams{
  37784. SecretKey: miConfig.SecretKey,
  37785. FixmedinsCode: miConfig.Code,
  37786. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37787. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37788. OrgName: miConfig.OrgName,
  37789. Doctor: user_name,
  37790. }
  37791. if config.IsOpen == 1 {
  37792. if miConfig.MdtrtareaAdmvs == "430800" {
  37793. for _, item := range queryResult {
  37794. var result string
  37795. if record_type == 1 {
  37796. 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)
  37797. } else if record_type == 2 {
  37798. fmt.Println(item.Code)
  37799. 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)
  37800. } else if record_type == 3 {
  37801. 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)
  37802. }
  37803. var dat map[string]interface{}
  37804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37805. fmt.Println(dat)
  37806. } else {
  37807. fmt.Println(err)
  37808. }
  37809. userJSONBytes, _ := json.Marshal(dat)
  37810. var res ResultSix
  37811. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37812. utils.ErrorLog("解析失败:%v", err)
  37813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37814. return
  37815. }
  37816. if res.Infcode == 0 {
  37817. if record_type == 1 {
  37818. service.UpdateBaseDrugById(item.ID)
  37819. } else if record_type == 2 {
  37820. service.UpdateGoodInformaitonByDetail(item.ID)
  37821. } else if record_type == 3 {
  37822. service.UpdateProjectById(item.ID)
  37823. }
  37824. c.ServeSuccessJSON(map[string]interface{}{
  37825. "failed_code": 0,
  37826. "msg": "目录对照成功",
  37827. })
  37828. } else {
  37829. c.ServeSuccessJSON(map[string]interface{}{
  37830. "failed_code": -10,
  37831. "msg": res.ErrMsg,
  37832. })
  37833. }
  37834. }
  37835. } else {
  37836. for _, item := range queryResult {
  37837. var result string
  37838. if record_type == 1 {
  37839. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  37840. } else if record_type == 2 {
  37841. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  37842. } else if record_type == 3 {
  37843. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  37844. }
  37845. var dat2 map[string]interface{}
  37846. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37847. fmt.Println(dat2)
  37848. } else {
  37849. fmt.Println(err)
  37850. }
  37851. userJSONBytes, _ := json.Marshal(dat2)
  37852. var res ResultSix
  37853. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37854. utils.ErrorLog("解析失败:%v", err)
  37855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37856. return
  37857. }
  37858. if res.Infcode == 0 {
  37859. if record_type == 1 {
  37860. service.UpdateDrugByIdDetail(item.ID)
  37861. } else if record_type == 2 {
  37862. service.UpdateGoodInfoById(item.ID)
  37863. } else if record_type == 3 {
  37864. service.UpdateMyProjectById(item.ID)
  37865. }
  37866. c.ServeSuccessJSON(map[string]interface{}{
  37867. "failed_code": 0,
  37868. "msg": "撤销目录对照成功",
  37869. })
  37870. } else {
  37871. c.ServeSuccessJSON(map[string]interface{}{
  37872. "failed_code": -10,
  37873. "msg": res.ErrMsg,
  37874. })
  37875. }
  37876. }
  37877. }
  37878. }
  37879. }
  37880. func (c *HisApiController) GetPatientInfo() {
  37881. id_card_no := c.GetString("id_card_no")
  37882. admin_user_id, _ := c.GetInt64("admin_user_id")
  37883. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  37884. if patient.ID == 0 {
  37885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37886. return
  37887. }
  37888. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  37889. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  37890. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  37891. var res ResultTwo
  37892. var res10265 ResultTwo10265
  37893. if config.IsOpen == 1 {
  37894. if miConfig.MdtrtareaAdmvs == "150499" {
  37895. //请求内网数据
  37896. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  37897. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  37898. "&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
  37899. resp, requestErr := http.Get(api)
  37900. if requestErr != nil {
  37901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37902. return
  37903. }
  37904. body, ioErr := ioutil.ReadAll(resp.Body)
  37905. if ioErr != nil {
  37906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37908. return
  37909. }
  37910. var respJSON map[string]interface{}
  37911. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37914. return
  37915. }
  37916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37917. result_byte, _ := json.Marshal(respJSON)
  37918. result := string(result_byte)
  37919. var dat map[string]interface{}
  37920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37921. fmt.Println(dat)
  37922. } else {
  37923. fmt.Println(err)
  37924. }
  37925. userJSONBytes, _ := json.Marshal(dat)
  37926. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37927. utils.ErrorLog("解析失败:%v", err)
  37928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37929. return
  37930. }
  37931. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37932. res.Infcode = Infcode
  37933. res.ErrMsg = res10265.ErrMsg
  37934. res.Output = res10265.Output
  37935. res.InfRefmsgid = res10265.InfRefmsgid
  37936. res.RespondTime = res10265.RespondTime
  37937. res.WarnInfo = res10265.WarnInfo
  37938. } else {
  37939. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37940. var dat map[string]interface{}
  37941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37942. fmt.Println(dat)
  37943. } else {
  37944. fmt.Println(err)
  37945. }
  37946. userJSONBytes, _ := json.Marshal(dat)
  37947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37948. utils.ErrorLog("解析失败:%v", err)
  37949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37950. return
  37951. }
  37952. }
  37953. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37954. // utils.ErrorLog("解析失败:%v", err)
  37955. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37956. // return
  37957. //}
  37958. for index, item := range res.Output.Iinfo {
  37959. if item.PsnInsuStas == "2" {
  37960. fmt.Println("--------")
  37961. res.Output.Iinfo[index].Insutype = "300"
  37962. res.Output.Iinfo[index].PsnInsuStas = "1"
  37963. }
  37964. }
  37965. fmt.Println(res.Output.Iinfo)
  37966. if res.Infcode != 0 {
  37967. c.ServeSuccessJSON(map[string]interface{}{
  37968. "failed_code": -10,
  37969. "msg": res.ErrMsg,
  37970. })
  37971. } else {
  37972. c.ServeSuccessJSON(map[string]interface{}{
  37973. "failed_code": 0,
  37974. "info": res,
  37975. })
  37976. }
  37977. }
  37978. }
  37979. func (c *HisApiController) PsnPutOnRecord() {
  37980. record_type, _ := c.GetInt64("type")
  37981. patient_id, _ := c.GetInt64("patient_id")
  37982. admin_user_id, _ := c.GetInt64("admin_user_id")
  37983. start_time := c.GetString("start_time")
  37984. end_time := c.GetString("end_time")
  37985. adminUser := c.GetAdminUserInfo()
  37986. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37987. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37988. var patients []*models.Patients
  37989. if record_type == 1 { //全部备案
  37990. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  37991. patients = append(patients, patient...)
  37992. } else { //单个备案
  37993. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37994. patients = append(patients, patient)
  37995. }
  37996. var user_name string
  37997. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37998. if role.ID == 0 {
  37999. user_name = "xxx"
  38000. } else {
  38001. user_name = role.UserName
  38002. }
  38003. if config.IsOpen == 1 {
  38004. for _, item := range patients {
  38005. 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
  38006. resp, requestErr := http.Get(api)
  38007. if requestErr != nil {
  38008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38009. return
  38010. }
  38011. defer resp.Body.Close()
  38012. body, ioErr := ioutil.ReadAll(resp.Body)
  38013. if ioErr != nil {
  38014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38016. return
  38017. }
  38018. var respJSON map[string]interface{}
  38019. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38022. return
  38023. }
  38024. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38025. userJSONBytes, _ := json.Marshal(userJSON)
  38026. var res ResultTwo
  38027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38028. utils.ErrorLog("解析失败:%v", err)
  38029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38030. return
  38031. }
  38032. if res.Infcode == 0 {
  38033. 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)
  38034. var dat map[string]interface{}
  38035. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38036. fmt.Println(dat)
  38037. } else {
  38038. fmt.Println(err)
  38039. }
  38040. userJSONBytes, _ := json.Marshal(dat)
  38041. var res2 ResultThirteen
  38042. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38043. utils.ErrorLog("解析失败:%v", err)
  38044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38045. return
  38046. }
  38047. if res2.Infcode == 0 {
  38048. psnResult := &models.GdybPsnRecord{
  38049. UserOrgId: adminUser.CurrentOrgId,
  38050. PatientId: item.ID,
  38051. PsnNo: res.Output.Baseinfo.PsnNo,
  38052. Ctime: time.Now().Unix(),
  38053. Mtime: time.Now().Unix(),
  38054. Status: 1,
  38055. IsCancel: 1,
  38056. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38057. }
  38058. service.CreatePsnRecord(psnResult)
  38059. } else {
  38060. c.ServeSuccessJSON(map[string]interface{}{
  38061. "failed_code": -10,
  38062. "msg": res2.ErrMsg,
  38063. })
  38064. return
  38065. }
  38066. }
  38067. }
  38068. }
  38069. }
  38070. func (c *HisApiController) PsnUnPutOnRecord() {
  38071. id, _ := c.GetInt64("id")
  38072. //record_type, _ := c.GetInt64("type")
  38073. admin_user_id, _ := c.GetInt64("admin_user_id")
  38074. adminUser := c.GetAdminUserInfo()
  38075. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38076. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38077. var user_name string
  38078. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38079. if role.ID == 0 {
  38080. user_name = "xxx"
  38081. } else {
  38082. user_name = role.UserName
  38083. }
  38084. psn_record, _ := service.GetPsnRecordById(id)
  38085. if psn_record.ID == 0 {
  38086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38087. return
  38088. }
  38089. if config.IsOpen == 1 {
  38090. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38091. var dat map[string]interface{}
  38092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38093. fmt.Println(dat)
  38094. } else {
  38095. fmt.Println(err)
  38096. }
  38097. userJSONBytes, _ := json.Marshal(dat)
  38098. var res ResultFourteen
  38099. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38100. utils.ErrorLog("解析失败:%v", err)
  38101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38102. return
  38103. }
  38104. if res.Infcode == 0 {
  38105. psn_record.IsCancel = 2
  38106. service.CreatePsnRecord(&psn_record)
  38107. } else {
  38108. c.ServeSuccessJSON(map[string]interface{}{
  38109. "failed_code": -10,
  38110. "msg": res.ErrMsg,
  38111. })
  38112. return
  38113. }
  38114. }
  38115. }
  38116. func (c *HisApiController) PsnPutNCDSOnRecord() {
  38117. patient_id, _ := c.GetInt64("patient_id")
  38118. insutype_two := c.GetString("insutype")
  38119. psn_no := c.GetString("psn_no")
  38120. doctor_id, _ := c.GetInt64("doctor_id")
  38121. sick_id, _ := c.GetInt64("sick_id")
  38122. department_id, _ := c.GetInt64("department_id")
  38123. start_time := c.GetString("start_time")
  38124. end_time := c.GetString("end_time")
  38125. check_time := c.GetString("check_time")
  38126. hospital_code := c.GetString("hospital_code")
  38127. hospital_name := c.GetString("hospital_name")
  38128. adminUser := c.GetAdminUserInfo()
  38129. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38130. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38131. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38132. sick, _ := service.FindSickById(sick_id)
  38133. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38134. if len(hospital_code) == 0 {
  38135. hospital_code = miConfig.Code
  38136. }
  38137. if len(hospital_name) == 0 {
  38138. hospital_name = miConfig.OrgName
  38139. }
  38140. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38141. var res ResultTwo
  38142. var res10265 ResultTwo10265
  38143. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38144. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  38145. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  38146. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38147. "&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
  38148. resp, requestErr := http.Get(api)
  38149. if requestErr != nil {
  38150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38151. return
  38152. }
  38153. body, ioErr := ioutil.ReadAll(resp.Body)
  38154. if ioErr != nil {
  38155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38157. return
  38158. }
  38159. var respJSON map[string]interface{}
  38160. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38163. return
  38164. }
  38165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38166. result, _ := json.Marshal(respJSON)
  38167. fmt.Println("log")
  38168. fmt.Println(string(result))
  38169. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38170. utils.ErrorLog("解析失败:%v", err)
  38171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38172. return
  38173. }
  38174. res.ErrMsg = res10265.ErrMsg
  38175. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38176. res.Infcode = infocode
  38177. res.Output = res10265.Output
  38178. res.InfRefmsgid = res10265.InfRefmsgid
  38179. } else {
  38180. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38181. if miConfig.Code == "H15049901371" {
  38182. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38183. utils.ErrorLog("解析失败:%v", err)
  38184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38185. return
  38186. }
  38187. res.ErrMsg = res10265.ErrMsg
  38188. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38189. res.Infcode = infocode
  38190. res.Output = res10265.Output
  38191. res.InfRefmsgid = res10265.InfRefmsgid
  38192. } else {
  38193. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38194. utils.ErrorLog("解析失败:%v", err)
  38195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38196. return
  38197. }
  38198. }
  38199. }
  38200. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38201. infoStr := string(Iinfos)
  38202. var rf []*ResultFive
  38203. json.Unmarshal([]byte(infoStr), &rf)
  38204. var insuplc_admdvs string
  38205. var insutype string
  38206. var is390 int = 0
  38207. var is310 int = 0
  38208. var insutypes []*ResultFive
  38209. for _, item := range rf {
  38210. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38211. insutypes = append(insutypes, item)
  38212. }
  38213. }
  38214. if len(insutypes) == 1 {
  38215. insutype = insutypes[0].Insutype
  38216. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38217. } else {
  38218. for _, i := range insutypes {
  38219. if i.Insutype == "390" {
  38220. is390 = 1
  38221. }
  38222. if i.Insutype == "310" {
  38223. is310 = 1
  38224. }
  38225. }
  38226. }
  38227. if is390 == 1 {
  38228. insutype = "390"
  38229. }
  38230. if is310 == 1 {
  38231. insutype = "310"
  38232. }
  38233. if len(insutypes) == 2 {
  38234. insutype = insutype_two
  38235. }
  38236. if len(insutypes) == 0 {
  38237. insutype = "310"
  38238. }
  38239. insutype = insutype_two
  38240. fmt.Println(insutype)
  38241. for _, item := range rf {
  38242. fmt.Println(item.Insutype)
  38243. fmt.Println(insutype)
  38244. if item.Insutype == insutype {
  38245. fmt.Println(item.Insutype)
  38246. fmt.Println(insutype)
  38247. insuplc_admdvs = item.InsuplcAdmdvs
  38248. }
  38249. }
  38250. fmt.Println(insuplc_admdvs)
  38251. var res2 ResultThirteen
  38252. var res10265_2 ResultThirteen10265
  38253. if config.IsOpen == 1 {
  38254. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38255. } else {
  38256. if miConfig.MdtrtareaAdmvs == "150499" {
  38257. //
  38258. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  38259. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38260. // "&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
  38261. //resp, requestErr := http.Get(api)
  38262. //if requestErr != nil {
  38263. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38264. // return
  38265. //}
  38266. //
  38267. //body, ioErr := ioutil.ReadAll(resp.Body)
  38268. //if ioErr != nil {
  38269. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38271. // return
  38272. //}
  38273. //var respJSON map[string]interface{}
  38274. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38275. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38277. // return
  38278. //}
  38279. //
  38280. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38281. //result, _ := json.Marshal(respJSON)
  38282. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  38283. // utils.ErrorLog("解析失败:%v", err)
  38284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38285. // return
  38286. //}
  38287. //infocode = resThree.Infcode
  38288. //result, _ := json.Marshal(respJSON)
  38289. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  38290. // utils.ErrorLog("解析失败:%v", err)
  38291. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38292. // return
  38293. //}
  38294. //
  38295. //resThree.ErrMsg = resThree10265.ErrMsg
  38296. //
  38297. //resThree.Output = resThree10265.Output
  38298. //
  38299. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  38300. //
  38301. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  38302. //
  38303. } else {
  38304. 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)
  38305. var dat map[string]interface{}
  38306. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38307. fmt.Println(dat)
  38308. } else {
  38309. fmt.Println(err)
  38310. }
  38311. userJSONBytes, _ := json.Marshal(dat)
  38312. if miConfig.Code == "H15049901371" {
  38313. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  38314. utils.ErrorLog("解析失败:%v", err)
  38315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38316. return
  38317. }
  38318. res2.ErrMsg = res10265_2.ErrMsg
  38319. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  38320. res2.Infcode = infocode
  38321. res2.Output = res10265_2.Output
  38322. res2.InfRefmsgid = res10265_2.InfRefmsgid
  38323. } else {
  38324. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38325. utils.ErrorLog("解析失败:%v", err)
  38326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38327. return
  38328. }
  38329. }
  38330. }
  38331. }
  38332. if res2.Infcode == 0 {
  38333. psnResult := &models.GdybPsnNcdsRecord{
  38334. UserOrgId: adminUser.CurrentOrgId,
  38335. PatientId: patient.ID,
  38336. PsnNo: psn_no,
  38337. DoctorId: doctor.AdminUserId,
  38338. DepartmentId: department_id,
  38339. SickType: sick_id,
  38340. Insutype: insutype,
  38341. Ctime: time.Now().Unix(),
  38342. Mtime: time.Now().Unix(),
  38343. Status: 1,
  38344. IsCancel: 1,
  38345. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38346. }
  38347. service.CreatePsnNCDSRecord(psnResult)
  38348. c.ServeSuccessJSON(map[string]interface{}{
  38349. "failed_code": 0,
  38350. "msg": "备案成功",
  38351. "result": psnResult,
  38352. })
  38353. } else {
  38354. c.ServeSuccessJSON(map[string]interface{}{
  38355. "failed_code": -10,
  38356. "msg": res2.ErrMsg,
  38357. })
  38358. return
  38359. }
  38360. }
  38361. }
  38362. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  38363. id, _ := c.GetInt64("id")
  38364. admin_user_id, _ := c.GetInt64("admin_user_id")
  38365. adminUser := c.GetAdminUserInfo()
  38366. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38367. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38368. //config, _ := service.Ge(adminUser.CurrentOrgId)
  38369. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  38370. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38371. //var user_name string
  38372. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38373. //if role.ID == 0 {
  38374. // user_name = "xxx"
  38375. //} else {
  38376. // user_name = role.UserName
  38377. //}
  38378. psn_record, _ := service.GetPsnNCDSRecordById(id)
  38379. if psn_record.ID == 0 {
  38380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38381. return
  38382. }
  38383. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38384. var res ResultTwo
  38385. var res10265 ResultTwo10265
  38386. if miConfig.Code == "H15049901371" {
  38387. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38388. utils.ErrorLog("解析失败:%v", err)
  38389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38390. return
  38391. }
  38392. res.ErrMsg = res10265.ErrMsg
  38393. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38394. res.Infcode = infocode
  38395. res.Output = res10265.Output
  38396. res.InfRefmsgid = res10265.InfRefmsgid
  38397. } else {
  38398. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38399. utils.ErrorLog("解析失败:%v", err)
  38400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38401. return
  38402. }
  38403. }
  38404. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38405. infoStr := string(Iinfos)
  38406. var rf []*ResultFive
  38407. json.Unmarshal([]byte(infoStr), &rf)
  38408. var insuplc_admdvs string
  38409. var insutype string
  38410. var is390 int = 0
  38411. var is310 int = 0
  38412. var insutypes []*ResultFive
  38413. for _, item := range rf {
  38414. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38415. insutypes = append(insutypes, item)
  38416. }
  38417. }
  38418. if len(insutypes) == 1 {
  38419. insutype = insutypes[0].Insutype
  38420. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38421. } else {
  38422. for _, i := range insutypes {
  38423. if i.Insutype == "390" {
  38424. is390 = 1
  38425. }
  38426. if i.Insutype == "310" {
  38427. is310 = 1
  38428. }
  38429. }
  38430. }
  38431. if is390 == 1 {
  38432. insutype = "390"
  38433. }
  38434. if is310 == 1 {
  38435. insutype = "310"
  38436. }
  38437. if len(insutypes) == 0 {
  38438. insutype = "310"
  38439. }
  38440. insutype = psn_record.Insutype
  38441. for _, item := range rf {
  38442. if item.Insutype == insutype {
  38443. insuplc_admdvs = item.InsuplcAdmdvs
  38444. }
  38445. }
  38446. if config.IsOpen == 1 {
  38447. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38448. var dat map[string]interface{}
  38449. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38450. fmt.Println(dat)
  38451. } else {
  38452. fmt.Println(err)
  38453. }
  38454. userJSONBytes, _ := json.Marshal(dat)
  38455. var res ResultFourteen
  38456. var res10265 ResultFourteen10265
  38457. if miConfig.Code == "H15049901371" {
  38458. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38459. utils.ErrorLog("解析失败:%v", err)
  38460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38461. return
  38462. }
  38463. res.ErrMsg = res10265.ErrMsg
  38464. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38465. res.Infcode = infocode
  38466. res.Output = res10265.Output
  38467. res.InfRefmsgid = res10265.InfRefmsgid
  38468. } else {
  38469. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38470. utils.ErrorLog("解析失败:%v", err)
  38471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38472. return
  38473. }
  38474. }
  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. psn_record.IsCancel = 2
  38482. service.CreatePsnNCDSRecord(&psn_record)
  38483. c.ServeSuccessJSON(map[string]interface{}{
  38484. "failed_code": 0,
  38485. "msg": "撤销备案成功",
  38486. })
  38487. } else {
  38488. c.ServeSuccessJSON(map[string]interface{}{
  38489. "failed_code": -10,
  38490. "msg": res.ErrMsg,
  38491. })
  38492. return
  38493. }
  38494. }
  38495. }
  38496. func (c *HisApiController) TestTest() {
  38497. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  38498. fmt.Println(patient.Iinfo)
  38499. }
  38500. type CustomData struct {
  38501. MsgId string
  38502. PsnNo string
  38503. Info string
  38504. }
  38505. func (c *HisApiController) ReversalData() {
  38506. var customData []*CustomData
  38507. custom := &CustomData{
  38508. MsgId: "H44022900158202103301714472004",
  38509. PsnNo: "44020000001101329945",
  38510. Info: "2207",
  38511. }
  38512. customData = append(customData, custom)
  38513. custom1 := &CustomData{
  38514. MsgId: "H4402290015820210330172057803",
  38515. PsnNo: "44020000001101161813",
  38516. Info: "2207",
  38517. }
  38518. customData = append(customData, custom1)
  38519. custom2 := &CustomData{
  38520. MsgId: "H44022900158202103301705198813",
  38521. PsnNo: "44190000133097375417",
  38522. Info: "2207",
  38523. }
  38524. customData = append(customData, custom2)
  38525. custom3 := &CustomData{
  38526. MsgId: "H44022900158202103301715524756",
  38527. PsnNo: "44020000001100187221",
  38528. Info: "2207",
  38529. }
  38530. customData = append(customData, custom3)
  38531. custom4 := &CustomData{
  38532. MsgId: "H44022900158202103301730376224",
  38533. PsnNo: "44020000001101959155",
  38534. Info: "2207",
  38535. }
  38536. customData = append(customData, custom4)
  38537. custom5 := &CustomData{
  38538. MsgId: "H44022900158202103301748008725",
  38539. PsnNo: "44020000001104246641",
  38540. Info: "2207",
  38541. }
  38542. customData = append(customData, custom5)
  38543. custom6 := &CustomData{
  38544. MsgId: "H44022900158202103301718096755",
  38545. PsnNo: "44020000001102211860",
  38546. Info: "2207",
  38547. }
  38548. customData = append(customData, custom6)
  38549. custom7 := &CustomData{
  38550. MsgId: "H44022900158202103301736551640",
  38551. PsnNo: "44020000001102687718",
  38552. Info: "2207",
  38553. }
  38554. customData = append(customData, custom7)
  38555. custom8 := &CustomData{
  38556. MsgId: "H44022900158202103301743097676",
  38557. PsnNo: "44020000001102127785",
  38558. Info: "2207",
  38559. }
  38560. customData = append(customData, custom8)
  38561. custom9 := &CustomData{
  38562. MsgId: "H44022900158202103301712304203",
  38563. PsnNo: "44020000001101518097",
  38564. Info: "2207",
  38565. }
  38566. customData = append(customData, custom9)
  38567. custom10 := &CustomData{
  38568. MsgId: "H44022900158202103301738448785",
  38569. PsnNo: "44020000001100500813",
  38570. Info: "2207",
  38571. }
  38572. customData = append(customData, custom10)
  38573. custom11 := &CustomData{
  38574. MsgId: "H44022900158202103301732455843",
  38575. PsnNo: "44020000001102690557",
  38576. Info: "2207",
  38577. }
  38578. customData = append(customData, custom11)
  38579. custom12 := &CustomData{
  38580. MsgId: "H44022900158202103301745421708",
  38581. PsnNo: "44020000001102211928",
  38582. Info: "2207",
  38583. }
  38584. customData = append(customData, custom12)
  38585. custom1212 := &CustomData{
  38586. MsgId: "H440229001582021033017351627",
  38587. PsnNo: "44020000001102481733",
  38588. Info: "2207",
  38589. }
  38590. customData = append(customData, custom1212)
  38591. custom13 := &CustomData{
  38592. MsgId: "H44022900158202103301740327951",
  38593. PsnNo: "44020000001103174866",
  38594. Info: "2207",
  38595. }
  38596. customData = append(customData, custom13)
  38597. custom14 := &CustomData{
  38598. MsgId: "H4402290015820210330174922668",
  38599. PsnNo: "44020000001102927272",
  38600. Info: "2207",
  38601. }
  38602. customData = append(customData, custom14)
  38603. custom15 := &CustomData{
  38604. MsgId: "H44022900158202103301752362273",
  38605. PsnNo: "44020000001102942890",
  38606. Info: "2207",
  38607. }
  38608. customData = append(customData, custom15)
  38609. custom16 := &CustomData{
  38610. MsgId: "H44022900158202103301751082917",
  38611. PsnNo: "44020000001101662162",
  38612. Info: "2207",
  38613. }
  38614. customData = append(customData, custom16)
  38615. custom17 := &CustomData{
  38616. MsgId: "H44022900158202103301754147728",
  38617. PsnNo: "44020000000229014511",
  38618. Info: "2207",
  38619. }
  38620. customData = append(customData, custom17)
  38621. adminUser := c.GetAdminUserInfo()
  38622. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38623. for _, item := range customData {
  38624. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  38625. fmt.Println(result)
  38626. }
  38627. }
  38628. func (c *HisApiController) GetAllopatry() {
  38629. year := c.GetString("year")
  38630. month := c.GetString("month")
  38631. admin_user_id, _ := c.GetInt64("admin_user_id")
  38632. adminUser := c.GetAdminUserInfo()
  38633. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38634. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38635. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38636. var dat map[string]interface{}
  38637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38638. fmt.Println(dat)
  38639. } else {
  38640. fmt.Println(err)
  38641. }
  38642. userJSONBytes, _ := json.Marshal(dat)
  38643. var res models.Result9001
  38644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38645. utils.ErrorLog("解析失败:%v", err)
  38646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38647. return
  38648. }
  38649. fmt.Println(res.Output.Signinoutb)
  38650. fmt.Println(res.Output.Signinoutb.SignNo)
  38651. fmt.Println(string(userJSONBytes))
  38652. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  38653. var dat3 map[string]interface{}
  38654. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  38655. fmt.Println(dat3)
  38656. } else {
  38657. fmt.Println(err)
  38658. }
  38659. userJSONBytes3, _ := json.Marshal(dat3)
  38660. var res3 models.Result3260
  38661. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  38662. utils.ErrorLog("解析失败:%v", err)
  38663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38664. return
  38665. }
  38666. var curpage int
  38667. var pagesize int = 100
  38668. var start int = 1
  38669. //var stop int
  38670. //pagecount := 10
  38671. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  38672. var res22 []models.Result3260
  38673. for curpage = 1; curpage <= pagecount; curpage++ {
  38674. if curpage == 1 {
  38675. start = 0
  38676. } else {
  38677. start = (curpage-1)*pagesize + 1
  38678. }
  38679. fmt.Println(start)
  38680. //stop = curpage * pagesize
  38681. //if stop > int(res3.Output.Totalrow) {
  38682. // stop =int(res3.Output.Totalrow)
  38683. //}
  38684. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  38685. var dat2 map[string]interface{}
  38686. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38687. fmt.Println(dat)
  38688. } else {
  38689. fmt.Println(err)
  38690. }
  38691. userJSONBytes2, _ := json.Marshal(dat2)
  38692. var res2 models.Result3260
  38693. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38694. utils.ErrorLog("解析失败:%v", err)
  38695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38696. return
  38697. }
  38698. if res2.Infcode == 0 {
  38699. res22 = append(res22, res2)
  38700. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  38701. //var dat2 map[string]interface{}
  38702. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  38703. // fmt.Println(dat)
  38704. //} else {
  38705. // fmt.Println(err)
  38706. //}
  38707. //c.ServeSuccessJSON(map[string]interface{}{
  38708. // "list": res2.Output.Data,
  38709. //})
  38710. //continue
  38711. }
  38712. }
  38713. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  38714. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  38715. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  38716. //var dat2 map[string]interface{}
  38717. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38718. // fmt.Println(dat)
  38719. //} else {
  38720. // fmt.Println(err)
  38721. //}
  38722. //userJSONBytes2, _ := json.Marshal(dat2)
  38723. //var res2 models.Result3260
  38724. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38725. // utils.ErrorLog("解析失败:%v", err)
  38726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38727. // return
  38728. //}
  38729. //if res2.Infcode == 0 {
  38730. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  38731. // var dat2 map[string]interface{}
  38732. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  38733. // fmt.Println(dat)
  38734. // } else {
  38735. // fmt.Println(err)
  38736. // }
  38737. // c.ServeSuccessJSON(map[string]interface{}{
  38738. // "list": res2.Output.Data,
  38739. // })
  38740. //}
  38741. }
  38742. func (c *HisApiController) ComfirmAllopatry() {
  38743. year := c.GetString("year")
  38744. month := c.GetString("month")
  38745. admin_user_id, _ := c.GetInt64("admin_user_id")
  38746. adminUser := c.GetAdminUserInfo()
  38747. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38748. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38749. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38750. var dat map[string]interface{}
  38751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38752. fmt.Println(dat)
  38753. } else {
  38754. fmt.Println(err)
  38755. }
  38756. userJSONBytes, _ := json.Marshal(dat)
  38757. var res models.Result9001
  38758. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38759. utils.ErrorLog("解析失败:%v", err)
  38760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38761. return
  38762. }
  38763. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  38764. var dat2 map[string]interface{}
  38765. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38766. fmt.Println(dat)
  38767. } else {
  38768. fmt.Println(err)
  38769. }
  38770. userJSONBytes2, _ := json.Marshal(dat2)
  38771. var res2 models.Result3260
  38772. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38773. utils.ErrorLog("解析失败:%v", err)
  38774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38775. return
  38776. }
  38777. //if res2.Infcode == 0 {
  38778. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  38779. // var dat map[string]interface{}
  38780. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38781. // fmt.Println(dat)
  38782. // } else {
  38783. // fmt.Println(err)
  38784. // }
  38785. // userJSONBytes, _ := json.Marshal(dat)
  38786. // var res3 models.Result3261
  38787. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  38788. // utils.ErrorLog("解析失败:%v", err)
  38789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38790. // return
  38791. // }
  38792. //
  38793. // if res3.Infcode == 0 {
  38794. // record := &models.HisYidiClearRecord{
  38795. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  38796. // Ctime: time.Now().Unix(),
  38797. // Mtime: time.Now().Unix(),
  38798. // Status: 1,
  38799. // MsgId: msgId,
  38800. // }
  38801. // service.SaveClearRecord(record)
  38802. // c.ServeSuccessJSON(map[string]interface{}{
  38803. // "msg": "提取成功",
  38804. // })
  38805. // }
  38806. //}
  38807. }
  38808. func (c *HisApiController) RefundAllopatry() {
  38809. year := c.GetString("year")
  38810. month := c.GetString("month")
  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. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38816. //record, _ := service.GetClearRecordById(id)
  38817. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38818. var dat map[string]interface{}
  38819. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  38820. fmt.Println(dat)
  38821. } else {
  38822. fmt.Println(err)
  38823. }
  38824. userJSONBytes, _ := json.Marshal(dat)
  38825. var res models.Result9001
  38826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38827. utils.ErrorLog("解析失败:%v", err)
  38828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38829. return
  38830. }
  38831. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  38832. var dat2 map[string]interface{}
  38833. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  38834. fmt.Println(dat)
  38835. } else {
  38836. fmt.Println(err)
  38837. }
  38838. userJSONBytes2, _ := json.Marshal(dat2)
  38839. var empty ResultFourteen
  38840. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  38841. utils.ErrorLog("解析失败:%v", err)
  38842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38843. return
  38844. }
  38845. if empty.Infcode == 0 {
  38846. c.ServeSuccessJSON(map[string]interface{}{
  38847. "msg": "撤销成功",
  38848. })
  38849. return
  38850. }
  38851. }
  38852. func (c *HisApiController) ReversalOtherData() {
  38853. var customData []*CustomData
  38854. custom := &CustomData{
  38855. MsgId: "H44022900158202103301714472004",
  38856. PsnNo: "44020000001101329945",
  38857. Info: "2208",
  38858. }
  38859. customData = append(customData, custom)
  38860. custom1 := &CustomData{
  38861. MsgId: "H4402290015820210330172057803",
  38862. PsnNo: "44020000001101161813",
  38863. Info: "2208",
  38864. }
  38865. customData = append(customData, custom1)
  38866. custom2 := &CustomData{
  38867. MsgId: "H44022900158202103301705198813",
  38868. PsnNo: "44190000133097375417",
  38869. Info: "2208",
  38870. }
  38871. customData = append(customData, custom2)
  38872. custom3 := &CustomData{
  38873. MsgId: "H44022900158202103301715524756",
  38874. PsnNo: "44020000001100187221",
  38875. Info: "2208",
  38876. }
  38877. customData = append(customData, custom3)
  38878. custom4 := &CustomData{
  38879. MsgId: "H44022900158202103301730376224",
  38880. PsnNo: "44020000001101959155",
  38881. Info: "2208",
  38882. }
  38883. customData = append(customData, custom4)
  38884. custom5 := &CustomData{
  38885. MsgId: "H44022900158202103301748008725",
  38886. PsnNo: "44020000001104246641",
  38887. Info: "2208",
  38888. }
  38889. customData = append(customData, custom5)
  38890. custom6 := &CustomData{
  38891. MsgId: "H44022900158202103301718096755",
  38892. PsnNo: "44020000001102211860",
  38893. Info: "2208",
  38894. }
  38895. customData = append(customData, custom6)
  38896. custom7 := &CustomData{
  38897. MsgId: "H44022900158202103301736551640",
  38898. PsnNo: "44020000001102687718",
  38899. Info: "2208",
  38900. }
  38901. customData = append(customData, custom7)
  38902. custom8 := &CustomData{
  38903. MsgId: "H44022900158202103301743097676",
  38904. PsnNo: "44020000001102127785",
  38905. Info: "2208",
  38906. }
  38907. customData = append(customData, custom8)
  38908. custom9 := &CustomData{
  38909. MsgId: "H44022900158202103301712304203",
  38910. PsnNo: "44020000001101518097",
  38911. Info: "2208",
  38912. }
  38913. customData = append(customData, custom9)
  38914. custom10 := &CustomData{
  38915. MsgId: "H44022900158202103301738448785",
  38916. PsnNo: "44020000001100500813",
  38917. Info: "2208",
  38918. }
  38919. customData = append(customData, custom10)
  38920. custom11 := &CustomData{
  38921. MsgId: "H44022900158202103301732455843",
  38922. PsnNo: "44020000001102690557",
  38923. Info: "2208",
  38924. }
  38925. customData = append(customData, custom11)
  38926. custom12 := &CustomData{
  38927. MsgId: "H44022900158202103301745421708",
  38928. PsnNo: "44020000001102211928",
  38929. Info: "2208",
  38930. }
  38931. customData = append(customData, custom12)
  38932. custom1212 := &CustomData{
  38933. MsgId: "H440229001582021033017351627",
  38934. PsnNo: "44020000001102481733",
  38935. Info: "2208",
  38936. }
  38937. customData = append(customData, custom1212)
  38938. custom13 := &CustomData{
  38939. MsgId: "H44022900158202103301740327951",
  38940. PsnNo: "44020000001103174866",
  38941. Info: "2208",
  38942. }
  38943. customData = append(customData, custom13)
  38944. custom14 := &CustomData{
  38945. MsgId: "H4402290015820210330174922668",
  38946. PsnNo: "44020000001102927272",
  38947. Info: "2208",
  38948. }
  38949. customData = append(customData, custom14)
  38950. custom15 := &CustomData{
  38951. MsgId: "H44022900158202103301752362273",
  38952. PsnNo: "44020000001102942890",
  38953. Info: "2208",
  38954. }
  38955. customData = append(customData, custom15)
  38956. custom16 := &CustomData{
  38957. MsgId: "H44022900158202103301751082917",
  38958. PsnNo: "44020000001101662162",
  38959. Info: "2208",
  38960. }
  38961. customData = append(customData, custom16)
  38962. custom17 := &CustomData{
  38963. MsgId: "H44022900158202103301754147728",
  38964. PsnNo: "44020000000229014511",
  38965. Info: "2208",
  38966. }
  38967. customData = append(customData, custom17)
  38968. adminUser := c.GetAdminUserInfo()
  38969. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38970. for _, item := range customData {
  38971. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  38972. fmt.Println(result)
  38973. }
  38974. }
  38975. func PathExists(path string) (bool, error) {
  38976. _, err := os.Stat(path)
  38977. if err == nil {
  38978. return true, nil
  38979. }
  38980. if os.IsNotExist(err) {
  38981. return false, nil
  38982. }
  38983. return false, err
  38984. }
  38985. // 创建文件夹
  38986. func Mkdir(dir string) {
  38987. // 创建文件夹
  38988. exist, err := PathExists(dir)
  38989. if err != nil {
  38990. fmt.Println(err.Error())
  38991. } else {
  38992. if exist {
  38993. fmt.Println(dir + "文件夹已存在!")
  38994. } else {
  38995. // 文件夹名称,权限
  38996. err := os.Mkdir(dir, os.ModePerm)
  38997. if err != nil {
  38998. fmt.Println(dir+"文件夹创建失败:", err.Error())
  38999. } else {
  39000. fmt.Println(dir + "文件夹创建成功!")
  39001. }
  39002. }
  39003. }
  39004. }
  39005. // 压缩文件
  39006. func Zip(srcFile string, destZip string) error {
  39007. zipfile, err := os.Create(destZip)
  39008. if err != nil {
  39009. return err
  39010. }
  39011. defer zipfile.Close()
  39012. archive := zip.NewWriter(zipfile)
  39013. defer archive.Close()
  39014. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  39015. if err != nil {
  39016. return err
  39017. }
  39018. header, err := zip.FileInfoHeader(info)
  39019. if err != nil {
  39020. return err
  39021. }
  39022. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  39023. // header.Name = path
  39024. if info.IsDir() {
  39025. header.Name += "/"
  39026. } else {
  39027. header.Method = zip.Deflate
  39028. }
  39029. writer, err := archive.CreateHeader(header)
  39030. if err != nil {
  39031. return err
  39032. }
  39033. if !info.IsDir() {
  39034. file, err := os.Open(path)
  39035. if err != nil {
  39036. return err
  39037. }
  39038. defer file.Close()
  39039. _, err = io.Copy(writer, file)
  39040. }
  39041. return err
  39042. })
  39043. return err
  39044. }
  39045. func ReadFile(filePath string) []byte {
  39046. f, err := os.Open(filePath)
  39047. if err != nil {
  39048. fmt.Println("read file fail", err)
  39049. return nil
  39050. }
  39051. defer f.Close()
  39052. fd, err := ioutil.ReadAll(f)
  39053. if err != nil {
  39054. fmt.Println("read to fd fail", err)
  39055. return nil
  39056. }
  39057. return fd
  39058. }
  39059. func saveLogq(result string, request string, infno string, desc string) {
  39060. dir := "日志"
  39061. utils.Mkdir(dir)
  39062. month := time.Unix(1557042972, 0).Format("1")
  39063. year := time.Now().Format("2006")
  39064. month = time.Now().Format("01")
  39065. day := time.Now().Format("02")
  39066. hour := time.Now().Format("15")
  39067. min := time.Now().Format("04")
  39068. sec := time.Now().Format("05")
  39069. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39070. file := year + month + day + "_log"
  39071. file_name := file + ".txt"
  39072. file_path := "日志" + "/" + file_name
  39073. exist, _ := utils.PathExists(file_path)
  39074. if exist { //存在
  39075. fmt.Println("存在")
  39076. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39077. if err != nil {
  39078. fmt.Println("read fail")
  39079. }
  39080. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39081. n, _ := f.Seek(0, 2)
  39082. _, err = f.WriteAt([]byte(content), n)
  39083. } else { //不存在
  39084. fmt.Println("文件不存在,创建文件")
  39085. f, err := os.Create("日志" + "/" + file_name)
  39086. defer f.Close()
  39087. if err != nil {
  39088. } else {
  39089. _, err = f.Write([]byte("记录日志"))
  39090. }
  39091. }
  39092. }
  39093. func saveLog(result string, request string, infno string, desc string) {
  39094. org_id, _ := beego.AppConfig.Int64("org_id")
  39095. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39096. dir := miConfig.OrgName + "日志"
  39097. utils.Mkdir(dir)
  39098. month := time.Unix(1557042972, 0).Format("1")
  39099. year := time.Now().Format("2006")
  39100. month = time.Now().Format("01")
  39101. day := time.Now().Format("02")
  39102. hour := time.Now().Format("15")
  39103. min := time.Now().Format("04")
  39104. sec := time.Now().Format("05")
  39105. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39106. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  39107. file_name := file + ".txt"
  39108. file_path := miConfig.OrgName + "日志" + "/" + file_name
  39109. exist, _ := utils.PathExists(file_path)
  39110. if exist { //存在
  39111. fmt.Println("存在")
  39112. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39113. if err != nil {
  39114. fmt.Println("read fail")
  39115. }
  39116. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39117. n, _ := f.Seek(0, 2)
  39118. _, err = f.WriteAt([]byte(content), n)
  39119. } else { //不存在
  39120. fmt.Println("文件不存在,创建文件")
  39121. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  39122. defer f.Close()
  39123. if err != nil {
  39124. } else {
  39125. _, err = f.Write([]byte("记录日志"))
  39126. }
  39127. }
  39128. }
  39129. type Charset string
  39130. const (
  39131. UTF8 = Charset("UTF-8")
  39132. GB18030 = Charset("GB18030")
  39133. )
  39134. func ConvertToString(src string, srcCode string, tagCode string) string {
  39135. srcCoder := mahonia.NewDecoder(srcCode)
  39136. srcResult := srcCoder.ConvertString(src)
  39137. tagCoder := mahonia.NewDecoder(tagCode)
  39138. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  39139. result := string(cdata)
  39140. return result
  39141. }
  39142. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  39143. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39144. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39145. var token string
  39146. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39147. var api string
  39148. if miConfig.MdtrtareaAdmvs == "320830" {
  39149. api = miConfig.AppSecret + "jsyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39150. "&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
  39151. fmt.Println(api)
  39152. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39153. 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 +
  39154. "&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
  39155. fmt.Println(api)
  39156. } else {
  39157. 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 +
  39158. "&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
  39159. }
  39160. resp, requestErr := http.Get(api)
  39161. if requestErr != nil {
  39162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39163. return ""
  39164. }
  39165. body, ioErr := ioutil.ReadAll(resp.Body)
  39166. if ioErr != nil {
  39167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39169. return ""
  39170. }
  39171. var respJSON map[string]interface{}
  39172. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39175. return ""
  39176. }
  39177. var status string
  39178. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39179. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39180. var res ResultTwo //1101结果
  39181. var res10265 ResultTwo10265 //1101结果
  39182. if status == "0" { //读卡成功
  39183. var card_info string //卡信息
  39184. var busi_card_info string
  39185. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39186. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39187. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39188. fmt.Println(card_info)
  39189. fmt.Println(busi_card_info)
  39190. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39191. result, _ := json.Marshal(respJSON)
  39192. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39193. utils.ErrorLog("解析失败:%v", err)
  39194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39195. return ""
  39196. }
  39197. res.ErrMsg = res10265.ErrMsg
  39198. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39199. res.Infcode = infocode
  39200. res.Output = res10265.Output
  39201. res.InfRefmsgid = res10265.InfRefmsgid
  39202. if res.Infcode == 0 {
  39203. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39204. if err == gorm.ErrRecordNotFound {
  39205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39206. return ""
  39207. } else if err != nil {
  39208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39209. return ""
  39210. } else {
  39211. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39212. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39213. infoStr := string(Iinfos)
  39214. idetinfoStr := string(Idetinfos)
  39215. psn := &models.HisPsn{
  39216. PsnNo: res.Output.Baseinfo.PsnNo,
  39217. PatientId: patient.ID,
  39218. Certno: res.Output.Baseinfo.Certno,
  39219. Gend: res.Output.Baseinfo.Gend,
  39220. Naty: res.Output.Baseinfo.Naty,
  39221. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39222. PsnName: res.Output.Baseinfo.PsnName,
  39223. Idetinfo: idetinfoStr,
  39224. Insuinfo: infoStr,
  39225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39226. CardInfo: card_info,
  39227. VerifyNumber: token,
  39228. }
  39229. service.CreateHisPsn(psn)
  39230. return token
  39231. }
  39232. }
  39233. } else {
  39234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39235. return ""
  39236. }
  39237. } else { //读卡失败
  39238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39239. return ""
  39240. }
  39241. return token
  39242. }
  39243. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  39244. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39245. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39246. var token string
  39247. var api string
  39248. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39249. "&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
  39250. fmt.Println(api)
  39251. resp, requestErr := http.Get(api)
  39252. if requestErr != nil {
  39253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39254. return ""
  39255. }
  39256. body, ioErr := ioutil.ReadAll(resp.Body)
  39257. if ioErr != nil {
  39258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39260. return ""
  39261. }
  39262. var respJSON map[string]interface{}
  39263. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39266. return ""
  39267. }
  39268. var status string
  39269. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39270. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39271. var res ResultTwo //1101结果
  39272. if status == "1" { //读卡成功
  39273. var card_info string //卡信息
  39274. var busi_card_info string
  39275. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39276. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39277. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39278. fmt.Println(card_info)
  39279. fmt.Println(busi_card_info)
  39280. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39281. result, _ := json.Marshal(respJSON)
  39282. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39283. utils.ErrorLog("解析失败:%v", err)
  39284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39285. return ""
  39286. }
  39287. if res.Infcode == 0 {
  39288. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39289. if err == gorm.ErrRecordNotFound {
  39290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39291. return ""
  39292. } else if err != nil {
  39293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39294. return ""
  39295. } else {
  39296. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39297. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39298. infoStr := string(Iinfos)
  39299. idetinfoStr := string(Idetinfos)
  39300. psn := &models.HisPsn{
  39301. PsnNo: res.Output.Baseinfo.PsnNo,
  39302. PatientId: patient.ID,
  39303. Certno: res.Output.Baseinfo.Certno,
  39304. Gend: res.Output.Baseinfo.Gend,
  39305. Naty: res.Output.Baseinfo.Naty,
  39306. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39307. PsnName: res.Output.Baseinfo.PsnName,
  39308. Idetinfo: idetinfoStr,
  39309. Insuinfo: infoStr,
  39310. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39311. CardInfo: card_info,
  39312. VerifyNumber: token,
  39313. }
  39314. service.CreateHisPsn(psn)
  39315. return token
  39316. }
  39317. }
  39318. } else {
  39319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39320. return ""
  39321. }
  39322. return token
  39323. }
  39324. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  39325. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39326. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39327. var token string
  39328. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39329. var api string
  39330. if miConfig.MdtrtareaAdmvs == "320830" {
  39331. api = miConfig.AppSecret + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39332. "&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
  39333. fmt.Println(api)
  39334. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39335. 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 +
  39336. "&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
  39337. fmt.Println(api)
  39338. } else {
  39339. 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 +
  39340. "&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
  39341. }
  39342. resp, requestErr := http.Get(api)
  39343. if requestErr != nil {
  39344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39345. return ""
  39346. }
  39347. body, ioErr := ioutil.ReadAll(resp.Body)
  39348. if ioErr != nil {
  39349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39351. return ""
  39352. }
  39353. var respJSON map[string]interface{}
  39354. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39357. return ""
  39358. }
  39359. var status string
  39360. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39361. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39362. var res ResultTwo //1101结果
  39363. var res10265 ResultTwo10265 //1101结果
  39364. if status == "0" { //读卡成功
  39365. var card_info string //卡信息
  39366. var busi_card_info string
  39367. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39368. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39369. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39370. fmt.Println(card_info)
  39371. fmt.Println(busi_card_info)
  39372. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39373. result, _ := json.Marshal(respJSON)
  39374. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39375. utils.ErrorLog("解析失败:%v", err)
  39376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39377. return ""
  39378. }
  39379. res.ErrMsg = res10265.ErrMsg
  39380. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39381. res.Infcode = infocode
  39382. res.Output = res10265.Output
  39383. res.InfRefmsgid = res10265.InfRefmsgid
  39384. if res.Infcode == 0 {
  39385. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39386. if err == gorm.ErrRecordNotFound {
  39387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39388. return ""
  39389. } else if err != nil {
  39390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39391. return ""
  39392. } else {
  39393. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39394. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39395. infoStr := string(Iinfos)
  39396. idetinfoStr := string(Idetinfos)
  39397. psn := &models.HisPsn{
  39398. PsnNo: res.Output.Baseinfo.PsnNo,
  39399. PatientId: patient.ID,
  39400. Certno: res.Output.Baseinfo.Certno,
  39401. Gend: res.Output.Baseinfo.Gend,
  39402. Naty: res.Output.Baseinfo.Naty,
  39403. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39404. PsnName: res.Output.Baseinfo.PsnName,
  39405. Idetinfo: idetinfoStr,
  39406. Insuinfo: infoStr,
  39407. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39408. CardInfo: card_info,
  39409. VerifyNumber: token,
  39410. }
  39411. service.CreateHisPsn(psn)
  39412. return token
  39413. }
  39414. }
  39415. } else {
  39416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39417. return ""
  39418. }
  39419. } else { //读卡失败
  39420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39421. return ""
  39422. }
  39423. return token
  39424. }
  39425. func DeleteExtraSpaceTwo(s string) string {
  39426. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39427. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39428. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39429. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39430. s2 := make([]byte, len(s1)) //定义字符数组切片
  39431. copy(s2, s1) //将字符串复制到切片
  39432. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39433. for len(spc_index) > 0 { //找到适配项
  39434. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39435. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39436. }
  39437. return string(s2)
  39438. }
  39439. func Remove0000(s string) string {
  39440. str := make([]rune, 0, len(s))
  39441. for _, v := range []rune(s) {
  39442. if v == 0 {
  39443. continue
  39444. }
  39445. str = append(str, v)
  39446. }
  39447. return string(str)
  39448. }
  39449. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  39450. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  39451. readCard := DllDef.MustFindProc("EcQuery")
  39452. pCardInfo := make([]byte, 8192)
  39453. pBusiCardInfo := make([]byte, 8192)
  39454. data := make(map[string]interface{})
  39455. //pData := make(map[string]interface{})
  39456. inputData := make(map[string]interface{})
  39457. inputData["orgId"] = code
  39458. inputData["businessType"] = "01101"
  39459. inputData["operatorId"] = operator_id
  39460. inputData["operatorName"] = operator_name
  39461. inputData["officeId"] = "001"
  39462. inputData["officeName"] = "血透室"
  39463. //
  39464. data["data"] = inputData
  39465. data["transType"] = "ec.query"
  39466. data["orgId"] = code
  39467. bytesData, _ := json.Marshal(data)
  39468. pCardInfo = bytesData
  39469. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  39470. fmt.Println(ret2)
  39471. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  39472. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  39473. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  39474. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  39475. if ret2 != 0 {
  39476. return "", ""
  39477. }
  39478. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  39479. }
  39480. func DeleteExtraSpace(s string) string {
  39481. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39482. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39483. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39484. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39485. s2 := make([]byte, len(s1)) //定义字符数组切片
  39486. copy(s2, s1) //将字符串复制到切片
  39487. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39488. for len(spc_index) > 0 { //找到适配项
  39489. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39490. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39491. }
  39492. return string(s2)
  39493. }
  39494. // 对账
  39495. func (c *HisApiController) Post3202() {
  39496. start_time := c.GetString("start_time")
  39497. end_time := c.GetString("end_time")
  39498. //insutype := c.GetString("insutype")
  39499. clr_type := c.GetString("clr_type")
  39500. clr_org := c.GetString("clr_optins")
  39501. admin_user_id, _ := c.GetInt64("admin_user_id")
  39502. adminUser := c.GetAdminUserInfo()
  39503. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39504. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39505. if len(clr_org) == 0 {
  39506. clr_org = miConfig.MdtrtareaAdmvs
  39507. }
  39508. timeLayout := "2006-01-02"
  39509. loc, _ := time.LoadLocation("Local")
  39510. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39511. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39512. var orders []*models.HisOrder
  39513. if clr_org == "421300" {
  39514. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39515. } else if clr_org == "420902" {
  39516. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39517. } else {
  39518. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39519. }
  39520. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39521. //fixmedins_setl_cnt := int64(len(orders))
  39522. var medfee_sumamt float64
  39523. var acct_pay float64
  39524. var fund_pay_sumamt float64
  39525. for _, item := range orders {
  39526. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39527. acct_pay = acct_pay + item.AcctPay
  39528. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39529. }
  39530. //var medfee_sumamt_two float64
  39531. //var acct_pay_two float64
  39532. //var fund_pay_sumamt_two float64
  39533. //for _, item := range orders_two {
  39534. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39535. // acct_pay_two = acct_pay_two + item.AcctPay
  39536. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39537. //}
  39538. //var user_name string
  39539. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39540. //if role.ID == 0 {
  39541. // user_name = "xxx"
  39542. //} else {
  39543. // user_name = role.UserName
  39544. //}
  39545. var res ResultSix
  39546. if config.IsOpen == 1 {
  39547. var bps []*models.BusinessParamsTwo
  39548. var bp models.BusinessParamsTwo
  39549. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39550. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39551. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39552. bp.MedfeeSumamt = medfee_sumamt_str
  39553. bp.AcctPay = acct_pay_str
  39554. bp.FundPaySumamt = fund_pay_sumamt_str
  39555. bp.Insutype = ""
  39556. bp.StmtBegndate = start_time
  39557. bp.ClrType = clr_type
  39558. bp.SetlOptins = clr_org
  39559. bp.StmtEnddate = end_time
  39560. bps = append(bps, &bp)
  39561. data := make(map[string]interface{})
  39562. data["bps"] = bps
  39563. data["org_name"] = miConfig.OrgName
  39564. data["doctor"] = role.UserName
  39565. data["fixmedins_code"] = miConfig.Code
  39566. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39567. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39568. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39569. if miConfig.MdtrtareaAdmvs == "421300" {
  39570. client := &http.Client{}
  39571. bytesData, _ := json.Marshal(data)
  39572. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39573. resp, _ := client.Do(req)
  39574. defer resp.Body.Close()
  39575. body, ioErr := ioutil.ReadAll(resp.Body)
  39576. if ioErr != nil {
  39577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39579. return
  39580. }
  39581. var respJSON map[string]interface{}
  39582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39585. return
  39586. }
  39587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39588. userJSONBytes, _ := json.Marshal(respJSON)
  39589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39590. utils.ErrorLog("解析失败:%v", err)
  39591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39592. return
  39593. }
  39594. }
  39595. if miConfig.MdtrtareaAdmvs == "420200" {
  39596. client := &http.Client{}
  39597. bytesData, _ := json.Marshal(data)
  39598. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39599. resp, _ := client.Do(req)
  39600. defer resp.Body.Close()
  39601. body, ioErr := ioutil.ReadAll(resp.Body)
  39602. if ioErr != nil {
  39603. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39605. return
  39606. }
  39607. var respJSON map[string]interface{}
  39608. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39611. return
  39612. }
  39613. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39614. userJSONBytes, _ := json.Marshal(respJSON)
  39615. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39616. utils.ErrorLog("解析失败:%v", err)
  39617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39618. return
  39619. }
  39620. }
  39621. if miConfig.MdtrtareaAdmvs == "421182" {
  39622. client := &http.Client{}
  39623. bytesData, _ := json.Marshal(data)
  39624. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39625. resp, _ := client.Do(req)
  39626. defer resp.Body.Close()
  39627. body, ioErr := ioutil.ReadAll(resp.Body)
  39628. if ioErr != nil {
  39629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39631. return
  39632. }
  39633. var respJSON map[string]interface{}
  39634. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39637. return
  39638. }
  39639. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39640. userJSONBytes, _ := json.Marshal(respJSON)
  39641. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39642. utils.ErrorLog("解析失败:%v", err)
  39643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39644. return
  39645. }
  39646. }
  39647. if miConfig.MdtrtareaAdmvs == "420902" {
  39648. client := &http.Client{}
  39649. bytesData, _ := json.Marshal(data)
  39650. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39651. resp, _ := client.Do(req)
  39652. defer resp.Body.Close()
  39653. body, ioErr := ioutil.ReadAll(resp.Body)
  39654. if ioErr != nil {
  39655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39657. return
  39658. }
  39659. var respJSON map[string]interface{}
  39660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39663. return
  39664. }
  39665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39666. userJSONBytes, _ := json.Marshal(respJSON)
  39667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39668. utils.ErrorLog("解析失败:%v", err)
  39669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39670. return
  39671. }
  39672. }
  39673. if res.Infcode == 0 {
  39674. c.ServeSuccessJSON(map[string]interface{}{
  39675. "msg": "发起成功",
  39676. })
  39677. } else {
  39678. c.ServeSuccessJSON(map[string]interface{}{
  39679. "failed_code": -10,
  39680. "msg": res.ErrMsg,
  39681. })
  39682. }
  39683. }
  39684. }
  39685. func (c *HisApiController) Post3204a() {
  39686. start_time := c.GetString("start_time")
  39687. end_time := c.GetString("end_time")
  39688. //insutype := c.GetString("insutype")
  39689. clr_type := c.GetString("clr_type")
  39690. clr_org := c.GetString("clr_optins")
  39691. admin_user_id, _ := c.GetInt64("admin_user_id")
  39692. adminUser := c.GetAdminUserInfo()
  39693. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39694. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39695. if len(clr_org) == 0 {
  39696. clr_org = miConfig.MdtrtareaAdmvs
  39697. }
  39698. timeLayout := "2006-01-02"
  39699. loc, _ := time.LoadLocation("Local")
  39700. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39701. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39702. var orders []*models.HisOrder
  39703. if clr_org == "421300" {
  39704. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39705. } else if clr_org == "420902" {
  39706. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39707. } else {
  39708. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39709. }
  39710. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39711. //fixmedins_setl_cnt := int64(len(orders))
  39712. var medfee_sumamt float64
  39713. var acct_pay float64
  39714. var fund_pay_sumamt float64
  39715. for _, item := range orders {
  39716. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39717. acct_pay = acct_pay + item.AcctPay
  39718. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39719. }
  39720. //var medfee_sumamt_two float64
  39721. //var acct_pay_two float64
  39722. //var fund_pay_sumamt_two float64
  39723. //for _, item := range orders_two {
  39724. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39725. // acct_pay_two = acct_pay_two + item.AcctPay
  39726. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39727. //}
  39728. //var user_name string
  39729. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39730. //if role.ID == 0 {
  39731. // user_name = "xxx"
  39732. //} else {
  39733. // user_name = role.UserName
  39734. //}
  39735. var res ResultSix
  39736. if config.IsOpen == 1 {
  39737. var bps []*models.BusinessParamsTwo
  39738. var bp models.BusinessParamsTwo
  39739. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39740. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39741. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39742. bp.MedfeeSumamt = medfee_sumamt_str
  39743. bp.AcctPay = acct_pay_str
  39744. bp.FundPaySumamt = fund_pay_sumamt_str
  39745. bp.Insutype = ""
  39746. bp.StmtBegndate = start_time
  39747. bp.ClrType = clr_type
  39748. bp.SetlOptins = clr_org
  39749. bp.StmtEnddate = end_time
  39750. bps = append(bps, &bp)
  39751. data := make(map[string]interface{})
  39752. data["bps"] = bps
  39753. data["org_name"] = miConfig.OrgName
  39754. data["doctor"] = role.UserName
  39755. data["fixmedins_code"] = miConfig.Code
  39756. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39757. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39758. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39759. if miConfig.MdtrtareaAdmvs == "421300" {
  39760. client := &http.Client{}
  39761. bytesData, _ := json.Marshal(data)
  39762. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  39763. resp, _ := client.Do(req)
  39764. defer resp.Body.Close()
  39765. body, ioErr := ioutil.ReadAll(resp.Body)
  39766. if ioErr != nil {
  39767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39769. return
  39770. }
  39771. var respJSON map[string]interface{}
  39772. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39775. return
  39776. }
  39777. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39778. userJSONBytes, _ := json.Marshal(respJSON)
  39779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39780. utils.ErrorLog("解析失败:%v", err)
  39781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39782. return
  39783. }
  39784. }
  39785. if miConfig.MdtrtareaAdmvs == "420200" {
  39786. client := &http.Client{}
  39787. bytesData, _ := json.Marshal(data)
  39788. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  39789. resp, _ := client.Do(req)
  39790. defer resp.Body.Close()
  39791. body, ioErr := ioutil.ReadAll(resp.Body)
  39792. if ioErr != nil {
  39793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39795. return
  39796. }
  39797. var respJSON map[string]interface{}
  39798. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39801. return
  39802. }
  39803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39804. userJSONBytes, _ := json.Marshal(respJSON)
  39805. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39806. utils.ErrorLog("解析失败:%v", err)
  39807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39808. return
  39809. }
  39810. }
  39811. if miConfig.MdtrtareaAdmvs == "421182" {
  39812. client := &http.Client{}
  39813. bytesData, _ := json.Marshal(data)
  39814. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  39815. resp, _ := client.Do(req)
  39816. defer resp.Body.Close()
  39817. body, ioErr := ioutil.ReadAll(resp.Body)
  39818. if ioErr != nil {
  39819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39821. return
  39822. }
  39823. var respJSON map[string]interface{}
  39824. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39827. return
  39828. }
  39829. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39830. userJSONBytes, _ := json.Marshal(respJSON)
  39831. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39832. utils.ErrorLog("解析失败:%v", err)
  39833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39834. return
  39835. }
  39836. }
  39837. if miConfig.MdtrtareaAdmvs == "420902" {
  39838. client := &http.Client{}
  39839. bytesData, _ := json.Marshal(data)
  39840. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  39841. resp, _ := client.Do(req)
  39842. defer resp.Body.Close()
  39843. body, ioErr := ioutil.ReadAll(resp.Body)
  39844. if ioErr != nil {
  39845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39847. return
  39848. }
  39849. var respJSON map[string]interface{}
  39850. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39853. return
  39854. }
  39855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39856. userJSONBytes, _ := json.Marshal(respJSON)
  39857. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39858. utils.ErrorLog("解析失败:%v", err)
  39859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39860. return
  39861. }
  39862. }
  39863. if res.Infcode == 0 {
  39864. c.ServeSuccessJSON(map[string]interface{}{
  39865. "msg": "撤销成功",
  39866. })
  39867. } else {
  39868. c.ServeSuccessJSON(map[string]interface{}{
  39869. "failed_code": -10,
  39870. "msg": res.ErrMsg,
  39871. })
  39872. }
  39873. }
  39874. }
  39875. func (c *HisApiController) Post3204() {
  39876. admin_user_id, _ := c.GetInt64("admin_user_id")
  39877. id := c.GetString("id")
  39878. adminUser := c.GetAdminUserInfo()
  39879. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39880. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39881. //clr_org := miConfig.MdtrtareaAdmvs
  39882. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39883. var res ResultSix
  39884. if config.IsOpen == 1 {
  39885. data := make(map[string]interface{})
  39886. data["id"] = id
  39887. data["org_name"] = miConfig.OrgName
  39888. data["doctor"] = role.UserName
  39889. data["fixmedins_code"] = miConfig.Code
  39890. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39891. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39892. client := &http.Client{}
  39893. bytesData, _ := json.Marshal(data)
  39894. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  39895. resp, _ := client.Do(req)
  39896. defer resp.Body.Close()
  39897. body, ioErr := ioutil.ReadAll(resp.Body)
  39898. if ioErr != nil {
  39899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39901. return
  39902. }
  39903. var respJSON map[string]interface{}
  39904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39907. return
  39908. }
  39909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39910. userJSONBytes, _ := json.Marshal(respJSON)
  39911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39912. utils.ErrorLog("解析失败:%v", err)
  39913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39914. return
  39915. }
  39916. if res.Infcode == 0 {
  39917. c.ServeSuccessJSON(map[string]interface{}{
  39918. "msg": "发起成功",
  39919. })
  39920. } else {
  39921. c.ServeSuccessJSON(map[string]interface{}{
  39922. "failed_code": -10,
  39923. "msg": res.ErrMsg,
  39924. })
  39925. }
  39926. }
  39927. }
  39928. func (c *HisApiController) Post8404() {
  39929. admin_user_id, _ := c.GetInt64("admin_user_id")
  39930. month := c.GetString("month")
  39931. adminUser := c.GetAdminUserInfo()
  39932. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39933. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39934. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39935. var res ResultSix
  39936. if config.IsOpen == 1 {
  39937. data := make(map[string]interface{})
  39938. data["month"] = month
  39939. data["org_name"] = miConfig.OrgName
  39940. data["doctor"] = role.UserName
  39941. data["fixmedins_code"] = miConfig.Code
  39942. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39943. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39944. client := &http.Client{}
  39945. bytesData, _ := json.Marshal(data)
  39946. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  39947. resp, _ := client.Do(req)
  39948. defer resp.Body.Close()
  39949. body, ioErr := ioutil.ReadAll(resp.Body)
  39950. if ioErr != nil {
  39951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39953. return
  39954. }
  39955. var respJSON map[string]interface{}
  39956. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39959. return
  39960. }
  39961. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39962. userJSONBytes, _ := json.Marshal(respJSON)
  39963. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39964. utils.ErrorLog("解析失败:%v", err)
  39965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39966. return
  39967. }
  39968. if res.Infcode == 0 {
  39969. c.ServeSuccessJSON(map[string]interface{}{
  39970. "msg": "查询成功",
  39971. })
  39972. } else {
  39973. c.ServeSuccessJSON(map[string]interface{}{
  39974. "failed_code": -10,
  39975. "msg": res.ErrMsg,
  39976. })
  39977. }
  39978. }
  39979. }
  39980. func (c *HisApiController) Post3202b() {
  39981. start_time := c.GetString("start_time")
  39982. end_time := c.GetString("end_time")
  39983. //insutype := c.GetString("insutype")
  39984. clr_type := c.GetString("clr_type")
  39985. clr_org := c.GetString("clr_optins")
  39986. admin_user_id, _ := c.GetInt64("admin_user_id")
  39987. adminUser := c.GetAdminUserInfo()
  39988. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39989. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39990. if len(clr_org) == 0 {
  39991. clr_org = miConfig.MdtrtareaAdmvs
  39992. }
  39993. timeLayout := "2006-01-02"
  39994. loc, _ := time.LoadLocation("Local")
  39995. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39996. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39997. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39998. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39999. //fixmedins_setl_cnt := int64(len(orders))
  40000. var medfee_sumamt float64
  40001. var acct_pay float64
  40002. var fund_pay_sumamt float64
  40003. for _, item := range orders {
  40004. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40005. acct_pay = acct_pay + item.AcctPay
  40006. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40007. }
  40008. //var medfee_sumamt_two float64
  40009. //var acct_pay_two float64
  40010. //var fund_pay_sumamt_two float64
  40011. //for _, item := range orders_two {
  40012. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40013. // acct_pay_two = acct_pay_two + item.AcctPay
  40014. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40015. //}
  40016. //var user_name string
  40017. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40018. //if role.ID == 0 {
  40019. // user_name = "xxx"
  40020. //} else {
  40021. // user_name = role.UserName
  40022. //}
  40023. var res ResultSix
  40024. if config.IsOpen == 1 {
  40025. var bps []*models.BusinessParamsTwo
  40026. var bp models.BusinessParamsTwo
  40027. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40028. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40029. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40030. bp.MedfeeSumamt = medfee_sumamt_str
  40031. bp.AcctPay = acct_pay_str
  40032. bp.FundPaySumamt = fund_pay_sumamt_str
  40033. bp.Insutype = "390"
  40034. bp.StmtBegndate = start_time
  40035. bp.ClrType = clr_type
  40036. bp.SetlOptins = clr_org
  40037. bp.StmtEnddate = end_time
  40038. bps = append(bps, &bp)
  40039. data := make(map[string]interface{})
  40040. data["bps"] = bps
  40041. data["org_name"] = miConfig.OrgName
  40042. data["doctor"] = role.UserName
  40043. data["fixmedins_code"] = miConfig.Code
  40044. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40045. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40046. if miConfig.MdtrtareaAdmvs == "421300" {
  40047. client := &http.Client{}
  40048. bytesData, _ := json.Marshal(data)
  40049. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40050. resp, _ := client.Do(req)
  40051. defer resp.Body.Close()
  40052. body, ioErr := ioutil.ReadAll(resp.Body)
  40053. if ioErr != nil {
  40054. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40056. return
  40057. }
  40058. var respJSON map[string]interface{}
  40059. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40060. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40062. return
  40063. }
  40064. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40065. userJSONBytes, _ := json.Marshal(respJSON)
  40066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40067. utils.ErrorLog("解析失败:%v", err)
  40068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40069. return
  40070. }
  40071. }
  40072. if miConfig.MdtrtareaAdmvs == "420200" {
  40073. client := &http.Client{}
  40074. bytesData, _ := json.Marshal(data)
  40075. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40076. resp, _ := client.Do(req)
  40077. defer resp.Body.Close()
  40078. body, ioErr := ioutil.ReadAll(resp.Body)
  40079. if ioErr != nil {
  40080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40082. return
  40083. }
  40084. var respJSON map[string]interface{}
  40085. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40088. return
  40089. }
  40090. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40091. userJSONBytes, _ := json.Marshal(respJSON)
  40092. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40093. utils.ErrorLog("解析失败:%v", err)
  40094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40095. return
  40096. }
  40097. }
  40098. if miConfig.MdtrtareaAdmvs == "421182" {
  40099. client := &http.Client{}
  40100. bytesData, _ := json.Marshal(data)
  40101. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  40102. resp, _ := client.Do(req)
  40103. defer resp.Body.Close()
  40104. body, ioErr := ioutil.ReadAll(resp.Body)
  40105. if ioErr != nil {
  40106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40108. return
  40109. }
  40110. var respJSON map[string]interface{}
  40111. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40114. return
  40115. }
  40116. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40117. userJSONBytes, _ := json.Marshal(respJSON)
  40118. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40119. utils.ErrorLog("解析失败:%v", err)
  40120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40121. return
  40122. }
  40123. }
  40124. if res.Infcode == 0 {
  40125. c.ServeSuccessJSON(map[string]interface{}{
  40126. "msg": "发起成功",
  40127. })
  40128. } else {
  40129. c.ServeSuccessJSON(map[string]interface{}{
  40130. "failed_code": -10,
  40131. "msg": res.ErrMsg,
  40132. })
  40133. }
  40134. }
  40135. }
  40136. func (c *HisApiController) Post1608() {
  40137. start_time := c.GetString("start_time")
  40138. end_time := c.GetString("end_time")
  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. timeLayout := "2006-01-02"
  40144. loc, _ := time.LoadLocation("Local")
  40145. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40146. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40147. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40148. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40149. fixmedins_setl_cnt := int64(len(orders))
  40150. var medfee_sumamt float64
  40151. var func_smamt float64
  40152. for _, item := range orders {
  40153. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40154. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  40155. }
  40156. times := strings.Split(start_time, "-")
  40157. time_tows := strings.Split(end_time, "-")
  40158. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40159. var res ResultSix
  40160. if config.IsOpen == 1 {
  40161. //var bps []*models.BusinessParamsTwo
  40162. //var bp models.BusinessParamsTwo
  40163. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40164. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  40165. data := make(map[string]interface{})
  40166. data["org_name"] = miConfig.OrgName
  40167. data["doctor"] = role.UserName
  40168. data["func_smamt"] = func_smamt_str
  40169. data["fixmedins_code"] = miConfig.Code
  40170. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40171. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40172. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  40173. data["medfee_sumamt"] = medfee_sumamt_str
  40174. data["start_time"] = times[0] + times[1] + times[2]
  40175. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  40176. if miConfig.MdtrtareaAdmvs == "421300" {
  40177. client := &http.Client{}
  40178. bytesData, _ := json.Marshal(data)
  40179. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40180. resp, _ := client.Do(req)
  40181. defer resp.Body.Close()
  40182. body, ioErr := ioutil.ReadAll(resp.Body)
  40183. if ioErr != nil {
  40184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40186. return
  40187. }
  40188. var respJSON map[string]interface{}
  40189. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40192. return
  40193. }
  40194. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40195. userJSONBytes, _ := json.Marshal(respJSON)
  40196. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40197. utils.ErrorLog("解析失败:%v", err)
  40198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40199. return
  40200. }
  40201. }
  40202. if miConfig.MdtrtareaAdmvs == "420200" {
  40203. client := &http.Client{}
  40204. bytesData, _ := json.Marshal(data)
  40205. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40206. resp, _ := client.Do(req)
  40207. defer resp.Body.Close()
  40208. body, ioErr := ioutil.ReadAll(resp.Body)
  40209. if ioErr != nil {
  40210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40212. return
  40213. }
  40214. var respJSON map[string]interface{}
  40215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40218. return
  40219. }
  40220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40221. userJSONBytes, _ := json.Marshal(respJSON)
  40222. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40223. utils.ErrorLog("解析失败:%v", err)
  40224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40225. return
  40226. }
  40227. }
  40228. if miConfig.MdtrtareaAdmvs == "421182" {
  40229. client := &http.Client{}
  40230. bytesData, _ := json.Marshal(data)
  40231. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  40232. resp, _ := client.Do(req)
  40233. defer resp.Body.Close()
  40234. body, ioErr := ioutil.ReadAll(resp.Body)
  40235. if ioErr != nil {
  40236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40238. return
  40239. }
  40240. var respJSON map[string]interface{}
  40241. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40244. return
  40245. }
  40246. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40247. userJSONBytes, _ := json.Marshal(respJSON)
  40248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40249. utils.ErrorLog("解析失败:%v", err)
  40250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40251. return
  40252. }
  40253. }
  40254. if res.Infcode == 0 {
  40255. c.ServeSuccessJSON(map[string]interface{}{
  40256. "msg": "发起成功",
  40257. })
  40258. } else {
  40259. c.ServeSuccessJSON(map[string]interface{}{
  40260. "failed_code": -10,
  40261. "msg": res.ErrMsg,
  40262. })
  40263. }
  40264. }
  40265. }
  40266. // 5.11.1.1【5262】结算信息按时间段查询
  40267. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40268. admin_user_id, _ := c.GetInt64("admin_user_id")
  40269. adminUser := c.GetAdminUserInfo()
  40270. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40271. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40272. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40273. var res Result5262
  40274. if config.IsOpen == 1 {
  40275. if miConfig.MdtrtareaAdmvs == "421300" {
  40276. data := make(map[string]interface{})
  40277. data["bps"] = bp
  40278. data["org_name"] = miConfig.OrgName
  40279. data["doctor"] = role.UserName
  40280. data["fixmedins_code"] = miConfig.Code
  40281. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40282. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40283. data["page"] = strconv.FormatInt(page, 10)
  40284. data["limit"] = strconv.FormatInt(limit, 10)
  40285. fmt.Println(data)
  40286. client := &http.Client{}
  40287. bytesData, _ := json.Marshal(data)
  40288. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", 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 miConfig.MdtrtareaAdmvs == "420200" {
  40312. data := make(map[string]interface{})
  40313. data["bps"] = bp
  40314. data["org_name"] = miConfig.OrgName
  40315. data["doctor"] = role.UserName
  40316. data["fixmedins_code"] = miConfig.Code
  40317. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40318. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40319. data["page"] = strconv.FormatInt(page, 10)
  40320. data["limit"] = strconv.FormatInt(limit, 10)
  40321. fmt.Println(data)
  40322. client := &http.Client{}
  40323. bytesData, _ := json.Marshal(data)
  40324. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40325. resp, _ := client.Do(req)
  40326. defer resp.Body.Close()
  40327. body, ioErr := ioutil.ReadAll(resp.Body)
  40328. if ioErr != nil {
  40329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40331. return
  40332. }
  40333. var respJSON map[string]interface{}
  40334. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40337. return
  40338. }
  40339. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40340. userJSONBytes, _ := json.Marshal(respJSON)
  40341. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40342. utils.ErrorLog("解析失败:%v", err)
  40343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40344. return
  40345. }
  40346. }
  40347. if miConfig.MdtrtareaAdmvs == "421182" {
  40348. data := make(map[string]interface{})
  40349. data["bps"] = bp
  40350. data["org_name"] = miConfig.OrgName
  40351. data["doctor"] = role.UserName
  40352. data["fixmedins_code"] = miConfig.Code
  40353. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40354. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40355. data["page"] = strconv.FormatInt(page, 10)
  40356. data["limit"] = strconv.FormatInt(limit, 10)
  40357. fmt.Println(data)
  40358. client := &http.Client{}
  40359. bytesData, _ := json.Marshal(data)
  40360. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40361. resp, _ := client.Do(req)
  40362. defer resp.Body.Close()
  40363. body, ioErr := ioutil.ReadAll(resp.Body)
  40364. if ioErr != nil {
  40365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40367. return
  40368. }
  40369. var respJSON map[string]interface{}
  40370. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40373. return
  40374. }
  40375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40376. userJSONBytes, _ := json.Marshal(respJSON)
  40377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40378. utils.ErrorLog("解析失败:%v", err)
  40379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40380. return
  40381. }
  40382. }
  40383. if miConfig.MdtrtareaAdmvs == "420902" {
  40384. data := make(map[string]interface{})
  40385. data["bps"] = bp
  40386. data["org_name"] = miConfig.OrgName
  40387. data["doctor"] = role.UserName
  40388. data["fixmedins_code"] = miConfig.Code
  40389. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40390. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40391. data["page"] = strconv.FormatInt(page, 10)
  40392. data["limit"] = strconv.FormatInt(limit, 10)
  40393. fmt.Println(data)
  40394. client := &http.Client{}
  40395. bytesData, _ := json.Marshal(data)
  40396. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40397. resp, _ := client.Do(req)
  40398. defer resp.Body.Close()
  40399. body, ioErr := ioutil.ReadAll(resp.Body)
  40400. if ioErr != nil {
  40401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40403. return
  40404. }
  40405. var respJSON map[string]interface{}
  40406. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40409. return
  40410. }
  40411. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40412. userJSONBytes, _ := json.Marshal(respJSON)
  40413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40414. utils.ErrorLog("解析失败:%v", err)
  40415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40416. return
  40417. }
  40418. }
  40419. if res.Infcode == 0 {
  40420. c.ServeSuccessJSON(map[string]interface{}{
  40421. "order": res.Output.Result,
  40422. "total": res.Output.PageInfo.RecordCounts,
  40423. })
  40424. } else {
  40425. c.ServeSuccessJSON(map[string]interface{}{
  40426. "failed_code": -10,
  40427. "msg": res.ErrMsg,
  40428. })
  40429. }
  40430. }
  40431. }
  40432. // 5.11.1.2【5267】异地结算信息时间段查询
  40433. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  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. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40439. var res Result5267
  40440. if config.IsOpen == 1 {
  40441. if miConfig.MdtrtareaAdmvs == "421300" {
  40442. data := make(map[string]interface{})
  40443. data["bps"] = bp
  40444. data["org_name"] = miConfig.OrgName
  40445. data["doctor"] = role.UserName
  40446. data["fixmedins_code"] = miConfig.Code
  40447. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40448. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40449. data["page"] = page
  40450. data["limit"] = limit
  40451. fmt.Println(data)
  40452. client := &http.Client{}
  40453. bytesData, _ := json.Marshal(data)
  40454. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40455. resp, _ := client.Do(req)
  40456. defer resp.Body.Close()
  40457. body, ioErr := ioutil.ReadAll(resp.Body)
  40458. if ioErr != nil {
  40459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40461. return
  40462. }
  40463. var respJSON map[string]interface{}
  40464. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40467. return
  40468. }
  40469. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40470. userJSONBytes, _ := json.Marshal(respJSON)
  40471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40472. utils.ErrorLog("解析失败:%v", err)
  40473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40474. return
  40475. }
  40476. }
  40477. if miConfig.MdtrtareaAdmvs == "420200" {
  40478. data := make(map[string]interface{})
  40479. data["bps"] = bp
  40480. data["org_name"] = miConfig.OrgName
  40481. data["doctor"] = role.UserName
  40482. data["fixmedins_code"] = miConfig.Code
  40483. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40484. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40485. data["page"] = page
  40486. data["limit"] = limit
  40487. fmt.Println(data)
  40488. client := &http.Client{}
  40489. bytesData, _ := json.Marshal(data)
  40490. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40491. resp, _ := client.Do(req)
  40492. defer resp.Body.Close()
  40493. body, ioErr := ioutil.ReadAll(resp.Body)
  40494. if ioErr != nil {
  40495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40497. return
  40498. }
  40499. var respJSON map[string]interface{}
  40500. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40503. return
  40504. }
  40505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40506. userJSONBytes, _ := json.Marshal(respJSON)
  40507. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40508. utils.ErrorLog("解析失败:%v", err)
  40509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40510. return
  40511. }
  40512. }
  40513. if miConfig.MdtrtareaAdmvs == "421182" {
  40514. data := make(map[string]interface{})
  40515. data["bps"] = bp
  40516. data["org_name"] = miConfig.OrgName
  40517. data["doctor"] = role.UserName
  40518. data["fixmedins_code"] = miConfig.Code
  40519. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40520. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40521. data["page"] = page
  40522. data["limit"] = limit
  40523. fmt.Println(data)
  40524. client := &http.Client{}
  40525. bytesData, _ := json.Marshal(data)
  40526. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  40527. resp, _ := client.Do(req)
  40528. defer resp.Body.Close()
  40529. body, ioErr := ioutil.ReadAll(resp.Body)
  40530. if ioErr != nil {
  40531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40533. return
  40534. }
  40535. var respJSON map[string]interface{}
  40536. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40539. return
  40540. }
  40541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40542. userJSONBytes, _ := json.Marshal(respJSON)
  40543. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40544. utils.ErrorLog("解析失败:%v", err)
  40545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40546. return
  40547. }
  40548. }
  40549. if res.Infcode == 0 {
  40550. c.ServeSuccessJSON(map[string]interface{}{
  40551. "order": res.Output.Result,
  40552. "total": res.Output.PageInfo.RecordCounts,
  40553. })
  40554. } else {
  40555. c.ServeSuccessJSON(map[string]interface{}{
  40556. "failed_code": -10,
  40557. "msg": res.ErrMsg,
  40558. })
  40559. }
  40560. }
  40561. }
  40562. func (c *HisApiController) Post3501() {
  40563. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40564. data := make(map[string]interface{})
  40565. var struct3501s []models.Struct3501
  40566. var struct3501 models.Struct3501
  40567. struct3501.OrgName = miConfig.OrgName
  40568. struct3501.AccessKey = miConfig.AccessKey
  40569. struct3501.RequestUrl = miConfig.Url
  40570. struct3501.SecretKey = miConfig.SecretKey
  40571. struct3501.ManuDate = "2022-08-17"
  40572. struct3501.FixmedinsBchno = ""
  40573. struct3501.ManuLotnum = ""
  40574. struct3501.RxFlag = "0"
  40575. struct3501.ExpyEnd = "2022-08-17"
  40576. struct3501.Invdate = "2022-08-17"
  40577. struct3501.InvCnt = "20.25"
  40578. struct3501.Memo = ""
  40579. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40580. struct3501.FixmedinsHilistId = miConfig.Code
  40581. struct3501.FixmedinsHilistName = miConfig.OrgName
  40582. struct3501s = append(struct3501s, struct3501)
  40583. data["struct_3501s"] = struct3501s
  40584. client := &http.Client{}
  40585. bytesData, _ := json.Marshal(data)
  40586. var req *http.Request
  40587. if miConfig.MdtrtareaAdmvs == "320830" {
  40588. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  40589. } else if miConfig.MdtrtareaAdmvs == "320921" {
  40590. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40591. } else {
  40592. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40593. }
  40594. resp, _ := client.Do(req)
  40595. defer resp.Body.Close()
  40596. body, ioErr := ioutil.ReadAll(resp.Body)
  40597. if ioErr != nil {
  40598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40600. return
  40601. }
  40602. var respJSON map[string]interface{}
  40603. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40606. return
  40607. }
  40608. var res ResultSix
  40609. var resSix10265 ResultSix10265 //1101结果
  40610. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40611. result, _ := json.Marshal(respJSON)
  40612. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40613. utils.ErrorLog("解析失败:%v", err)
  40614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40615. return
  40616. }
  40617. res.InfRefmsgid = resSix10265.InfRefmsgid
  40618. res.Output = resSix10265.Output
  40619. res.ErrMsg = resSix10265.ErrMsg
  40620. res.Cainfo = resSix10265.Cainfo
  40621. res.WarnMsg = resSix10265.WarnMsg
  40622. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40623. res.Infcode = infocode
  40624. if infocode == 0 {
  40625. c.ServeSuccessJSON(map[string]interface{}{
  40626. "msg": "上传成功",
  40627. })
  40628. return
  40629. } else {
  40630. c.ServeSuccessJSON(map[string]interface{}{
  40631. "failed_code": -10,
  40632. "msg": res.ErrMsg,
  40633. })
  40634. return
  40635. }
  40636. }
  40637. func (c *HisApiController) Post3502() {
  40638. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40639. data := make(map[string]interface{})
  40640. var struct3502s []models.Struct3502
  40641. var struct3502 models.Struct3502
  40642. struct3502.OrgName = miConfig.OrgName
  40643. struct3502.AccessKey = miConfig.AccessKey
  40644. struct3502.RequestUrl = miConfig.Url
  40645. struct3502.SecretKey = miConfig.SecretKey
  40646. struct3502.ManuDate = "2022-08-15"
  40647. struct3502.FixmedinsBchno = ""
  40648. struct3502.ManuLotnum = ""
  40649. struct3502.RxFlag = "0"
  40650. struct3502.ExpyEnd = "2022-08-15"
  40651. struct3502.Invdate = "2022-08-15"
  40652. struct3502.InvCnt = "20.25"
  40653. struct3502.Memo = ""
  40654. struct3502.MedListCodg = "XB01ABD056B002020200517"
  40655. struct3502.FixmedinsHilistId = miConfig.Code
  40656. struct3502.FixmedinsHilistName = miConfig.OrgName
  40657. struct3502s = append(struct3502s, struct3502)
  40658. data["struct_3502s"] = struct3502s
  40659. client := &http.Client{}
  40660. bytesData, _ := json.Marshal(data)
  40661. var req *http.Request
  40662. if miConfig.MdtrtareaAdmvs == "320830" {
  40663. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  40664. } else if miConfig.MdtrtareaAdmvs == "320921" {
  40665. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40666. } else {
  40667. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40668. }
  40669. resp, _ := client.Do(req)
  40670. defer resp.Body.Close()
  40671. body, ioErr := ioutil.ReadAll(resp.Body)
  40672. if ioErr != nil {
  40673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40675. return
  40676. }
  40677. var respJSON map[string]interface{}
  40678. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40681. return
  40682. }
  40683. var res ResultSix
  40684. var resSix10265 ResultSix10265 //1101结果
  40685. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40686. result, _ := json.Marshal(respJSON)
  40687. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40688. utils.ErrorLog("解析失败:%v", err)
  40689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40690. return
  40691. }
  40692. res.InfRefmsgid = resSix10265.InfRefmsgid
  40693. res.Output = resSix10265.Output
  40694. res.ErrMsg = resSix10265.ErrMsg
  40695. res.Cainfo = resSix10265.Cainfo
  40696. res.WarnMsg = resSix10265.WarnMsg
  40697. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40698. res.Infcode = infocode
  40699. if infocode == 0 {
  40700. c.ServeSuccessJSON(map[string]interface{}{
  40701. "msg": "上传成功",
  40702. })
  40703. return
  40704. } else {
  40705. c.ServeSuccessJSON(map[string]interface{}{
  40706. "failed_code": -10,
  40707. "msg": res.ErrMsg,
  40708. })
  40709. return
  40710. }
  40711. }
  40712. func (c *HisApiController) Post3503() {
  40713. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40714. data := make(map[string]interface{})
  40715. var struct3501s []models.Struct3501
  40716. var struct3501 models.Struct3501
  40717. struct3501.OrgName = miConfig.OrgName
  40718. struct3501.AccessKey = miConfig.AccessKey
  40719. struct3501.RequestUrl = miConfig.Url
  40720. struct3501.SecretKey = miConfig.SecretKey
  40721. struct3501.ManuDate = "2022-08-15"
  40722. struct3501.FixmedinsBchno = ""
  40723. struct3501.ManuLotnum = ""
  40724. struct3501.RxFlag = "0"
  40725. struct3501.ExpyEnd = "2022-08-15"
  40726. struct3501.Invdate = "2022-08-15"
  40727. struct3501.InvCnt = "20.25"
  40728. struct3501.Memo = ""
  40729. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40730. struct3501.FixmedinsHilistId = miConfig.Code
  40731. struct3501.FixmedinsHilistName = miConfig.OrgName
  40732. struct3501s = append(struct3501s, struct3501)
  40733. data["struct_3501s"] = struct3501s
  40734. client := &http.Client{}
  40735. bytesData, _ := json.Marshal(data)
  40736. var req *http.Request
  40737. if miConfig.MdtrtareaAdmvs == "320921" {
  40738. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40739. } else {
  40740. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40741. }
  40742. resp, _ := client.Do(req)
  40743. defer resp.Body.Close()
  40744. body, ioErr := ioutil.ReadAll(resp.Body)
  40745. if ioErr != nil {
  40746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40748. return
  40749. }
  40750. var respJSON map[string]interface{}
  40751. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40754. return
  40755. }
  40756. var res ResultSix
  40757. var resSix10265 ResultSix10265 //1101结果
  40758. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40759. result, _ := json.Marshal(respJSON)
  40760. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40761. utils.ErrorLog("解析失败:%v", err)
  40762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40763. return
  40764. }
  40765. res.InfRefmsgid = resSix10265.InfRefmsgid
  40766. res.Output = resSix10265.Output
  40767. res.ErrMsg = resSix10265.ErrMsg
  40768. res.Cainfo = resSix10265.Cainfo
  40769. res.WarnMsg = resSix10265.WarnMsg
  40770. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40771. res.Infcode = infocode
  40772. if infocode == 0 {
  40773. c.ServeSuccessJSON(map[string]interface{}{
  40774. "msg": "上传成功",
  40775. })
  40776. return
  40777. } else {
  40778. c.ServeSuccessJSON(map[string]interface{}{
  40779. "failed_code": -10,
  40780. "msg": res.ErrMsg,
  40781. })
  40782. return
  40783. }
  40784. }
  40785. func (c *HisApiController) Post3504() {
  40786. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40787. data := make(map[string]interface{})
  40788. var struct3501s []models.Struct3501
  40789. var struct3501 models.Struct3501
  40790. struct3501.OrgName = miConfig.OrgName
  40791. struct3501.AccessKey = miConfig.AccessKey
  40792. struct3501.RequestUrl = miConfig.Url
  40793. struct3501.SecretKey = miConfig.SecretKey
  40794. struct3501.ManuDate = "2022-08-15"
  40795. struct3501.FixmedinsBchno = ""
  40796. struct3501.ManuLotnum = ""
  40797. struct3501.RxFlag = "0"
  40798. struct3501.ExpyEnd = "2022-08-15"
  40799. struct3501.Invdate = "2022-08-15"
  40800. struct3501.InvCnt = "20.25"
  40801. struct3501.Memo = ""
  40802. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40803. struct3501.FixmedinsHilistId = miConfig.Code
  40804. struct3501.FixmedinsHilistName = miConfig.OrgName
  40805. struct3501s = append(struct3501s, struct3501)
  40806. data["struct_3501s"] = struct3501s
  40807. client := &http.Client{}
  40808. bytesData, _ := json.Marshal(data)
  40809. var req *http.Request
  40810. if miConfig.MdtrtareaAdmvs == "320921" {
  40811. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40812. } else {
  40813. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40814. }
  40815. resp, _ := client.Do(req)
  40816. defer resp.Body.Close()
  40817. body, ioErr := ioutil.ReadAll(resp.Body)
  40818. if ioErr != nil {
  40819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40821. return
  40822. }
  40823. var respJSON map[string]interface{}
  40824. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40827. return
  40828. }
  40829. var res ResultSix
  40830. var resSix10265 ResultSix10265 //1101结果
  40831. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40832. result, _ := json.Marshal(respJSON)
  40833. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40834. utils.ErrorLog("解析失败:%v", err)
  40835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40836. return
  40837. }
  40838. res.InfRefmsgid = resSix10265.InfRefmsgid
  40839. res.Output = resSix10265.Output
  40840. res.ErrMsg = resSix10265.ErrMsg
  40841. res.Cainfo = resSix10265.Cainfo
  40842. res.WarnMsg = resSix10265.WarnMsg
  40843. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40844. res.Infcode = infocode
  40845. if infocode == 0 {
  40846. c.ServeSuccessJSON(map[string]interface{}{
  40847. "msg": "上传成功",
  40848. })
  40849. return
  40850. } else {
  40851. c.ServeSuccessJSON(map[string]interface{}{
  40852. "failed_code": -10,
  40853. "msg": res.ErrMsg,
  40854. })
  40855. return
  40856. }
  40857. }
  40858. func (c *HisApiController) Post3505() {
  40859. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40860. data := make(map[string]interface{})
  40861. var struct3501s []models.Struct3501
  40862. var struct3501 models.Struct3501
  40863. struct3501.OrgName = miConfig.OrgName
  40864. struct3501.AccessKey = miConfig.AccessKey
  40865. struct3501.RequestUrl = miConfig.Url
  40866. struct3501.SecretKey = miConfig.SecretKey
  40867. struct3501.ManuDate = "2022-08-15"
  40868. struct3501.FixmedinsBchno = ""
  40869. struct3501.ManuLotnum = ""
  40870. struct3501.RxFlag = "0"
  40871. struct3501.ExpyEnd = "2022-08-15"
  40872. struct3501.Invdate = "2022-08-15"
  40873. struct3501.InvCnt = "20.25"
  40874. struct3501.Memo = ""
  40875. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40876. struct3501.FixmedinsHilistId = miConfig.Code
  40877. struct3501.FixmedinsHilistName = miConfig.OrgName
  40878. struct3501s = append(struct3501s, struct3501)
  40879. data["struct_3501s"] = struct3501s
  40880. client := &http.Client{}
  40881. bytesData, _ := json.Marshal(data)
  40882. var req *http.Request
  40883. if miConfig.MdtrtareaAdmvs == "320921" {
  40884. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40885. } else {
  40886. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40887. }
  40888. resp, _ := client.Do(req)
  40889. defer resp.Body.Close()
  40890. body, ioErr := ioutil.ReadAll(resp.Body)
  40891. if ioErr != nil {
  40892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40894. return
  40895. }
  40896. var respJSON map[string]interface{}
  40897. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40900. return
  40901. }
  40902. var res ResultSix
  40903. var resSix10265 ResultSix10265 //1101结果
  40904. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40905. result, _ := json.Marshal(respJSON)
  40906. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40907. utils.ErrorLog("解析失败:%v", err)
  40908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40909. return
  40910. }
  40911. res.InfRefmsgid = resSix10265.InfRefmsgid
  40912. res.Output = resSix10265.Output
  40913. res.ErrMsg = resSix10265.ErrMsg
  40914. res.Cainfo = resSix10265.Cainfo
  40915. res.WarnMsg = resSix10265.WarnMsg
  40916. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40917. res.Infcode = infocode
  40918. if infocode == 0 {
  40919. c.ServeSuccessJSON(map[string]interface{}{
  40920. "msg": "上传成功",
  40921. })
  40922. return
  40923. } else {
  40924. c.ServeSuccessJSON(map[string]interface{}{
  40925. "failed_code": -10,
  40926. "msg": res.ErrMsg,
  40927. })
  40928. return
  40929. }
  40930. }
  40931. func (c *HisApiController) Post3506() {
  40932. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40933. data := make(map[string]interface{})
  40934. var struct3501s []models.Struct3501
  40935. var struct3501 models.Struct3501
  40936. struct3501.OrgName = miConfig.OrgName
  40937. struct3501.AccessKey = miConfig.AccessKey
  40938. struct3501.RequestUrl = miConfig.Url
  40939. struct3501.SecretKey = miConfig.SecretKey
  40940. struct3501.ManuDate = "2022-08-15"
  40941. struct3501.FixmedinsBchno = ""
  40942. struct3501.ManuLotnum = ""
  40943. struct3501.RxFlag = "0"
  40944. struct3501.ExpyEnd = "2022-08-15"
  40945. struct3501.Invdate = "2022-08-15"
  40946. struct3501.InvCnt = "20.25"
  40947. struct3501.Memo = ""
  40948. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40949. struct3501.FixmedinsHilistId = miConfig.Code
  40950. struct3501.FixmedinsHilistName = miConfig.OrgName
  40951. struct3501s = append(struct3501s, struct3501)
  40952. data["struct_3501s"] = struct3501s
  40953. client := &http.Client{}
  40954. bytesData, _ := json.Marshal(data)
  40955. var req *http.Request
  40956. if miConfig.MdtrtareaAdmvs == "320921" {
  40957. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40958. } else {
  40959. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40960. }
  40961. resp, _ := client.Do(req)
  40962. defer resp.Body.Close()
  40963. body, ioErr := ioutil.ReadAll(resp.Body)
  40964. if ioErr != nil {
  40965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40967. return
  40968. }
  40969. var respJSON map[string]interface{}
  40970. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40973. return
  40974. }
  40975. var res ResultSix
  40976. var resSix10265 ResultSix10265 //1101结果
  40977. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40978. result, _ := json.Marshal(respJSON)
  40979. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40980. utils.ErrorLog("解析失败:%v", err)
  40981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40982. return
  40983. }
  40984. res.InfRefmsgid = resSix10265.InfRefmsgid
  40985. res.Output = resSix10265.Output
  40986. res.ErrMsg = resSix10265.ErrMsg
  40987. res.Cainfo = resSix10265.Cainfo
  40988. res.WarnMsg = resSix10265.WarnMsg
  40989. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40990. res.Infcode = infocode
  40991. if infocode == 0 {
  40992. c.ServeSuccessJSON(map[string]interface{}{
  40993. "msg": "上传成功",
  40994. })
  40995. return
  40996. } else {
  40997. c.ServeSuccessJSON(map[string]interface{}{
  40998. "failed_code": -10,
  40999. "msg": res.ErrMsg,
  41000. })
  41001. return
  41002. }
  41003. }
  41004. func (c *HisApiController) Post3507() {
  41005. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41006. data := make(map[string]interface{})
  41007. var struct3501s []models.Struct3501
  41008. var struct3501 models.Struct3501
  41009. struct3501.OrgName = miConfig.OrgName
  41010. struct3501.AccessKey = miConfig.AccessKey
  41011. struct3501.RequestUrl = miConfig.Url
  41012. struct3501.SecretKey = miConfig.SecretKey
  41013. struct3501.ManuDate = "2022-08-15"
  41014. struct3501.FixmedinsBchno = ""
  41015. struct3501.ManuLotnum = ""
  41016. struct3501.RxFlag = "0"
  41017. struct3501.ExpyEnd = "2022-08-15"
  41018. struct3501.Invdate = "2022-08-15"
  41019. struct3501.InvCnt = "20.25"
  41020. struct3501.Memo = ""
  41021. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41022. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  41023. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  41024. struct3501s = append(struct3501s, struct3501)
  41025. data["struct_3501s"] = struct3501s
  41026. client := &http.Client{}
  41027. bytesData, _ := json.Marshal(data)
  41028. var req *http.Request
  41029. if miConfig.MdtrtareaAdmvs == "320921" {
  41030. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41031. } else {
  41032. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41033. }
  41034. resp, _ := client.Do(req)
  41035. defer resp.Body.Close()
  41036. body, ioErr := ioutil.ReadAll(resp.Body)
  41037. if ioErr != nil {
  41038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41040. return
  41041. }
  41042. var respJSON map[string]interface{}
  41043. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41046. return
  41047. }
  41048. var res ResultSix
  41049. var resSix10265 ResultSix10265 //1101结果
  41050. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41051. result, _ := json.Marshal(respJSON)
  41052. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41053. utils.ErrorLog("解析失败:%v", err)
  41054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41055. return
  41056. }
  41057. res.InfRefmsgid = resSix10265.InfRefmsgid
  41058. res.Output = resSix10265.Output
  41059. res.ErrMsg = resSix10265.ErrMsg
  41060. res.Cainfo = resSix10265.Cainfo
  41061. res.WarnMsg = resSix10265.WarnMsg
  41062. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41063. res.Infcode = infocode
  41064. if infocode == 0 {
  41065. c.ServeSuccessJSON(map[string]interface{}{
  41066. "msg": "上传成功",
  41067. })
  41068. return
  41069. } else {
  41070. c.ServeSuccessJSON(map[string]interface{}{
  41071. "failed_code": -10,
  41072. "msg": res.ErrMsg,
  41073. })
  41074. return
  41075. }
  41076. }
  41077. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41078. // WebSocket服务器地址
  41079. serverURL := "ws://127.0.0.1:8899"
  41080. // 解析WebSocket服务器地址
  41081. u, err := url.Parse(serverURL)
  41082. if err != nil {
  41083. }
  41084. // 建立WebSocket连接
  41085. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41086. if err != nil {
  41087. }
  41088. defer conn.Close()
  41089. input2 := make(map[string]interface{})
  41090. input := make(map[string]interface{})
  41091. inputData := make(map[string]interface{})
  41092. inputData["orgId"] = code
  41093. inputData["businessType"] = "01101"
  41094. inputData["operatorId"] = operator_id
  41095. inputData["operatorName"] = operator_name
  41096. inputData["officeId"] = "001"
  41097. inputData["officeName"] = "血透室"
  41098. inputData["deviceType"] = ""
  41099. input["data"] = inputData
  41100. input["orgId"] = code
  41101. input["transType"] = "ec.query"
  41102. //if md == ""
  41103. if md[:4] == "4403" {
  41104. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41105. } else if md[:4] == "4401" {
  41106. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41107. } else {
  41108. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41109. }
  41110. input2["indata"] = input
  41111. fmt.Println(input2)
  41112. bytesData, _ := json.Marshal(input2)
  41113. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41114. if err != nil {
  41115. fmt.Println(err)
  41116. }
  41117. // 接收消息
  41118. _, receivedMessage, err := conn.ReadMessage()
  41119. if err != nil {
  41120. fmt.Println(err)
  41121. }
  41122. return "", string(receivedMessage)
  41123. }
  41124. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  41125. // WebSocket服务器地址
  41126. serverURL := "ws://127.0.0.1:8899"
  41127. // 解析WebSocket服务器地址
  41128. u, err := url.Parse(serverURL)
  41129. if err != nil {
  41130. }
  41131. // 建立WebSocket连接
  41132. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41133. if err != nil {
  41134. }
  41135. defer conn.Close()
  41136. input2 := make(map[string]interface{})
  41137. input := make(map[string]interface{})
  41138. inputData := make(map[string]interface{})
  41139. inputData["orgId"] = code
  41140. inputData["businessType"] = "01101"
  41141. inputData["operatorId"] = operator_id
  41142. inputData["operatorName"] = operator_name
  41143. inputData["officeId"] = "001"
  41144. inputData["officeName"] = "血透室"
  41145. inputData["deviceType"] = ""
  41146. input["data"] = inputData
  41147. input["orgId"] = code
  41148. input["transType"] = "ec.query"
  41149. //if md == ""
  41150. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41151. input2["indata"] = input
  41152. fmt.Println(input2)
  41153. bytesData, _ := json.Marshal(input2)
  41154. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41155. if err != nil {
  41156. fmt.Println(err)
  41157. }
  41158. // 接收消息
  41159. _, receivedMessage, err := conn.ReadMessage()
  41160. if err != nil {
  41161. fmt.Println(err)
  41162. }
  41163. return "", string(receivedMessage)
  41164. }
  41165. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  41166. // WebSocket服务器地址
  41167. serverURL := "ws://127.0.0.1:8899"
  41168. // 解析WebSocket服务器地址
  41169. u, err := url.Parse(serverURL)
  41170. if err != nil {
  41171. }
  41172. // 建立WebSocket连接
  41173. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41174. if err != nil {
  41175. }
  41176. defer conn.Close()
  41177. input2 := make(map[string]interface{})
  41178. input := make(map[string]interface{})
  41179. inputData := make(map[string]interface{})
  41180. inputData["orgId"] = code
  41181. inputData["businessType"] = "01301"
  41182. inputData["operatorId"] = operator_id
  41183. inputData["operatorName"] = operator_name
  41184. inputData["officeId"] = "001"
  41185. inputData["officeName"] = "血透室"
  41186. inputData["deviceType"] = ""
  41187. input["data"] = inputData
  41188. input["orgId"] = code
  41189. input["transType"] = "ec.query"
  41190. //if md == ""
  41191. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41192. input2["indata"] = input
  41193. fmt.Println(input2)
  41194. bytesData, _ := json.Marshal(input2)
  41195. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41196. if err != nil {
  41197. fmt.Println(err)
  41198. }
  41199. // 接收消息
  41200. _, receivedMessage, err := conn.ReadMessage()
  41201. if err != nil {
  41202. fmt.Println(err)
  41203. }
  41204. return "", string(receivedMessage)
  41205. }
  41206. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  41207. // WebSocket服务器地址
  41208. serverURL := "ws://127.0.0.1:8899"
  41209. // 解析WebSocket服务器地址
  41210. u, err := url.Parse(serverURL)
  41211. if err != nil {
  41212. }
  41213. // 建立WebSocket连接
  41214. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41215. if err != nil {
  41216. }
  41217. defer conn.Close()
  41218. input2 := make(map[string]interface{})
  41219. input := make(map[string]interface{})
  41220. inputData := make(map[string]interface{})
  41221. inputData["orgId"] = code
  41222. inputData["businessType"] = "01103"
  41223. inputData["operatorId"] = operator_id
  41224. inputData["operatorName"] = operator_name
  41225. inputData["officeId"] = "001"
  41226. inputData["officeName"] = "血透室"
  41227. inputData["deviceType"] = ""
  41228. input["data"] = inputData
  41229. input["orgId"] = code
  41230. input["transType"] = "ec.query"
  41231. //if md ==
  41232. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  41233. input2["indata"] = input
  41234. fmt.Println(input2)
  41235. bytesData, _ := json.Marshal(input2)
  41236. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41237. if err != nil {
  41238. fmt.Println(err)
  41239. }
  41240. // 接收消息
  41241. _, receivedMessage, err := conn.ReadMessage()
  41242. if err != nil {
  41243. fmt.Println(err)
  41244. }
  41245. return "", string(receivedMessage)
  41246. }
  41247. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41248. // WebSocket服务器地址
  41249. serverURL := "ws://127.0.0.1:8899"
  41250. // 解析WebSocket服务器地址
  41251. u, err := url.Parse(serverURL)
  41252. if err != nil {
  41253. }
  41254. // 建立WebSocket连接
  41255. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41256. if err != nil {
  41257. }
  41258. defer conn.Close()
  41259. input2 := make(map[string]interface{})
  41260. input := make(map[string]interface{})
  41261. inputData := make(map[string]interface{})
  41262. inputData["orgId"] = code
  41263. inputData["businessType"] = "01101"
  41264. inputData["operatorId"] = operator_id
  41265. inputData["operatorName"] = operator_name
  41266. inputData["officeId"] = "001"
  41267. inputData["officeName"] = "血透室"
  41268. inputData["deviceType"] = ""
  41269. input["data"] = inputData
  41270. input["orgId"] = code
  41271. input["transType"] = "ec.query"
  41272. //if md == ""
  41273. if md[:4] == "4403" {
  41274. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41275. } else if md[:4] == "4401" {
  41276. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41277. } else {
  41278. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41279. }
  41280. input2["indata"] = input
  41281. fmt.Println(input2)
  41282. bytesData, _ := json.Marshal(input2)
  41283. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41284. if err != nil {
  41285. fmt.Println(err)
  41286. }
  41287. // 接收消息
  41288. _, receivedMessage, err := conn.ReadMessage()
  41289. if err != nil {
  41290. fmt.Println(err)
  41291. }
  41292. return "", string(receivedMessage)
  41293. }
  41294. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  41295. // WebSocket服务器地址
  41296. serverURL := "ws://127.0.0.1:8899"
  41297. // 解析WebSocket服务器地址
  41298. u, err := url.Parse(serverURL)
  41299. if err != nil {
  41300. }
  41301. // 建立WebSocket连接
  41302. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41303. if err != nil {
  41304. }
  41305. defer conn.Close()
  41306. input2 := make(map[string]interface{})
  41307. input := make(map[string]interface{})
  41308. inputData := make(map[string]interface{})
  41309. inputData["orgId"] = code
  41310. inputData["businessType"] = "01301"
  41311. inputData["operatorId"] = operator_id
  41312. inputData["operatorName"] = operator_name
  41313. inputData["officeId"] = "001"
  41314. inputData["officeName"] = "血透室"
  41315. inputData["deviceType"] = ""
  41316. input["data"] = inputData
  41317. input["orgId"] = code
  41318. input["transType"] = "ec.query"
  41319. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41320. input2["indata"] = input
  41321. bytesData, _ := json.Marshal(input2)
  41322. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41323. if err != nil {
  41324. fmt.Println(err)
  41325. }
  41326. // 接收消息
  41327. _, receivedMessage, err := conn.ReadMessage()
  41328. if err != nil {
  41329. fmt.Println(err)
  41330. }
  41331. return "", string(receivedMessage)
  41332. }
  41333. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  41334. newArr = make([]string, 0)
  41335. for i := 0; i < len(arr); i++ {
  41336. repeat := false
  41337. for j := i + 1; j < len(arr); j++ {
  41338. if arr[i] == arr[j] {
  41339. repeat = true
  41340. break
  41341. }
  41342. }
  41343. if !repeat {
  41344. newArr = append(newArr, arr[i])
  41345. }
  41346. }
  41347. return
  41348. }
  41349. func getBirthdateAndAge(idNumber string) (string, int, error) {
  41350. if len(idNumber) != 18 {
  41351. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  41352. }
  41353. // 提取出生日期
  41354. year, err := strconv.Atoi(idNumber[6:10])
  41355. if err != nil {
  41356. return "", 0, err
  41357. }
  41358. month, err := strconv.Atoi(idNumber[10:12])
  41359. if err != nil {
  41360. return "", 0, err
  41361. }
  41362. day, err := strconv.Atoi(idNumber[12:14])
  41363. if err != nil {
  41364. return "", 0, err
  41365. }
  41366. // 格式化生日字符串
  41367. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  41368. birthdateFormatted := birthdate.Format("2006-01-02")
  41369. // 计算年龄
  41370. today := time.Now()
  41371. age := today.Year() - birthdate.Year()
  41372. if today.YearDay() < birthdate.YearDay() {
  41373. age--
  41374. }
  41375. return birthdateFormatted, age, nil
  41376. }
  41377. // 从身份证号码中提取出生年月日
  41378. func getBirthDateFromIDCard(idCard string) (string, error) {
  41379. // 身份证号码长度应为18位
  41380. if len(idCard) != 18 {
  41381. return "", fmt.Errorf("身份证号码长度应为18位")
  41382. }
  41383. // 提取出生日期部分 (YYYYMMDD)
  41384. birthDateStr := idCard[6:14]
  41385. // 解析出生日期
  41386. birthDate, err := time.Parse("20060102", birthDateStr)
  41387. if err != nil {
  41388. return "", fmt.Errorf("解析出生日期失败: %v", err)
  41389. }
  41390. // 格式化出生日期为 YYYY-MM-DD
  41391. formattedDate := birthDate.Format("2006-01-02")
  41392. return formattedDate, nil
  41393. }